0% found this document useful (0 votes)
2K views1 page

TestNG Cheatsheet

TestNG is a testing framework that allows for the execution of test cases sequentially or in parallel. It provides annotations to effectively control test execution and generate HTML reports. Key advantages include data-driven testing, dependency management between tests, cross-browser testing, and test prioritization. The framework utilizes XML configuration files to define test suites, classes, and methods.

Uploaded by

louglas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views1 page

TestNG Cheatsheet

TestNG is a testing framework that allows for the execution of test cases sequentially or in parallel. It provides annotations to effectively control test execution and generate HTML reports. Key advantages include data-driven testing, dependency management between tests, cross-browser testing, and test prioritization. The framework utilizes XML configuration files to define test suites, classes, and methods.

Uploaded by

louglas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

A

TesTing CheaT sheeT


TestNG is a test execution framework

Advantages Annotations
 Executing all testcases sequentially @BeforeSuite : The annotated method will be run before
 Parallel testing MANAGEMENT
also possible. TEAM all tests in this suite have run.
 Data Parameterization is possible. @BeforeTest : The annotated method will be run before
 TestNG annotation helps to effective any test method belonging to the classes inside the <test>
tag is run.
test execution.
 Test execution can be controlled using @BeforeClass : The annotated method will be run before
the first test method in the current class is invoked.
annotation and attributes.
@DataProvider : Marks a method as supplying data for a
 It gives the ability to produce HTML test method.
Reports of execution.
@BeforeMethod : The annotated method will be run
 Retry the failed testcases. before each test method.
 Cross browser testing is possible @Test: Marks a class or a method as part of the test.
@AfterMethod: The annotated method will be run after
each test method.
@AfterClass : The annotated method will be run after all
Attributes the test methods in the current class have been run.
@AfterTest : The annotated method will be run after all
the test methods belonging to the classes inside the <test>
priority: Set to prioritize the test method for execution tag have run.
Default value: 0 @AfterSuite : The annotated method will be run after all
enabled: Set to ignore the test method for execution tests in this suite have run.
Default value: true @Parameters : To inject static datas into the testcase
invocationCount: Set to run the test method for @Parameters({"url","username","password"
multiple times })
Default value: 1
invocationtimeOut: maximum time period TestNg xml structure
provided to the test case for all the invocations count
set. ?xml version="1.0" encoding="UTF-8"?>
timeOut: total time period provided to the test case <!DOCTYPE suite SYSTEM "https://testng.org/testng-
to completely execute its test case. 1.0.dtd">
dependsOnMethods: inject dependency to the test
<suite parallel="tests" name="Suite">
methods
groups: to categorize /filter the testcase to excute <test thread-count="5" parallel="tests"
under specified group name="chrome">
dependsOnGroups: inject dependency to the test <classes>
methods based on the groups to execute
<class name="testcase.CreateLead"/>
dataProvider: set to fetch the data from the
excelsheet and to passed as arguments into the test </classes>
steps
</test> <!-- Test -->

</suite> <!-- Suite -->

You might also like