i'm writing my first zats-test and i'm trying to do it according to the example at zkoss.
This is my test:
public class zatsTest {
@BeforeClass
public static void init() {
Zats.init("./src/main/resources/web");
}
@AfterClass
public static void end() {
Zats.end();
}
@AfterMethod
public void after() {
Zats.cleanup();
}
@Test
public void testLoginGUI() {
log.info("Testing Login GUI ...");
DesktopAgent deskAgent = Zats.newClient().connect("/login.zul");//<---
ComponentAgent button = deskAgent.query("loginButton");
ComponentAgent tbLogin = deskAgent.query("#login");
ComponentAgent tbPassword = deskAgent.query("#password");
// Successful login
log.info("Testing correct login and password...");
tbLogin.type("root");
tbPassword.type("nysnys");
Assert.assertEquals(deskAgent.query("#login"), "root", "correct login must be 'root' ");
Assert.assertEquals(deskAgent.query("#password"), "password", "correct password must be 'nysnys' ");
button.click();
log.info("Testing Login GUI has been finished.");
}
}
I've recieved this:
org.zkoss.zats.ZatsException: instance not found, please call init first at org.zkoss.zats.mimic.Zats.getInstance(Zats.java:33) at org.zkoss.zats.mimic.Zats.newClient(Zats.java:61) at zats_test.zatsTest.testLoginGUI2(zatsTest.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) at org.testng.internal.Invoker.invokeMethod(Invoker.java:639) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:821) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108) at org.testng.TestRunner.privateRun(TestRunner.java:773) at org.testng.TestRunner.run(TestRunner.java:623) at org.testng.SuiteRunner.runTest(SuiteRunner.java:357) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310) at org.testng.SuiteRunner.run(SuiteRunner.java:259) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185) at org.testng.TestNG.runSuitesLocally(TestNG.java:1110) at org.testng.TestNG.run(TestNG.java:1018) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
For my internship I have to understand how ZATS work and make a test for Login zk Gui (ZK 8.0 and zats-mimic-ext7 version 1.2.0, Maven project). But I'm a bit puzzled. I use TestNG.
@BeforeClass
method to be static - only JUnit does that. I haven't used TestNG myself yet, but it could be worth a try to make it non-static or put a logging (or breakpoint) there to see if it's actually called. Otherwise the code seems functional and pretty much how the ZATS class is supposed to be used. – Florian SchaetzZatsEnvironment env = new DefaultZatsEnvironment("./src/main/webapp/WEB-INF");
and then call the init on that variable instead (newClient then also, of course). – Florian Schaetz