Skip to content

Instantly share code, notes, and snippets.

@brainwipe
Last active June 29, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brainwipe/960c026d0fef81bf50ee5e0bfcc4afd1 to your computer and use it in GitHub Desktop.
Save brainwipe/960c026d0fef81bf50ee5e0bfcc4afd1 to your computer and use it in GitHub Desktop.
Unit Test code snippet for Visual Studio 2017 using Given, When, Then and Arrange, Act and Assert
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Keywords>
<Keyword>unit</Keyword>
<Keyword>test</Keyword>
<Keyword>given</Keyword>
<Keyword>when</Keyword>
<Keyword>then</Keyword>
<Keyword>arrange</Keyword>
<Keyword>act</Keyword>
<Keyword>assert</Keyword>
</Keywords>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>gwt</Title>
<Author>brainwipe</Author>
<Description>Unit test format using Given,When,Then and Arrage/Act/Assert</Description>
<HelpUrl>https://brainwipe.github.io</HelpUrl>
<Shortcut>gwt</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>precondition</ID>
<ToolTip>precondition</ToolTip>
<Default>precondition</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>methodname</ID>
<ToolTip>methodname</ToolTip>
<Default>methodname</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>outcome</ID>
<ToolTip>outcome</ToolTip>
<Default>outcome</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="csharp" Delimiter="$"><![CDATA[[TestMethod]
public void GIVEN_$precondition$_WHEN_$methodname$_THEN_$outcome$()
{
// 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