[英]How do I create and run NUnit/WebDriver test-suites via Visual Studio?
I've recently moved from a Java-JUnit4-Webdriver environment to a C#-NUnit-Webdriver one. 我最近从Java-JUnit4-Webdriver环境转移到了C#-NUnit-Webdriver环境。
In Eclipse, I could create test-suites quickly by copying test classes into a test-suite class, and after minimal formatting, run them as JUnit tests. 在Eclipse中,我可以通过将测试类复制到测试套件类中来快速创建测试套件,然后以最小的格式将它们作为JUnit测试运行。 The JUnit test-suites used the pattern below: 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 {
}
Is there an equivalent way to conveniently generate NUnit test-suite classes and then execute them in Visual Studio? 是否有等效的方法可以方便地生成NUnit测试套件类,然后在Visual Studio中执行它们?
I've been reading the NUnit documentation but can find no obvious equivalent. 我一直在阅读NUnit文档,但找不到明显的等效内容。 I know that with the NUnit GUI you can select tests to run via check-boxes but this does not create a permanent test-suite. 我知道,使用NUnit GUI可以选择要通过复选框运行的测试,但这不会创建永久的测试套件。 And that suites can be created by adding attributes/categories etc to individual tests but this doesn't appear as flexible as the method above. 可以通过向各个测试中添加属性/类别等来创建套件,但这并不像上面的方法那样灵活。
You can use NUnit Suite functionality: 您可以使用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;
}
}
}
}
However, Suites are currently not displayed in the NUnit GUI. 但是,套件当前未显示在NUnit GUI中。
[Category]
attribute instead of Suite functionality. 您也可以考虑使用[Category]
属性而不是Suite功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.