ZTL

From Documentation
Revision as of 11:05, 22 March 2011 by Tomyeh (talk | contribs)

ZTL is an automatic testing tool based on jUnit and Selenium. It is supported officially by ZK team. Here is a short introduction. For more information, please refer to ZTL Documentation.

The ZTL language is XML based which describes the operation of a test case for the Selenium Remote Control (RC). For example,

<test tags="button">
    <case id="Click">
        <server><!--
            <zk>
                <button id="btn" label="Click Me to Show a Message" onClick='alert("Hello!")'/>
            </zk>
        --></server>
        <client>
             click(btn);
             waitResponse();
             verifyTrue(jq("@window").exists());
        </client>
    </case>
</test>

The root tag of the ZTL file is test and encloses one or many test case(s) (similar to each method of the jUnit test case). The case can enclose one or many server and client tags. The content of the server is run on the ZK server, and the content of the client is run on the Selenium server (we called client).

Notice that the client code is Java, and it runs on the Selenium server that provides an 'emulated' browser environment in Java. In other words, the client code will be eventually 'converted' to JavaScript code, and then delivered to the browser for execution. Also notice that the Selenium server is a server independent of the application server. It is used to run the client code (without changing anything run on the application server).

In the above example, the content of the server creates a button (id=btn) which when clicked on will show a "Hello!" message. The content of the client uses btn which is an instance of org.zkoss.ztl.Widget, to fire a Click event to the browser, and then waits for the response from ZK server. Once the response is received the code then checks whether @window exists or not by using the jq API which is implemented by the class org.zkoss.ztl.JQuery.

Unit testing using image differences

In additions to Java, ZTL also allows developers to do unit testing by comparing the screenshot.

For more information, please refer to Vision Test for ZTL.

Version History

Last Update : 2011/03/22


Version Date Content
     



Last Update : 2011/03/22

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.