Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vstest.console.exe with ClassName as /testcasefilter

I am looking for executing the unit test by ClassName using vstes.console.exe, any help

I tried like

/TestCaseFilter:"ClassName=ProgressTests"

but that throws this error:

Error: No tests matched the filter because it contains one or more properties that are not valid (ClassName). Specify filter expression containing valid properties (TestCategory, Priority, FullyQualifiedName, Name) and try again.

Thanks

like image 309
gsgill76 Avatar asked Aug 23 '16 08:08

gsgill76


People also ask

What is Vstest console exe?

VSTest. Console.exe is the command-line tool to run tests. You can specify several options in any order on the command line. These options are listed in General command-line options.

Where is Vstest EXE?

Usually, vstest. console.exe. is located at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow, please check if it is in that directory. Can you run test successfully using Visual Studio locally on the private agent? In addition, please set the system.

What is the difference between MSTest and Vstest?

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.

How do I run MSTest from command line?

MSTest utility. To access the MSTest tool, add the Visual Studio install directory to the path or open the Visual Studio Group from the Start menu, and then open the Tools section to access the Visual Studio command prompt. Use the command MSTest from the command prompt.


2 Answers

You can run the tests by specifying the fully qualified class name:

vstest.console MyBusinessDomain.Tests.dll /testcasefilter:FullyQualifiedName~MyBusinessDomain.Tests.Shopping.Cart

where:

MyBusinessDomain.Tests.dll is the test dll

MyBusinessDomain.Tests.Shopping.Cart is the fully qualified class name

Or you can run the tests classes by namespace:

vstest.console MyBusinessDomain.Tests.dll /testcasefilter:FullyQualifiedName~MyBusinessDomain.Tests.Shopping

This command will run all the tests under MyBusinessDomain.Tests.Shopping namespace.

NOTE: FYI, vstest.console is newer than mstest and is preferred for running via the command line. It can be added to the environment path with this location(for VS2015) :

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
like image 130
alltej Avatar answered Oct 31 '22 00:10

alltej


According to https://blogs.msdn.microsoft.com/vikramagrawal/2012/07/23/running-selective-unit-tests-in-vs-2012-rc-using-testcasefilter/ - "ClassName is only valid for unit tests for Windows store apps, currently not available for classic MSTest" although that blog post is from years ago now though.

You could just use the FullyQualifiedName filter type as in /testcasefilter:FullyQualifiedName~NameSpace.Class

like image 32
SalamiArmy Avatar answered Oct 30 '22 23:10

SalamiArmy