Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Post-Build Event To Execute Unit Tests With MS Test in .NET 2.0+

I'm trying to setup a post-build event in .NET 3.5 that will run a suite of unit tests w/ MS test. I found this post that shows how to call a bat file using MbUnit but I'm wanting to see if anyone has done this type of thing w/ MS Test?

If so, I would be interested in a sample of what the bat file would look like

like image 313
Toran Billups Avatar asked Feb 03 '09 16:02

Toran Billups


People also ask

What is the prerequisite to unit testing C# with MSTest and .NET version?

Create the test project The test project requires other packages to create and run unit tests. dotnet new in the previous step added the MSTest SDK, the MSTest test framework, the MSTest runner, and coverlet for code coverage reporting. You can see the entire file in the samples repository on GitHub.

Does MSTest work with .NET core?

There are three different test frameworks which are supported by the unit test with asp.net core: MSTest, xUnit, and NUnit, which allow us to test our code in a consistent way.


1 Answers

We were using NUnit in the same style and decided to move to MSTest. When doing so, we just added the following to our Post-Build event of the applicable MSTest project:

CD $(TargetDir)
"$(DevEnvDir)MSTEST.exe" /testcontainer:$(TargetFileName)

The full set of MSTest command line options can be found at the applicable MSDN site.

like image 151
David Beckman Avatar answered Jan 04 '23 00:01

David Beckman