0% found this document useful (0 votes)
5 views

07_01_TestNG Groups Include, Exclude with Example - Selenium Tutorial

Uploaded by

minhtandragon29
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

07_01_TestNG Groups Include, Exclude with Example - Selenium Tutorial

Uploaded by

minhtandragon29
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

TestNG Groups:

Include, Exclude
with Example -
Selenium Tutorial
May-2019
RBVH/ENG1

Content
 What is Group test
 TestNG Groups with Example
 Set maven and Java path in environment variable (for windows use
r)
 Introduction to XML and how to make an XML files
 Another mechanism instead of Grouping is “exclude” or “include” i
n test XML
 How to run code using XML file (video demo)

2
What is Group test

 Group test is a new innovative feature in TestNG, which doesn’t


exist in JUnit framework. It permits you to dispatch methods into
proper portions and perform sophisticated groupings of test
methods.
 Not only can you declare those methods that belong to groups, but
you can also specify groups that contain other groups. Then,
TestNG can be invoked and asked to include a certain set of groups
(or regular expressions), while excluding another set.
 Group tests provide maximum flexibility in how you partition your
tests, and doesn't require you to recompile anything if you want to
run two different sets of tests back to back.
 Groups are specified in your testng.xml file using the <groups>
tag. It can be found either under the <test> or <suite> tag.
Groups specified in the <suite> tag apply to all the <test> tags
underneath.

3
TestNG Groups with Example
We use groups in Testng when,
•We don't want to define test methods separately in different
classes (depending upon functionality) and
•At the same time want to ignore (not to execute) some test
cases as if they does not exist in the code.
•So to carry out this we have to Group them. This is done by
using "include" and "exclude" mechanism supported in testNG.

4
1.Groups on Methods

5
1.Groups on Methods

6
2. Groups on Class

7
2. Groups on Class

8
3. Misc Examples

9
How to Run Multiple Test Suites
in Selenium
tep 1) Creating a TestNG.xml file for executing test

In order to do that follow the below steps.


1.Create a new project in eclipse
2.Create two packages in the projects (name them as
com.suite1 and com.suite2)
3.Create a class in each package (name them as Flipkart.java
and Snapdeal.java)
4.Create a new file in your project and name it as testing.xml
.Testng.xml contains all configuration (classnames, testnames
and suitnames.

10
Step 2) Parallel execution in TestNG

11
Step 2) Parallel execution in TestNG

1) thread-count: This is used for parallel execution, based


on the number script. It will execute in parallel or sequential
order.
2) verbose: It is used to log the execution details in the
console. The value should be 1-10. The log details in the
console window will get more detailed and clearer as you
increase the value of the verbose attribute in the testng.xml
configuration file.
3) name: Name of the suite. Here it is "Gmail Suite"
4) Parallel: To run scripts parallel, value can be
tests/classes/methods/suites. Default value is none
Right click on the testing.xml and select run as testing, once
successful you'll see all the results

12
Output:

13
RBVH/ENG1

Conclusion
 Here we have seen in above example, how to use Testng to
execute parallel test. TestNG gives an option to execute multiple
test in parallel in a single configuration file (XML).

14
RBVH/ENG1

Reference
 https://www.guru99.com/testng-execute-multiple-test-suites.html

15

You might also like