Act Arrange Assert Comment Snippet

When I write unit tests, I like to quickly add the following commenting or scaffolding:

public void NameOfTestMethod()
	//  Arrange

	//  Act

	//  Assert     

As I’m always on the lookout to streamline my workflows, I created a Visual Studio snippet for that commenting. The text of the snippet is:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="">
 <CodeSnippet Format="1.0.0">
   <Title>Act Arrange Assert</Title>
   <Description>Code snippet for Act, Arrange Assert text.</Description>
   <Code Language="csharp"><![CDATA[//  Arrange

            //  Act

            //  Assert                        

There’s a couple of ways of installing that snippet:

  1. Copy that text into a text editor and save it as a file with the snippet file extension into the relevant directory for snippets in your environment (I called mine aaa.snippet) . For me, that was
    E:\Documents\Dave\Documents\Visual Studio 2013\Code Snippets\Visual C#\My Code Snippets
  2. Open the Code Snippets Manager (Tools > Code Snippets Manager) and import it via that GUI:


To use the snippet, you just type the letters aaa then immediately hit the tab key twice. Also, you will need to restart Visual Studio (if it was already open when you saved the snippet).

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>