简体   繁体   English

如何确定在构建服务器中构建时要运行或忽略的nunit测试

[英]How to determine which nunit tests to run or ignore while building in build server

I want to specify a subset of my test to run while a project builds in build server an so its integrated tests run. 我想指定要在构建服务器中构建项目时运行的测试子集,以便其集成测试运行。

I've found a solution for MSTest tests here: Ignore test categories in TFS build server using DefaultTemplate.xaml 我在这里找到了MSTest测试的解决方案: 使用DefaultTemplate.xaml忽略TFS构建服务器中的测试类别

but it doesn't work for Nunit. 但对Nunit无效。

I've found Category attribute for Nunit but setting this in the build template doesn't work: 我已经找到Nunit的Category属性,但是在构建模板中设置此属性无效:

Category=IntegrationTest

while I marked my tests like: 当我将测试标记为:

[Category("IntegrationTest")]
[TestFixture]
public MyTestClass ...

You can create custom category (inherit Category class) then in your build script you can ignore this category 您可以创建自定义类别(继承类别类),然后在构建脚本中可以忽略此类别

This is a example for psake + mstest but it could be easily applied to NUnit and whatever build system are you using 这是psake + mstest的示例,但可以轻松地应用于NUnit和您使用的任何构建系统

http://log.ld.si/post/longrunningtests-as-a-separate-psake-task http://log.ld.si/post/longrunningtests-as-a-separate-psake-task

Why do you have them in the same project? 为什么将它们放在同一个项目中? I would recommend separating the integration tests to a separate assembly. 我建议将集成测试分离到单独的程序集中。 Since they are different "things" they "should" be separated! 由于它们是不同的“事物”,因此它们“应该”分开!

We have had the same problems and i came up with this Solution. 我们遇到了同样的问题,我想出了这个解决方案。 Place your UnitTests in one (or more) Projects and your IntegrationTests in another Project (or more than one). 将您的UnitTests放置在一个(或多个)项目中,将IntegrationTests放置在另一个(或多个)项目中。 The clue is to identify that its UnitTest or IntegrationTest by the project name. 提示是通过项目名称来标识其UnitTest或IntegrationTest。 For example we named all our UnitTest Projects "UnitTest" besides other specific description. 例如,除了其他特定描述外,我们将所有UnitTest项目命名为“ UnitTest”。

Then in your builddefinition you can describe the filter which dlls the buildserver should use to load unittests and only load dlls which contain of UnitTest in the filename. 然后,在您的builddefinition中,您可以描述过滤器,即buildserver应该使用哪些dll来加载单元测试,并且仅加载文件名中包含UnitTest的dll。

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

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