MSBUILD 针对匹配项目运行 NCover
我正在使用 MSBuild,并在项目名称上使用正则表达式获取所有测试项目,如下所示。
<RegexMatch Input="@(AllProjects)" Expression="(.)*Test(.)*">
<Output TaskParameter="Output" ItemName="UnitTestProjects"/>
</RegexMatch>
我现在想使用 @(UnitTestProjects) 并将它们全部传递给 NCover 以检查测试是否都提供 100% 的覆盖率。
要在单个项目上执行此操作,我会执行以下操作:
<Target Name="Coverage">
<NCover TestRunnerExe="C:\Program Files\NUnit 2.5.8\bin\net-2.0\nunit-console.exe"
TestRunnerArgs=""C:\SomeProject\bin\SomeProject.dll" "C:\SomeProject\bin\SomeProjectTest.dll""
WorkingDirectory="C:\SomeProject\bin\"
AppendTrendTo="coverage.trend"
OnlyAssembliesWithSource="True"
ProjectName="SomeProjectCoverage" />
</Target>
How do I effective use @(UnitTestProjects) in this NCover target?
I am using MSBuild and am getting all test projects using a regex on the project name, like this.
<RegexMatch Input="@(AllProjects)" Expression="(.)*Test(.)*">
<Output TaskParameter="Output" ItemName="UnitTestProjects"/>
</RegexMatch>
I now want to use @(UnitTestProjects) and pass them all to NCover to check that the tests are all giving 100% coverage.
To do this on a single project, I do something like this:
<Target Name="Coverage">
<NCover TestRunnerExe="C:\Program Files\NUnit 2.5.8\bin\net-2.0\nunit-console.exe"
TestRunnerArgs=""C:\SomeProject\bin\SomeProject.dll" "C:\SomeProject\bin\SomeProjectTest.dll""
WorkingDirectory="C:\SomeProject\bin\"
AppendTrendTo="coverage.trend"
OnlyAssembliesWithSource="True"
ProjectName="SomeProjectCoverage" />
</Target>
How do I effectively use @(UnitTestProjects) in the context of this NCover target?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了批处理您的 @(UnitTestProjects) ,您的 Target 必须像这样使用它:
更可靠的解决方案是提供 TaskItems 列表,保存有关您的(测试)项目的元数据。
您的问题表明您正在寻找一种自动化方法,该方法允许您添加新的测试项目,而无需维护任务项的配置列表。
由于提取 NCover 任务所需的所有信息非常困难,因此半自动化方法可能适合您。
您可以向您的测试项目添加一个导入,该导入将提供给您的全局测试项目 ItemGroup:
NCover 任务中的用法将与上面相同。
这样您的主构建脚本不需要了解任何特定的测试项目;它只是处理您的 ItemGroup“TestProject”。
For batching your
@(UnitTestProjects)
your Target will have to use it like this:A more reliable solution would be, to provide a list of TaskItems, holding metadata about your (Test)project.
Your question suggests that you are looking for an automated approach which will allow you to add new test projects without having to maintain a configuration list of TaskItems.
Since it would be quite difficult, to extract all the information needed to feed your NCover Task maybe a semi-automated approach might work for you.
You could add an import to your test project which will feed your global test project ItemGroup:
The usage in your NCover Task will be the same as above.
This way your master build script doesn't need to know about any specific test project; it just processes your ItemGroup "TestProject".