如何将单元测试作为构建的一部分运行(不是持续集成)
我有 Nunit 单元测试,我需要将其作为 MS 构建的一部分运行。我知道运行所有测试会减慢构建速度,所以,我只需要运行受影响的测试,有什么办法可以找出答案。 。
I have Nunit unit test which i need to run as the part of my MS build.. I know that running all the test will slow up the build So, i need to run only the impacted test is there any way to find that out..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,对于 NUnit 测试来说,仅运行受影响的测试是不可能的。但这对于 Visual Studio 2010 Ultimate/Test Professional 中的 MSTest 是可能的:
推荐运行测试受代码更改影响的
无论如何,您可以使用 MSBuild Community NUnit Task 从一组程序集运行测试。您可以通过指定
DependsOnTargets
属性将其作为标准AfterBuild
目标的依赖目标来执行此操作。AFAIK running only impacted tests is not possible yet for NUnit tests. But this is possible for MSTests in Visual Studio 2010 Ultimate/Test Professional:
Recommending Tests to Run That are Affected by Code Changes
Anyway you can use MSBuild Community NUnit Task to run tests from a set of the assemblies. You can do this as dependency target of standard
AfterBuild
target by specifyingDependsOnTargets
attribute.要了解受影响的测试,您需要跟踪测试用例代码覆盖率。只有这样,您才能检查哪些测试受到您所签入的更改的影响。除了 Microsoft 的 Team Foundation Server 之外,我不知道还有什么工具可以满足您的要求。
To know the impacted tests you need to track the test case code coverage. Only this way you can examine what test is impacted by the changes you are checking in. I don't know of any tool that does what you want besides Microsofts Team Foundation Server.
可以通过项目的“构建事件”属性来运行测试作为构建的一部分。您可以执行 NUnit 的命令行工具。
但正如 PVitt 已经指出的那样,我不知道 NUnit 是否可以与测试影响分析一起使用。
Running your tests as a part of the build can be done trough the Build Events properties of your project. You can execute the command line tool for NUnit.
But as PVitt already pointed out, I don't know if NUnit can work with Test Impact analysis.