Customize Test Environment

From Documentation
Revision as of 04:45, 15 May 2012 by Hawk (talk | contribs) (Created page with "{{ZATSEssentialsPageHeader}} When we use <tt> Zats </tt> to initialize the test case environment, it will '''load built-in web.xml and zk.xml '''. <source lang="java"> @Befo...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Customize Test Environment




When we use Zats to initialize the test case environment, it will load built-in web.xml and zk.xml .

	@BeforeClass
	public static void init(){
		Zats.init("./src/main/webapp");
	}

	@AfterClass
	public static void end(){
		Zats.end();
	}

	@Test
	public void test(){
		DesktopAgent desktop = Zats.newClient().connect("/basic/click.zul");
		//...

	}

But most projects have their custom configuration in web.xml or need a another one for testing purpose. Mimic provides a way to apply custom web descriptor by specifying your WEB-INF folder.

First, you should create your own ZatsEnvironment by new DefaultZatsEnvironment("./src/test/env1/WEB-INF") with your "WEB-INF" path as the parameter. Then, use it to create a client to connect to ZUL. The rest are the same as you do under default configuration.

public class EnvironmentTest{

	static ZatsEnvironment env; 

	@BeforeClass
	public static void init(){
		env = new DefaultZatsEnvironment("./src/test/env1/WEB-INF");
		env.init("./src/main/webapp"); 
	}

	@AfterClass
	public static void end(){
		env.destroy();
	}
	@Test
	public void testCustomConfig() {

		Client client = env.newClient();
		DesktopAgent desktop = client.connect("/basic/custom-config.zul");
		//...
	}
}




Last Update : 2012/05/15

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