ZTL"
Jumperchen (talk | contribs) |
m (remove empty version history (via JWB)) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{ZKDevelopersReferencePageHeader}} | {{ZKDevelopersReferencePageHeader}} | ||
+ | {{Deprecated|url=http://www.zkoss.org/documentation/zats}} | ||
[http://code.google.com/p/zk-ztl/ ZTL] is an automatic testing tool based on [http://www.junit.org jUnit] and [http://seleniumhq.org/ Selenium]. It is supported officially by ZK team. Here is a short introduction. For more information, please refer to [http://code.google.com/p/zk-ztl/#Documentation ZTL Documentation]. | [http://code.google.com/p/zk-ztl/ ZTL] is an automatic testing tool based on [http://www.junit.org jUnit] and [http://seleniumhq.org/ Selenium]. It is supported officially by ZK team. Here is a short introduction. For more information, please refer to [http://code.google.com/p/zk-ztl/#Documentation ZTL Documentation]. | ||
Line 7: | Line 8: | ||
<source lang="xml"> | <source lang="xml"> | ||
<test tags="button"> | <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> | </test> | ||
</source> | </source> | ||
Line 26: | Line 27: | ||
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). | 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 (< | + | In the above example, the content of the server creates a button (<code>id=btn</code>) which when clicked on will show a "Hello!" message. The content of the client uses <code>btn</code> which is an instance of [http://zk-ztl.googlecode.com/svn/trunk/javadoc/org/zkoss/ztl/Widget.html 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 <code>@window</code> exists or not by using the jq API which is implemented by the class [http://zk-ztl.googlecode.com/svn/trunk/javadoc/org/zkoss/ztl/JQuery.html 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 [http://blog.zkoss.org/index.php/2011/03/22/vision-test-for-ztl/ Vision Test for ZTL]. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
{{ZKDevelopersReferencePageFooter}} | {{ZKDevelopersReferencePageFooter}} |
Latest revision as of 10:26, 5 February 2024
This article is out of date, please refer to http://www.zkoss.org/documentation/zats for more up to date information.
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.