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
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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With