1

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());
    }
}
Community
  • 1
  • 1
Abdul Hameed
  • 1,135
  • 1
  • 13
  • 24

2 Answers2

2

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...

Petr Janeček
  • 37,768
  • 12
  • 121
  • 145
  • Sorry, I am new to Selenium / JUnit. Can you please let me know how to extend junit.framework.TestCase? Do you mean to import them? import junit.framework.TestSuite; Also if selenium test case is in JUnit WebDriverBacked then TestSuite work, but if test case is JUnit WebDriver then addTestSuite throws error. Please advise. – Abdul Hameed Mar 28 '12 at 19:57
  • That means that in `Open_Google_IE.java` file, you need to state `public class Open_Google_IE extends TestCase` and also import it there. But all this is kinda against the JUnit philosophy, because it would do the most if this work for you... But I still think this would work :) – Petr Janeček Mar 29 '12 at 09:10
  • 1
    After included that, it is not throwing error in Test Suite (in addTestSuite(testClass) step). But test case (Open_Google_IE class) is failing to execute. However I have verified in and modified as addTest(new TestSuite(testClass)); then it worked. Thanks. – Abdul Hameed Mar 29 '12 at 19:04
1

your class has to extend SeleniumTestBase

like this one :

public class CreateAccountTestCase extends SeleniumTestBase {
Blachshma
  • 17,097
  • 4
  • 58
  • 72
leandro
  • 11
  • 1