Creating Test Template in Visual Studio using ReSharper

By: Slav Kurochkin

Here is a quick tutorial on how to create custom test template in Visual Studio using ReSharper plugin

In Visual Studio navigate to ReSharper in navigation (make sure you have ReSharper installed), and then Tools -> Template Explorer.
Once you in Template Explorer select desired language in Scopes windowand click on create new template button:

Creating test template in Visual Studio

Once the new template tab opened fill up with your desired test template code, I like the idea from one of the courses I been watching online to give test template method name something like the one bellow:

 [Test]
        public void METHOD_SCENARIO_EXPECTATION()
        {
        }

The name of the method template giving heads of the way test have to be written:
1) Give it appropriate name
2) Think of scenario against which you will run your test
3) And what is your expectation once scenario been completed

Let's get back to test template creation, give it a name and save.

Creating test template in Visual Studio

So in my case it is saved with name "test" every time I type the word test in Visual Studio Re-Sharper offers me to use my pre-defined template. Pretty simple and easy setup of test template which saves you a lot of time.

View Comments

Leave a Comment

Use markdown or basic HTML and be nice.