Last active
December 9, 2020 22:38
-
-
Save MisterJames/4732853 to your computer and use it in GitHub Desktop.
This is a code snippet that you can invoke via tab completion. Type aaa and get a full test method with Arrange, Act, Assert parts, with encouragement to help name your test method following Roy Osherove's lead (http://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> | |
<CodeSnippet Format="1.0.0"> | |
<Header> | |
<SnippetTypes> | |
<SnippetType>Expansion</SnippetType> | |
</SnippetTypes> | |
<Title>AAA Test Method</Title> | |
<Shortcut>aaa</Shortcut> | |
<Description>Code snippet for a test method with Arrange, Act, Assert</Description> | |
<Author>James Chambers</Author> | |
</Header> | |
<Snippet> | |
<Imports> | |
<Import> | |
<Namespace>Microsoft.VisualStudio.TestTools.UnitTesting</Namespace> | |
</Import> | |
</Imports> | |
<References> | |
<Reference> | |
<Assembly>Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll</Assembly> | |
</Reference> | |
</References> | |
<Declarations> | |
<Literal> | |
<ID>MethodName</ID> | |
<ToolTip>The name of the method under test</ToolTip> | |
<Default>Method</Default> | |
</Literal> | |
<Literal> | |
<ID>StateUnderTest</ID> | |
<ToolTip>Specific contditions that lead to expected result</ToolTip> | |
<Default>State</Default> | |
</Literal> | |
<Literal> | |
<ID>ExpectedBehavior</ID> | |
<ToolTip>The expected result of the given state when the method is invoked</ToolTip> | |
<Default>Expectations</Default> | |
</Literal> | |
<Literal Editable="false"> | |
<ID>TestMethod</ID> | |
<Function>SimpleTypeName(global::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod)</Function> | |
</Literal> | |
</Declarations> | |
<Code Language="csharp"> | |
<![CDATA[[$TestMethod$] | |
public void $MethodName$_$StateUnderTest$_$ExpectedBehavior$() | |
{ | |
// Arrange | |
$end$ | |
// Act | |
// Assert | |
} | |
]]></Code> | |
</Snippet> | |
</CodeSnippet> | |
</CodeSnippets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks