3

I have a set of unit tests in a C# project in Visual Studio 2013. Is there a way to generate a report from the unit test results?

I need a report as evidence of time when the tests were run and for the results. I dont mean an online CI server report, I just mean a local file report. Are there any nice plugings for VS2013?

I looked into the NUnit plugin with its XML output but its not very accurate, a lot of the data displayed was duplicated and inaccurate (for example my OS type). I'm currently sticking with the Visual Studio MSTest testing framework for now.

Spirit
  • 150
  • 1
  • 10
  • 1
    As tests would be run on each developers machine, you would want to look at a way of running these reports centrally. Build and use a CI (Continuous Integration) server and generate your report when a build is triggered. – Adrian Thompson Phillips Mar 03 '15 at 10:14
  • That sounds like a great system design and I will look into that, thank you. However its the "Generating Reports" phase that has blocked me. I dont see any features available to generate any formal report within Visual Studio 2013, or any external tools (apart from Nunit) but im not a huge fan. I thought reporting would be a necessity – Spirit Mar 03 '15 at 10:29
  • 1
    If you search for your chosen CI server and 'unit test report' or 'code coverage report' you should unearth all the information you need. I.e. if you have licences available, TFS may be the obvious choice, or you could maybe look at other CI servers like TeamCity or CruiseControl. – Adrian Thompson Phillips Mar 03 '15 at 10:51

2 Answers2

4

I would suggest using vstest.console.exe from the command line to generate the results as follows:

vstest.console.exe YourTestProject.dll /Logger:trx

The results will be saved in the following format: “username_PCName YYYY-MM-DD HH_MM_SS.trx” Then navigate to the folder where your results have been output and use trx2html (this is the version that works with VS2012+) to convert the results into an html report!

trx2html.exe “username_PCName YYYY-MM-DD HH_MM_SS.trx”

I know you said you wanted a plug in, but maybe this will suit your purposes!

blueberryredbull
  • 219
  • 1
  • 11
  • where can I get the trx2html.exe? I download the zip file from vwww.codeplex.com/trx2html. But it has 4 folder and more subfolders. Do you know where is the trx2html.exe located? Thanks – user3174886 Apr 11 '18 at 00:54
2

What your probably best doing is setting up Continous Integration and Continuous Delivery.

For example we have have setup the following process in our company:

Jenkins(To manage the process) SVN TRIGGER -> MSBUILD -> UNIT TESTS(Nunit) -> SONAR -> DEPLOYMENT(MSDEPLOY) -> SMOKE TESTS(has deployment succeeded?) -> ROLLBACK(MSDEPLOY) -> SELENIUM TESTS

In the process we have code adherence and a build breaker to stop if any unit tests are not working, basically if any of that fails you cant deploy. The idea is that it's fool proof. Also the delivery pipeline visualisation tools are pretty cool.

You can pull XML reports from Nunit on the command line into Sonar, I had a few issues with it myself, but you need to rebuild before checking against the tests and run the tests against the dll file itself.

Hopefully that will be of some help.

Netferret
  • 604
  • 4
  • 15
  • Thank you, it is of use, but i'm seeking a plugin that will output the unit test results from visual studio into an XML or word doc. as I need to generate a report locally, not so much cornered with CI servers, its not what I need. But thanks for the info. – Spirit Mar 03 '15 at 17:31
  • Fair enough, its not for everyone, I would have put as a comment, but I didnt have enough points at the time. – Netferret Mar 04 '15 at 10:02