1
votes

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.

maven project structure

1
Are you using TestNG or JUnit?flo
As you wrote that you are using TestNG, it seems worth noticing that TestNG does not require the @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 Schaetz
thank you i have just tried without static but the result the same (nat
Did you check if the method actually gets called? You could also try to introduce a variable ZatsEnvironment env = new DefaultZatsEnvironment("./src/main/webapp/WEB-INF"); and then call the init on that variable instead (newClient then also, of course).Florian Schaetz
How do you run the test?flo

1 Answers

1
votes

So, this helped me to solve the problem for my reactor project.

            env = new DefaultZatsEnvironment("../ControlCenterPack/src/main/webapp/WEB-INF");
            env.init("../ControlCenterCore/src/main/resources/web");