Skip to content

Instantly share code, notes, and snippets.

@kzu
Last active July 5, 2016 19:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kzu/2bb3316d59a3aa7a2216 to your computer and use it in GitHub Desktop.
Save kzu/2bb3316d59a3aa7a2216 to your computer and use it in GitHub Desktop.
Code snippet for creating BDD-style xUnit tests
<?xml version="1.0" encoding="utf-8" ?>
<!-- Download to %userprofile%\Documents\Visual Studio [2010|2012|2013|vNext]\Code Snippets\Visual C#\My Code Snippets -->
<!--
Template for xunit test methods
Press fact[tab][tab] to get it.
-->
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>XUnit test</Title>
<Shortcut>fact</Shortcut>
<Description>Create XUnit test method</Description>
<Author>Daniel Cazzulino</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Imports>
<Import>
<Namespace>Xunit</Namespace>
</Import>
</Imports>
<Declarations>
<Literal>
<ID>action</ID>
<ToolTip>Action performed on the given context</ToolTip>
<Default>action</Default>
</Literal>
<Literal>
<ID>assert</ID>
<ToolTip>The consequence of the action</ToolTip>
<Default>assert</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[[Fact]
public void when_$action$_then_$assert$()
{
$end$
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment