Snippet for creating testmethod in C#

Posted by Marcus Hammarberg on February 8, 2009
Stats

Here is a short snippet that saves me a lot of time. It simply creates a test method with the correct attributes and stuff. Simply but useful – and now you don’t have to write it.


<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>TestMethod</Title>
<Shortcut>tm</Shortcut>
<Description>Code snippet for creating a testmethod</Description>
<Author>Marcusoft (www.marcusoft.net)</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
<SnippetType>SurroundsWith</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>methodName</ID>
<ToolTip>The name of the test</ToolTip>
<Default>methodName</Default>
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[<TestMethod()> _
public void should_$methodName$()
{
// Arrange

// Act

// Assert
Assert.Fail("Implement test");
}]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>



Published by Marcus Hammarberg on Last updated