Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MSTest Framework for testing applications targeting .NET Standard 1.6 and higher

I'm migrating my project from .NETFramework 4.5.1 to .NET Standard 1.6

The project is using MSTest framework, and I would like to keep it that way for now and avoid rewriting tests in another framework (XUnit, NUnit or the like)

Currently, MSTest framework support was announced for .NET Core only, and, quite naturally the dotnet-test-mstest 1.1.2-preview package available on NuGet does not support .NET Standard, so I cannot have my test projects target .NET Standard

However, according to compatibility matrix, .NET Standard 1.6 is compatible with .NET Core 1.0.
So I have my test assemblies targeting .NET Core 1.0 and referencing my system-under-test assemblies that target .NET Standard 1.6 - and it works just fine.

The question is - is this a good decision going forward?

I have not found any road map for MSTest, and I'm wondering whether this trick will still work when I migrate to .NET Standard 2.0 ?
Should I change my test framework to something else, that has more up to date support, for example XUnit?

Even Microsoft documentation points to XUnit, are they abandoning MSTest?

Please note that this is not a duplicate, since my question is about the perspective for the future, not only current state of affairs.

like image 743
ironstone13 Avatar asked Jan 19 '17 18:01

ironstone13


1 Answers

>> The project is using MSTest framework, and I would like to keep it that way for now and avoid rewriting tests in another framework (XUnit, NUnit or te like)

Sounds reasonable.

>> I cannot have my test projects target .NET Standard

You can.

Please see this post for reference: https://blogs.msdn.microsoft.com/visualstudioalm/2016/11/29/evolving-the-test-platform-part-3-net-core-convergence-and-cross-plat/ Do note that you no longer need the dotnet-test-mstest package. Use MSTest.TestAdapter instead.

>> Even Microsoft documentation points to XUnit

In this case, yes. But then there are other projects that use MSTest heavily as well.

We work on both the MSTest test framework and the VS Test platform. As a Test Platform, we take a pluralistic approach and would like to leave the choice of test framework to the developer (as opposed to taking sides in favour of any one framework). You can read more about this approach here: https://blogs.msdn.microsoft.com/visualstudioalm/2016/07/25/evolving-the-visual-studio-test-platform-part-1/.

>> are they abandoning MSTest?

Not at all.

Please see here: https://blogs.msdn.microsoft.com/bharry/2017/01/20/open-sourcing-the-vs-test-platform/, and here: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/13399980-make-ms-test-framework-opensouce to get a glimpse of the road ahead. We will announce more – specifically in terms of a roadmap – soon.

>> The question is - is this a good decision going forward?

Yes (based on all of the above).

like image 110
pvlakshm Avatar answered Nov 24 '22 15:11

pvlakshm