Write Unit Test Automatically using IntelliTest in Visual Studio 2015

By | July 19, 2015

Over the past few posts we have discussed about many topics on Unit Testing in Visual Studio. We have learned, How to write your very first Unit Test , Exploring and Managing Unit Tests and we have seen how the code coverage is one the important aspect to identify the uncovered portion of code. Keeping all these learning on mind, lets learn another aspect of writing Smart Unit Test, using “IntelliTest” in Visual Studio 2015.  IntelliTest helps us to create Unit Test automatically that give maximum of code coverage.

The overall process is very simple looks

IntelliTest in Visual Studio 201

Let’s have a look into how this works. Consider we have following method in a class which adds two positive number. ( We are using same example for all the unit test scenarios to understand it better and keep it simple) .


Now, Right Click on the Method, and Select “Run IntelliTest” from the context menu.



Once you select “Run IntelliTest” , Visual Studio performs certain steps to analyze and generate unit test for us.  You can view these steps from Output Window –> IntelliTest


As soon as the processing is done, Visual Studio will launch an another new windows called “IntelliTest Exploration Results”, that generates set of all possible unit tests based on the method parameters and which can cover the maximum of code path of the given code block. These generated test covers all possible combination of parameter values; including boundary condition. As you can see in the below windows, the generated methods with it’s targets and the number of parameter (a, b) and the value that has been used for test parameter.



If you select any of these targeted method from the IntelliTest windows, you would be able to see the Details of Generated Unit Test by the Pex.  This shows how internally a generated unit test getting called and cover the certain percentage of the code.


Select all the Unit Tests and Click in the Save Icon in the “IntellTest Exploration” Windows.

image \

This will add a new Unit Test Project  in the solution with all required assembly added. At this point of time you should be able to build the overall solution.


Now you can take help of Test Explorer to review, run and manage all the Unit Tests generated  through the IntelliTest.

Must Read : Exploring and Managing Unit Tests Using Test Explorer in Visual Studio


You can also take help of codelens to see the reference Tests methods, along with parameter used for test.

Must Read : Check the Unit Test Status Easily and Effectively – Test Status Indicator in Visual Studio



The last and final things is Code Coverage.  Read the below highlighted post to understand the basic of code coverage. Similarly, Code coverage for test methods generated through the IntelliTest can also be shown using the Code Coverage Windows.

Must Read :

Understanding Code Coverage – How to determine which portion of code is being tested in Visual Studio ?

How to customize color settings for Code Coverage Result in Visual Studio ?



You can refer and read this post for more internal details of this feature.

Hope this helps !

9 thoughts on “Write Unit Test Automatically using IntelliTest in Visual Studio 2015

  1. Pingback: Visual Studio 2015 New Debugging Features

  2. Pingback: Dew Drop – July 20, 2015 (#2057) | Morning Dew

  3. Clinton Billedeaux

    The ability to create automatic unit tests is nice, but not very useful for test driven development. Do you feel that this is a way to increase coverage after having written tests for a test driven project?

    Also, would you like help creating a better captcha module. I like what you’re trying, but if someone really wanted to spam you, it would not be very difficult.

  4. Pingback: 10 New features of Visual Studio 2015 that you should know | Abhijit's World of .NET

  5. Pingback: Visual Studio – Developer Top Ten for July 29th, 2015 - Dmitry Lyalin

  6. Pingback: .NET Tips and Tricks from Daily .NET Tips – ( Visual Studio 2015, Windows Universal App Development, Microsoft Band, Xamarin ) – July 2015 Links | Abhijit's World of .NET

  7. Pingback: Create IntelliTest in Visual Studio 2015 – another way of Start Writing Smart Unit Test

  8. Pingback: Step-By-Step working with Unit Test in Visual Studio 2015 | Abhijit's World of .NET

  9. Pingback: Visual Studio 2015: Worth the upgrade? | Ready to Rock Software Development

Comments are closed.