MSTest - unit testing framework in C#.netMicrosoft visual studio provides the unit testing project template. You can easily create unit testing project in visual studio. Namespace "Microsoft.VisualStudio.TestTools.UnitTesting" provides the classes, attributes and namespaces required for unit testing framework. Assert class provides methods for assertions. Some of the most popular methods from Assert class are AreEqual, AreSame, IsNull, IsTrue, IsFalse, IsNotNull, AreNotEqual etc You can run the tests from within studio or you can also run from command line as well Instead of using old msbuild, mstest commands, Micorosoft has introduced new CLI tools that work on all platforms like windows, mac, linux etc. You can find more info at https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x For example - if you want to build the solution, you can use below command
If you want to execute the tests, you can use below command
To filter the tests, you can use below command
You can also use logical & and | operators to filter the tests
dotnet test --filter TestCategory~sanity
If you are using MSTest, you can use FullyQualifiedName, Name, ClassName, Priority and TestCategory to filter the tests. If you are using NUnit, you can use FullyQualifiedName, DisplayName and Traits to filter the tests
dotnet test --filter "(Name~TestMethod1 | Name~TestMethod2)"
Complex problems, Simple Solutions