11

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

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
gsgill76
  • 339
  • 1
  • 4
  • 14

3 Answers3

13

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
alltej
  • 6,787
  • 10
  • 46
  • 87
5

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

SalamiArmy
  • 413
  • 1
  • 5
  • 14
2

The tilda ~ means "contains", so if Foobar is the name of your class:

vstest.console bin\Debug\MyTests.dll /TestCaseFilter:FullyQualifiedName~Foobar

See https://msdn.microsoft.com/en-us/library/jj155800.aspx

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467