Search code examples
batch-filejenkins-pipelinemstest

Execute multiple .dll with MSTest using batch (bat)


currently we are building up a Jenkins-Pipeline, while building it up we found out that we need a few bat-scripts. But now I don't know any further. We have a Folder with all our Unit-Tests (about 27 .dll's, in sum 1788 Tests).

Example Paths:

D:\Jenkins\Pipeline\trunk\Binaries\Unittests\SculiWebServiceTest.UnitTests\SculiWebServiceTests.dll
D:\Jenkins\Pipeline\trunk\Binaries\Unittests\ExternalServices.UnitTests\ExternalServicesTests.dll
D:\Jenkins\Pipeline\trunk\Binaries\Unittests\ServiceBus.IntegrationTests\ServiceBus.IntegrationTests.dll

And we want to execute all .dll and define a Quality-Gate (this means all Tests need to be passed), the following works:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" "/testcontainer:D:\Jenkins\Pipeline\trunk\Binaries\Unittests\SculiWebServiceTest.UnitTests\SculiWebServiceTests.dll"

But if you add more /testcontainer, we get an error "The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters."

Already read this post, but it didn't helped me "wildcard test containers to mstest. exe", anybody have a solution here?


Solution

  • We found out that this is a string-limitations issue, if you don't use the "", it will work.

    Example:

    "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcontainer:D:\Jenkins\Pipeline\trunk\Binaries\Unittests\SculiWebServiceTest.UnitTests\SculiWebServiceTests.dll /testcontainer:D:\Jenkins\Pipeline\trunk\Binaries\Unittests\ExternalServices.UnitTests\ExternalServicesTests.dll /testcontainer:D:\Jenkins\Pipeline\trunk\Binaries\Unittests\ServiceBus.IntegrationTests\ServiceBus.IntegrationTests.dll
    

    If you are using batch be careful that you don't use an enter between the different testcontainers.