JUnit Test Suite for Selenium 2

只谈情不闲聊 提交于 2019-12-24 08:26:02

问题


I have converted a Selenium Test Suite into JUnit from Selenium IDE, and trying to execute from eclipse. But there is an error in my script in

suite.addTestSuite(Open_Google_IE.class);
suite.addTestSuite(Open_Google_FireFox.class);

Error message: The method addTestSuite(Class) in the type TestSuite is not applicable for the arguments (Class).

Please advise what could be the reason. I have also verified Creating Test Suite in Webdriver and updated test suite but still throws that error.

JUnit TestSuite

import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses(value = {Open_Google_IE.class, Open_Google_FireFox.class})

public class OpenGoogle {

    public static Test suite() {
        TestSuite suite = new TestSuite();
        suite.addTestSuite(Open_Google_IE.class);
        suite.addTestSuite(Open_Google_FireFox.class);
        return suite;
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }
}

回答1:


As far as I can see, the code is OK.

addTestSuite() can only take classes that extend junit.framework.TestCase. Please make sure your classes extend that one, or find another way around...




回答2:


your class has to extend SeleniumTestBase

like this one :

public class CreateAccountTestCase extends SeleniumTestBase {


来源:https://stackoverflow.com/questions/9896057/junit-test-suite-for-selenium-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!