This section will help you to integrate MSTest (.Net unit test framework) tool on your local instance.
Prerequisites
- MSBuild version should be 15 or 16 depending on the type of source code that needs to be scanned.
- MSTest (does not require Visual Studio) can be separately downloaded as Test Agent Module.
Assumption
- MSTest/MSBuild should run in the client environment’s existing setup.
For more information about the execution of MSTest, refer to this article.
Limitations
- MSTest exe takes only a DLL executable; hence, the path of the executable is very specific to the arguments provided.
Troubleshooting
- In spite of having Visual Studio setup, if MSTest.exe is not present on your Jenkins machine, make sure you update the installation because you may have installed minimal components and not the full IDE. Also, sometimes the test components are explicitly loaded on drives, other than C drive.
- If Embold analysis succeeds only with an “INITIALIZING GAMMASCANNER” success message and git exceptions for fetching the repository, the JSON given for the scan config is invalid.
- MSTest module logs are generated inside
workspace/projectName/gamma_logs/{repositoryUID}/ext_mstest.log
Building C# projects in Jenkins:
While building the project from Jenkins, the following errors may occur:
MSBUILD : error MSB1009: Project file does not exist
MSBUILD : error MSB1008: Project file does not exist
Solutions
%WORKSPACE%
value has space in it ( C:/Program Files(x86/Jenkins/jobs/MSTest-Examples.Tests-Build/workspace)
), hence, it can break it into 2 arguments.
In this case, you need to move your Job’s workspace to a location that won’t have spaces in it. You can do in either of the following ways:
- Relocate your whole Jenkins’ installation out of “Program Files“,
- Or, Use custom workspace (click on the Advanced… button on the project configuration page, under Advanced Project Options)
Note: Make sure to replace
%WORKSPACE%
in MSBuildConfig build step with Custom Workspace value set in the above step.