Disclaimer: I am a consultant at Amazon Web Services, and this is my personal blog. The opinions expressed here are solely mine and do not reflect the views of Amazon Web Services (AWS). Any statements made should not be considered official endorsements or statements by AWS.
I am just documenting all my research and learning that I did to build my concepts regarding the Unit Testing of a .NET Framework application in Visual Studio using various Test Frameworks. I would be glad if this learning will be useful for you as well.
Below are 3 main Unit Test frameworks for writing unit tests for any .NET Framework application.
By default, for .NET Framework
- Visual Studio provides a template for MS Test
only. If you want to use NUnit
or xUnit
Test Frameworks, then you have two options.
To run the tests written with MS Test requires no additional setup, you can run them from Visual Studio Test Explorer. But to run the unit tests written with NUnit and xUnit, you have to work a little extra, you just need to install their adapter.
Visual Studio Test Explorer runner can run tests from any unit test framework that has developed an adapter interface for it.
Refer to this link - How to choose between Extension and NuGet package?
xunit.runner.visualstudio
)Visual Studio Extensions are no longer supported for xUnit.
MSTest.exe - You can use the MSTest.exe program to run automated tests in a test assembly from a command line. This is a legacy tool.
VSTest.Console.exe - This is the latest offering from Microsoft to run automated unit and coded UI tests from a command line. VSTest.Console.exe is optimized in performance and can be used in place of MSTest.exe.