MSTest V2

In the (relatively) distant past, MSTest was often used by organizations because it was provided by Microsoft “in the box” with Visual Studio/.NET. Because of this, some organizations trusted MSTest over open source testing frameworks such as NUnit. This was at a time when the .NET open source ecosystem was not as advanced as it is today and before Microsoft began open sourcing some of their own products.

Nowadays MSTest is cross-platform and open source and is known as MSTest V2, and as the documentation states: “is a fully supported, open source and cross-platform implementation of the MSTest test framework with which to write tests targeting .NET Framework, .NET Core and ASP.NET Core on Windows, Linux, and Mac.”.

MSTest V2 provides typical assert functionality such as asserting on the values of: strings, numbers, collections, thrown exceptions, etc. Also like other testing frameworks, MSTest V2 allows the customization of the test execution lifecycle such as the running of additional setup code before each test executes. The framework also allows the creation of data driven tests (a single test method executing  multiple times with different input test data) and the ability to extend the framework with custom asserts and custom test attributes.

You can find out more about MSTest V2 at the GitHub repository, the documentation, or check out my Pluralsight course: Automated Testing with MSTest V2.

You can start watching with a Pluralsight free trial.

SHARE:

Comments (1) -

  • Meziantou

    5/22/2018 7:06:03 PM | Reply

    Hi,
    MSTest V2 is a great improvement compare to v1. It can now be used as a replacement for NUnit or xunit in most cases. However, NUnit has still some useful features such as ExplicitAttribute and other attributes to control how the tests are executed (for instance, STA or MTA). Also, it would be great if  MSTest were used for testing corefx and other Microsoft projects on GitHub. This would help adding new features to MSTest.

    BTW, I wrote a series of posts on the usage of MSTest V2 and how to extend it: www.meziantou.net/.../mstest-v2-setup-a-test-project-and-run-tests

Pingbacks and trackbacks (1)+

Add comment

Loading