2

I am trying to easily display unit test results and code coverage reports from Visual Studio 2012 into the CruiseControl.NET Build Reports. The pieces are the following:

  • MSBuild - to build the project
  • vstest.console.exe - to execute visual studio unit tests and code coverage tools via the command line
  • custom console application to convert coverage report to XML

My problem is how can I control the output name for the vstest.console.exe. I am not finding anyway to control this. My only solution at this point is to write some custom script to find the coverage file and TRX file and rename to a known value. Then the cruise control tool can find the files properly.

Any help would be appreciated. Thanks,

Steve Ankeny
  • 335
  • 5
  • 18

2 Answers2

1

The command line looks very limiting:

http://msdn.microsoft.com/en-us/library/vstudio/jj155796.aspx

"The TRX logger doesn't support any parameters (unlike the TFS publisher logger)."

From:

Specifying results filename for vstest.console.exe

Here is a general tip.

One way to think of CC.NET is like this: It's a big, fancy "Msbuild.Exe" executor.

So if you can write up your logic in msbuild (.proj) file, you can get CC.NET to call it.

1.  CC.NET calls a source-control retrieve task.
2.  In that retrieve, there is a .proj file.
3.  You get CC.NET to call "msbuild.exe MySolutionBuild.proj"
4.  Have the .proj file run Unit-Tests, create xml, create artifacts (.zip(s) or .msi(s), etc)
5.  After the build, have CC.NET pull in the results (usually xml with File-Merge) and have CC.NET send out emails (publishers).

If you do it this way, if you ever go to TFS (or Jenkins or other), you'll minimize the transition effort.

If you rely very heavily on CC.NET proprietary commands, you can get it to work, but its harder to maintain IMHO.

Community
  • 1
  • 1
granadaCoder
  • 26,328
  • 10
  • 113
  • 146
  • 1
    I've extended MSBuild before to do all sorts of fun things. It is powerful and nice to be able to extend it. I may end up doing some of that. For now, I am doing the following: 1. call a cleanup batch file to remove coverage/test reports 2. executing the build using MSBuild 3. calling the tool to do unit test and coverage 4. calling a custom tool to find and rename the coverage/test reports 5. calling a custom tool to generate the coverage report to XML 6. using ReportGenerator (from codeplex) to take XML and make it HTML – Steve Ankeny Oct 23 '13 at 18:39
  • So my latest approach is fairly similar to yours. I just need to try and package it so that it's movable to other systems (as you stated). – Steve Ankeny Oct 23 '13 at 18:40
0

Take a look at this post http://rubenwillems.blogspot.be/2011/09/setting-up-ccnet-in-combination-with.html

It shows the step needed. Look at step 4 and step 5 there, these cover unit testing and coverage.

Williams
  • 741
  • 1
  • 4
  • 11
  • That is for Visual Studio 2010. In Visual Studio 2012, they have vstest.console.exe. This does NOT allow you to specify the results file. That is what I am trying to make sure that I am not missing something with this new tool. – Steve Ankeny Oct 23 '13 at 12:37
  • It's a great article for VS2010 though :-P – Steve Ankeny Oct 23 '13 at 12:38
  • I overlooked the version, sorry for that. For the moment I do not have VS2012 at hand, but the docs at msdn say that the export still exists. http://msdn.microsoft.com/en-us/library/ms182489%28v=vs.110%29.aspx /resultsfile:testResults.trx – Williams Oct 23 '13 at 13:12
  • This site seems to show a way to save to a file with /settings arguments, it's at about in the middle of the page http://blogs.msdn.com/b/bhuvaneshwari/archive/2012/06/16/vstest-console-exe-commandline-test-runner.aspx – Williams Oct 23 '13 at 13:20
  • I am not sure that I can use MSTest.exe to do the unit test results. The code base that I am working with is C++ and it must be 64-bit as well. MSTest complains to me about not being able to load 64-bit test code. I believe vstest.console.exe was written as part of 2012 to replace MSTest. The settings file I can only find how to set the results directory name not the file names. – Steve Ankeny Oct 23 '13 at 13:52
  • I should have mentioned that in the original question :(. – Steve Ankeny Oct 23 '13 at 13:58