简体   繁体   English

在Visual Studio 2013中生成单元测试报告

[英]Generating Unit Test Reports in Visual Studio 2013

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? 我在Visual Studio 2013中的C#项目中有一组单元测试。有没有办法从单元测试结果生成报告?

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. 我不是指在线CI服务器报告,我只是指本地文件报告。 Are there any nice plugings for VS2013? 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). 我用它的XML输出查看了NUnit插件,但它不是很准确,显示的很多数据都是重复和不准确的(例如我的操作系统类型)。 I'm currently sticking with the Visual Studio MSTest testing framework for now. 我目前正在坚持使用Visual Studio MSTest测试框架。

I would suggest using vstest.console.exe from the command line to generate the results as follows: 我建议vstest.console.exe使用vstest.console.exe来生成如下结果:

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! 结果将以下列格式保存:“username_PCName YYYY-MM-DD HH_MM_SS.trx”然后导航到输出结果的文件夹,并使用trx2html (这是与VS2012 +一起使用的版本)将结果转换为一个HTML报告!

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! 我知道你说你想要一个插件,但也许这适合你的目的!

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 Jenkins(管理流程)SVN TRIGGER - > MSBUILD - > UNIT TESTS(Nunit) - > SONAR - > DEPLOYMENT(MSDEPLOY) - > SMOKE TESTS(部署成功了吗?) - > 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. 您可以在命令行上将Nunit的XML报告提取到Sonar中,我自己也遇到了一些问题,但是在检查测试并针对dll文件本身运行测试之前需要重建。

Hopefully that will be of some help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM