Hello Folks,
Proper categorisation/grouping of test scripts is very important as it gives us flexibility in running specific or group of tests. Group names followed by meaningful prefix or suffix help us in reducing number of lines of codes to execute desired groups. We will see an example below:
You have multiple groups of tests and you have marked some of tests from each group as smoke tests. A TestNG class is as below:
Now suppose you need to run smoke tests from all groups. We can do this in two ways:
Way 1:
Since there are multiple groups, you need to include each group name in TestNG xml as below:
Output:
Creating xml using above approach will be difficult if you have so many groups of tests.
Way 2: Using Regular expression
Output:
Note:
1. TestNG uses regular expressions, and not wildmats. Be aware of the difference (for example, “anything” is matched by “.*” — dot star — and not “*”).
2. You can’t use regex in the class name attribute with TestNG xml. Regex can be used in include, exclude tags and package tags.
3. Regex is case sensitive means “Smoke” and “smoke” both are different things.
More about TestNG in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium
My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning
Hello Folks, Recently a guy asked me this question which he was asked in an interview in IBM. What the…
Hello Folks, As part of our API Testing series, we will see “Sending GET request with params in Postman”. In last…
We have learnt in previous posts regarding establishing relationship between test methods. You can go through them below: Dependency in…
In previous post, We have learnt to Establish dependency among test methods. In this post, we will see another concept…
We are going to see another important concept or feature provided by TestNG. This feature is called as Dependency. Suppose,…
A Test method is run for all data set provided by a DataProvider method which is by default one after…