简体   繁体   English

如何让TestDriven.net使用NCover生成有用的代码覆盖率XML文件?

[英]How do I get TestDriven.net to generate a useful code coverage XML file with NCover?

Steps to Repro: Repro的步骤:

  1. Make a C# project in VS 2010 Professional on Windows 7 Ultimate 32-bit edition. 在Windows 7 Ultimate 32位版本的VS 2010 Professional中创建一个C#项目。
  2. Write some unit tests with the VS C# Unit Test wizard 使用VS C#单元测试向导编写一些单元测试
  3. Download and install the latest RTM or Beta version of TestDriven.Net. 下载并安装最新的RTM或Beta版TestDriven.Net。
  4. Right-click on the testing project and select Test With NCover 右键单击测试项目,然后选择Test with NCover
  5. Wait 等待
  6. See that NCover's window is empty 看到NCover的窗口是空的

How do I get TestDriven.net to generate a useful code coverage XML file with NCover? 如何让TestDriven.net使用NCover生成有用的代码覆盖率XML文件?

So far, I've tried rebooting, uninstalling the RTM version and installing the Beta version, and running in Debug & Release modes. 到目前为止,我已尝试重新启动,卸载RTM版本并安装Beta版本,并在调试和发布模式下运行。

Update with Output window text: 使用输出窗口文本更新:

------ Test started: Assembly: TestProject1.dll ------

NCover v1.5.8 - Code Coverage Analysis for .NET - http://ncover.com

NCover.Console v1.5.8 - Code Coverage Analysis for .NET - http://ncover.org
Copyright (c) 2004-2006 Peter Waldschmidt


Command: C:\Program Files\TestDriven.NET 3\ProcessInvocation86.exe
Command Args: "/assemblyName:TestDriven.TestRunner.Server, Version=3.2.2770.0, Culture=neutral, PublicKeyToken=50ecb853f8c6b8d2" "/xmlName:M:TestDriven.TestRunner.Coverage.NCoverCoverageTestRunner.OutOfProc.Run(System.String,System.String,System.String,System.String,System.String)" "/parameter:tcp://127.0.0.1:64445/7dbdb535-3602-4a8e-8bbc-f8be7eb83987" "/parameter:tcp://127.0.0.1:64445/fbff4f73-2438-43e4-b1f9-2bdaeb9c0907" "/parameter:C:\Users\Zian\Documents\Visual Studio 2010\Projects\ClassLibrary1\TestProject1\bin\Debug\TestProject1.dll" "/parameter" "/parameter"
Working Directory: 
Assemblies: ClassLibrary1;ClassLibrary1_Accessor;TestProject1
Coverage Xml: C:\Users\Zian\AppData\Local\Temp\Mutant Design\TestDriven.NET 2.0\Coverage\ClassLibrary1\TestProject1.xml
Coverage Log: Coverage.Log

Waiting for profiled application to connect...Connected
Configuring Profiler...
******************* Program Output *******************
Unable to establish communications with the profiler. (0x2)

NCover couldn't create a coverage report.

(Assuming you are using NCover 1.5.8 which ship with TDD.Net) (假设您使用的是与TDD.Net一起提供的NCover 1.5.8)

I've done exactly what you described, and it works just fine... Here are some things to consider: 我完全按照你的描述做了,它的工作正常......以下是一些需要考虑的事项:

  1. Are you sure the actual xml file is empty? 你确定实际的xml文件是空的吗? Try to look for it here: C:\\Users\\USERNAME\\AppData\\Local\\Temp\\Mutant Design\\TestDriven.NET 2.0\\Coverage\\YOURPROJECT , or use something like Everything (great free search tool) to find YourTestProject.xml . 尝试在这里查找: C:\\Users\\USERNAME\\AppData\\Local\\Temp\\Mutant Design\\TestDriven.NET 2.0\\Coverage\\YOURPROJECT ,或使用像Everything (伟大的免费搜索工具)之类的东西来查找YourTestProject.xml Perhaps there is a problem with the NCover GUI. 也许NCover GUI存在问题。
  2. There have been some problems with MSTest & NCover integration prior to 1.5.8. 在1.5.8之前,MSTest和NCover集成存在一些问题。 Try to reproduce this with NUnit and see what happens (Actually IMHO, I don't see any advantage for MSTest over NUnit anyway). 尝试用NUnit重现这个并看看会发生什么(实际上恕我直言,我认为MSTest在NUnit上没有任何优势)。
  3. Are you running any other profiler in addition to NCover? 除了NCover之外,您还在运行任何其他分析器吗? Is so, try to disable them. 是这样,尝试禁用它们。

EDIT: Try to follow the steps in this article . 编辑:尝试按照本文中的步骤操作。 There's a section called "NCover With TestDriven.NET". 有一个名为“NCover With TestDriven.NET”的部分。
It seems as NCover's profiler is not registered properly, so mainly what you have to do is remove it manually completely (TDD.Net probably doesn't do it for you), and only then reinstall it. 看起来NCover的探查器没有正确注册,所以主要是你需要做的就是完全手动删除(TDD.Net可能不会为你做),然后才重新安装它。

  1. Uninstall the Beta version of TestDriven.net 卸载TestDriven.net的Beta版本
  2. Install the RTM version of TestDriven.net 安装TestDriven.net的RTM版本

The 2 steps work because NCover's profiler is not registered properly, as described by KiwiDude . 这两个步骤有效,因为NCover的分析器未正确注册, 如KiwiDude所述

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

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