I have following constructor in a public class:
public LoginPage(Browser browser, Logger logger) throws GeneralLeanFtException {
super(browser, logger);
}
browser
and logger
variables are defined in BasePage
class, which is extended by this class.
public class BasePage {
protected Browser browser;
protected Logger logger;
public BasePage(Browser browser,Logger logger) throws GeneralLeanFtException {
this.browser = browser;
this.logger = logger;
}
}
I get following error message when execute it with TestNG
.
either make it static or add a no-args constructor to your class
Error stack:
throws com.hp.lft.sdk.GeneralLeanFtException,java.lang.InterruptedException: either make it static or add a no-args constructor to your class at org.testng.internal.Utils.checkInstanceOrStatic(Utils.java:795) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:40) at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617) at org.testng.SuiteRunner.runTest(SuiteRunner.java:348) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305) at org.testng.SuiteRunner.run(SuiteRunner.java:254) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224) at org.testng.TestNG.runSuitesLocally(TestNG.java:1149) at org.testng.TestNG.run(TestNG.java:1057)
Class from test is executed:
@Test
public class LeanFTest {
public static void main(String[] args) throws IOException, SAXException, ParserConfigurationException {
TestNG testNG = new TestNG();
testNG.setTestSuites(Arrays.asList("testng.xml"));
testNG.setPreserveOrder(true);
testNG.run();
}
}