Search code examples
.netmstest

Unit Test multi target frameworks: Test all frameworks


I create a MS Test Unit test project with these targets

<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>

If I use this code in one my tests:

#if NET472
            Assert.Fail();
#endif

and then run the test, it will be successful. It means the tests are executed with netcoreapp target framework.

I want to do tests in both frameworks. How can I do that with a SINGLE test project?


Solution

  • I found that if using command line dotnet test it will run tests for each framework separately.