I like to comment my tests following the arrange, act, assert pattern.
E.g.
//Arrange
//Act
//Assert
Here is a snippet you can add to “your” snippets folder in Visual Studio 2019:
(or use menu Tools -> Code snippet manager to find your correct path to add to / or Import file).
Filename: C:\Users\andreasp\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets\testmethodcomment_act_arrange_assert.snippet
<?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <SnippetTypes> <SnippetType>Expansion</SnippetType> </SnippetTypes> <Title>Test Method Comment - Act Arrange Assert</Title> <Shortcut>testaaa</Shortcut> <Description>Code snippet for a test method structure comments. Act arrange assert</Description> </Header> <Snippet> <Code Language="csharp"> <![CDATA[//Arrange $end$ //Act //Assert ]]></Code> </Snippet> </CodeSnippet> </CodeSnippets>
Restart Visual Studio.
Usage:
Inside testmethod, type:
testaaa [tab]
The 3 comments will be inserted, and cursor below //Arrange comment line.