Introduction

From Documentation



A ZTL file is an XML based format that is compiled by ZtlGenerator to generate a JUnit Java test case.

For example (ZTL),

<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>

It will generate the Java class as follows:

/* B30_123456Test.java

	Purpose:
		
	Description:
		
	History:
		Mar, 29, 2010 15:52:29 PM

Copyright (C) 2010 Potix Corporation. All Rights Reserved.

This program is distributed under Apache License Version 2.0 in the hope that
it will be useful, but WITHOUT ANY WARRANTY.
*/
import org.junit.Test;
import org.zkoss.ztl.Element;
import org.zkoss.ztl.JQuery;
import org.zkoss.ztl.Tags;
import org.zkoss.ztl.Widget;
import org.zkoss.ztl.ZK;
import org.zkoss.ztl.ZKClientTestCase;

import com.thoughtworks.selenium.Selenium;

@Tags(tags = "button")
public class B30_123456Test extends ZKClientTestCase {
	
	public B30_123456Test() {
		target = "http://localhost:8080/zk50/service.zul";
		browsers = getBrowsers("all");
		_timeout = 60000;
	}
	
	@Test(expected = AssertionError.class)
	public void testClick() {
		for (Selenium browser : browsers) {
			boolean close = false;
			try {
				start(browser);
				browser.windowFocus();
				browser.windowMaximize();
				String zscript = "";
				Widget engine = new Widget(new StringBuffer("zk.Desktop._dt"));
				/** start **/
				/** server code **/
				zscript = ""
					+ "<zk>"
					+ "	<button id=\"btn\" label=\"Click Me to Show a Message\" onClick=\\'alert(\"Hello!\")\\'/>"
					+ "</zk>"
					+ ""
					;
				runZscript(zscript);
				Widget btn = engine.$f("btn");
				waitResponse();
				/** client code **/
				
				click(btn);
				waitResponse();
				verifyTrue(jq("@window").exists());
				
				/** end **/
				close = true;
			} finally {
				if (close) stop();	
			}
		}
	}
}


Last Update : 2011/05/26

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