SWTBot - 为什么不能使用JUnit4TestAdapter运行同一个类?

时间:2015-05-11 10:22:00

标签: java eclipse junit4 swtbot

我使用SWTBot在我的环境中运行自动化。 我在每个套件中创建了2个套件和2个测试用例 - 问题是我对两个套件使用了相同的测试用例。

TestSuite suite = new TestSuite("Test Suite 1");
suite.addTest(new JUnit4TestAdapter(Test1.class));
suite.addTest(new JUnit4TestAdapter(Test2.class));

TestSuite suite = new TestSuite("Test Suite 2");
suite.addTest(new JUnit4TestAdapter(Test1.class));
suite.addTest(new JUnit4TestAdapter(Test2.class));

当我运行SWTBot时,它只运行一个套件两次..请在此处查看我的代码:

AllTestSuites.java - 构建所有套件的主类

@RunWith(Suite.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@SuiteClasses({
    SuiteOneAllTests.class, 
    SuiteTwoAllTests.class })
....//Code..

SuiteOneAllTests.java

public class SuiteOneAllTests extends TestSuite {

    /**
     * Function for running all test cases
     * @return suite (All test cases)
     * @throws Exception 
     */
    public static Test suite() throws Exception {
    TestSuite suite = new TestSuite("Test Suite 1");

        suite.addTest(new JUnit4TestAdapter(Test1.class));
        suite.addTest(new JUnit4TestAdapter(Test2.class));

        return suite;
    }
}

SuiteTwoAllTests.java

public class SuiteTwoAllTestsextends TestSuite {

    /**
     * Function for running all test cases
     * @return suite (All test cases)
     * @throws Exception 
     */
    public static Test suite() throws Exception {
    TestSuite suite = new TestSuite("Test Suite 1");

        suite.addTest(new JUnit4TestAdapter(Test1.class));
        suite.addTest(new JUnit4TestAdapter(Test2.class));

        return suite;
    }
}

以下是结果: http://i.stack.imgur.com/KPgHY.jpg

0 个答案:

没有答案