AAA Testing Snippet

This is a snippet I use quite often and send around.

It simply a framework for getting people to organise there unit tests around the AAA principal of Arrange, Act and Assert.

What does it do? Well not much really, it’s just a useful construct I find that helps split up a unit test, it’s a snippet for MSTEST but can quite easly be turned into an xUnit or NUnit snippet by changing the [TextMethod] mark up.

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">

<Header>
            <Title>AAA Test</Title>
            <Description>Arrange, act, assert test format</Description>
            <Author>James Hirka</Author>
            <Shortcut>aaatest</Shortcut>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Code Language="csharp"><![CDATA[[TestMethod] 
public void TestMethodName() 
{
 //-----------------------------------------------------------------------------------------------------------
 // Arrange
 //-----------------------------------------------------------------------------------------------------------

 //-----------------------------------------------------------------------------------------------------------
 // Act
 //-----------------------------------------------------------------------------------------------------------

 //-----------------------------------------------------------------------------------------------------------
 // Assert
 //----------------------------------------------------------------------------------------------------------- 

}]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

 

Leave a Reply

Your email address will not be published. Required fields are marked *