Show Menu
Cheatography

TestNG Cheat Sheet (DRAFT) by

TestNG testing framework Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Course of action

1. Write the test and insert annota­tions into the code
2. Add test info to testng.xml
3. Run TestNG

Basic annota­tions

@Befor­eSuite
Run once before the test suite
@After­Suite
Run once after the test suite
@Befor­eClass
Run once before the test class
@After­Class
Run once after the test class
@Befor­eTest
Run once before each test in class
@AfterTest
Run once after each test in class
@Test
Mark class or method as test
 

testng.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="TestngTestClassName"/>
    </classes>
  </test>
</suite>