我最近从Java-JUnit4-Webdriver环境转移到了C#-NUnit-Webdriver环境。
在Eclipse中,我可以通过将测试类复制到测试套件类中来快速创建测试套件,并且在最小格式化之后,将它们作为JUnit测试运行。 JUnit测试套件使用了以下模式:
package com.example.testsuites;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import com.example.TestBase;
import com.example.Test1;
import com.example.Test2;
import com.example.Test3;
import com.example.Test12;
import com.example.Test303;
@RunWith(Suite.class)
@SuiteClasses({Test1.class,
Test2.class,
Test3.class,
Test12.class,
Test303.class,
})
public class ExampleTestSuite extends TestBase {
}
是否有相同的方法可以方便地生成NUnit测试套件类,然后在Visual Studio中执行它们?
我一直在阅读NUnit文档,但没有发现明显的等价物。我知道使用NUnit GUI,您可以选择通过复选框运行的测试,但这不会创建永久的测试套件。并且可以通过向各个测试添加属性/类别等来创建套件,但这似乎不像上面的方法那样灵活。
答案 0 :(得分:1)
您可以使用NUnit Suite功能:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
private class AllTests
{
[Suite]
public static IEnumerable Suite
{
get
{
ArrayList suite = new ArrayList();
suite.Add(typeof(OneTestCase));
suite.Add(typeof(AssemblyTests));
suite.Add(typeof(NoNamespaceTestFixture));
return suite;
}
}
}
}
但是,套件当前未显示在NUnit GUI中。
[Category]
属性代替
套件功能。