I am currently trying to set up a CI pipeline for one of our softwares using Jenkins. I'm at the step where I need to run each separate test file with MsTest. From what I've read, unlike NUnit or other popular test frameworks, MsTest does not let you run all tests from the solutions folder. I have to recursively check every folder in the solution folder and manually run every test container in a ForEach-Object loop. At the moment, the first few test suites run perfectly and print out the log. However, about midway through the testing phase, some weird characters appear in the Jenkins log, and it seems to cause the tests to fail.
I have looked online and in most similar cases, people who ran into this issue had an older version of a plugin, which is not my case. We are using Jenkins 2.15 and PowerShell 4.0. Here's the code from the testing stage.
stage ('Unit tests') {
steps {
script {
powershell("""
Get-ChildItem -Path .\\*\\bin\\*Tests.dll -Recurse |
ForEach-Object {
\$obj = \$_;
& \"${tool 'MsTest'}\" /category:.\"ExpectedState|CurrentState|Uncategorized\" /testcontainer:\"\$obj\";
}
""")
}
}
}
Here's part of the output from the Jenkins Log
Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0 Copyright (c) Microsoft Corporation. All rights reserved.
Loading D:\jenkins-workspace\workspace\MultiBranch_Pipeline\Acceptance.Tests\bin\Release\Acceptance.Tests.dll... Starting execution...
Summary
Test Run Inconclusive.
Inconclusive 7
Total 7
Results file: D:\jenkins->workspace\workspace\MultiBranch_Pipeline\TestResults\JenkinsAdmin 2019-04-02 13_47_54.trx
Test Settings: Default Test Settings
Then eventually later in the ForEach loop
Starting execution... No tests to execute.
powershell.exe : 
At D:\jenkins-workspace\workspace\MultiBranch_Pipeline\durable-5fe1\powershellWrapper.ps1:3 char:1 + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "& 'D:\ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:String) [], RemoteException
- FullyQualifiedErrorId : NativeCommandError
These weird characters seem to spawn pretty randomly and I'm not sure exactly what makes them appear. Is this a problem on my end or rather with one of the plugins ?
Sorry if this has been asked before, I could not find a solution in the cases I have seen online. Thanks for taking the time to read.
late to my own party but I finally fixed it with this answer on SO.
I had overlooked this answer because I thought my problem was elsewhere but this is really what I wanted.
How set encodings in Jenkins to UTF-8
EDIT :
According to this answer: JVM property -Dfile.encoding=UTF8 or UTF-8?
You have to add this JVM setting to your Jenkins starting script (JAVA_TOOLS_OPTIONS):
-Dfile.encoding=UTF8