5

Is there any difference between vstest.console.exe and dotnet test commands to run unit test from a terminal? Like when should you use one over the other. Is "vstest.console.exe" meant for only .Net framework and "dotnet test" for dotnet core projects? I can't find any specific answer that addresses this on google or in Microsoft's documentation.

The question in the below link comes close but the answer does not address the difference. I want to run my C# project in a build server with a script and was wondering which would be the best option to use.

testing in .net framework

cmoe
  • 141
  • 3
  • 12
  • A few experiments can show that both work, and that's why no need to have documentation on "what is not supported". – Lex Li Aug 16 '19 at 18:30
  • Are you saying either could be used irrespective of the frameworks? Be it .net core or .net framework? – cmoe Aug 16 '19 at 20:59

2 Answers2

2

I believe the vstest.console.exe used to run only MSTests at some point while dotnet test was designed to be more test framework agnostic and support other frameworks like NUnit and xUnit with potential to run them on different platforms (i.e. not only Windows as it was with vstest.console.exe).

According to the official documentation for dotnet vstest:

The dotnet-vstest command runs the VSTest.Console command-line application to run automated unit tests.

MS also added an important note on that page recently stating that:

The dotnet vstest command is superseded by dotnet test, which can now be used to run assemblies. See dotnet test.

So it seems like dotnet test is the way now :)

Sevenate
  • 6,221
  • 3
  • 49
  • 75
0

Yes, the doc https://learn.microsoft.com/pt-br/dotnet/core/testing/selective-unit-tests?pivots=mstest describes it.

Basically, using vstestconsole you need to use "--testcasefilter" instead of "--filter".

  • There is a difference between vstest and mstest - the former is a test runner and the later is a test framework. Both could be used independently. – Sevenate Nov 19 '20 at 02:00