MSTest 2008 results file does not get refreshed when tests are executed in TeamCity 4.0

We run into a locking issue last week while setting up MSTest 2008 with TeamCity 4.0. We recommend using NUnit instead of MSTest, but MSTest 2008 is supported by TeamCity 4.0 and we did not anticipate any problems using it. The first build worked correctly as expected, but the second and all subsequent builds did not seem to execute any tests and did not overwrite MSTest results file created by the first build. All builds were displayed as successful and all included MSTest results from the first run!

I looked closer into the build logs and noticed the following entries:

  • "The results file 'C:\TeamCity\...\tests.trx' already exists. Please specify a different results file or verify the existing file is no longer needed and delete it."
  • "The command 'C:\...\mstest.exe' /testcontainer..." exited with code 1.

When I tried deleting the results file manually, I received the "Error Deleting File or Folder" exception. The file was locked by TeamCityAgentService-windows-x86-32.exe -> java.exe process.
 
To resolve this problem, we ended up naming our MSTest results file name as tests%env.BUILD_NUMBER%.trx. This way, each new build generates a brand-new results file. Note that this solution requires you to delete historical .trx files on a regular basis, which could be easily accomplished with a command line script.

Happy coding!

Welcome to ModelBlog

Thank you for visiting ModelBlog. We hope the time you spend with us will be both entertaining and worth your while. Have fun!

Authors

Search

Archive

Tags