IntelliTest simplifies writing and maintaining unit tests
Writing a suite of unit tests that exhaustively exercise and validate the logic of the code is not easy. It can even be considered too expensive to do at all. Fortunately, IntelliTest addresses both concerns: it helps you achieve high code coverage at a fraction of the cost, and now in Preview, this Enterprise feature supports projects that target .NET6 and will run on x64.
When you run on your .NET code, it generates test cases by dynamically analyzing the code. For every statement in the code, it crafts an input that will reach that statement, doing a case analysis for every conditional branch—if statements, assertions, and all operations that can throw exceptions—much like white box testing. The goal is to generate a test suite covering all branches of your code, and so every time it crafts an input that increases coverage, it emits that concrete value as a test case using C# and MSTest (xUnit and NUnit to come) as the test framework. The result is a compact suite of tests with high coverage that you didn’t have to write from scratch.
This updated version of IntelliTest is powered by the latest version of the and it generates a varied set of inputs (scoped to those that improve code coverage) that are then plugged into what we call parameterized unit tests for each of your methods. When you Generate Tests, you can select which tests you’d like to preserve into a test project that can serve as your regression suite. As your code is updated, you can rerun IntelliTest to keep the generated tests in sync with your code.
Previous implementations of this Enterprise Edition feature only supported code targeting .NET Framework and did not support x64 configuration. This updated version includes the following:
- Add IntelliTest support for .NET Core/Standard – Developer Community (visualstudio.com)
- Add IntelliTest support for x64 – Developer Community (visualstudio.com)
Give it a try on your projects today by enabling the feature through Tools > Manage Preview Features and selecting IntelliTest support for NetFx and Net6 using Z3 v4 (requires restart).
Then in your code, right click within a method and select IntelliTest (Preview) and either Create Project to create a project where your tests can be saved or Generate Tests to generate a set of tests to review and decide which ones to keep.
Whether you are evolving existing/legacy code and try out IntelliTest to generate a safety net of test before beginning refactoring or exploring existing/new code and use IntelliTest to understand the input/output behavior of the code against various data values, try the updated IntelliTest today!