TestNG code samples

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 will be launched.

@Test
public void testIE() throws GeneralLeanFtException { String url = "www.hpe.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">
	  <classes>
		<class name="com.hp.leanft.examples.testng.SimpleTest">
		<methods>
			<include name="testIE"/>
		</methods>
		</class>
	  </classes>
	</test>
</suite>

Back to top

See also: