我正在编写一些 webdriver 测试来测试网站的功能,现在我需要让它们成为数据驱动的。我正在使用 junit 来执行它们。测试流程是:做登录,做test1,做注销。做登录,做test2,做注销等。
我需要的是像这样使两个类数据驱动(登录和测试类),获取第一次登录数据,对所有数据变化进行所有测试,获取第二次登录数据,对所有数据进行所有测试.. .等等
所以我有调用测试类的主类:
@RunWith(Suite.class)
@Suite.SuiteClasses({
Test1.class,
Test2.class,
Test3.class
})
public class MainTestSuite {
.. skipped.
测试类如下:
public class Test1 {
private static final Logger Log = LogManager.getLogger(Test1.class);
@Rule
public TestRules testRules = new TestRules();
@Test
public void testSomething() throws Exception { // test code
}
@Test
public void testSomethingElse() throws Exception { // test code
}
...跳过。
现在登录和注销由实现 TestWatcher 的 TestRules 调用:
public class TestRules extends TestWatcher {
@Override
protected void starting(Description description) {
// do login
}
@Override
protected void finished(Description description) {
// do logout
}
我一直在研究 easytest 模块 https://github.com/EaseTech/easytest-core ,但是将参数提供给登录测试,它首先循环遍历所有这些,这不是我需要的。您是否看到使用我已有的结构来解决我的问题。
最佳答案
关于java - junit 数据驱动测试指定何时提供新数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18655767/