vstest.console

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


Solution

  • 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