TestNG code samples (Java SDK)

Simple TestNG test

The following is an example of a Java test to be used together with the suite XML file below.

Only the methods specified in the XML file are launched.

public void testIE() throws GeneralLeanFtException { String url = "www.mysite.com"; Browser browser = BrowserFactory.launch(BrowserType.INTERNET_EXPLORER); browser.navigate(url); }

Suite XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="suite1">
	<test name="test1">
		<class name="com.hp.leanft.examples.testng.SimpleTest">
			<include name="testIE"/>

Back to top

See also: