Annotation Helper Attributes In TestNG

Most useful attributes for automating test cases with TestNG❗️

Fareena Imran
CodixLab
2 min readFeb 18, 2022

--

In this article, we’re going to learn annotation helper attributes that are most useful for automation testing 💻. Let’s get started 👇

▶️ dependsOnMethods Attribute

This attribute makes one test method dependent on another to execute.

✔️ For Example, sometimes we need to run the test before any specific test. Let’s say you have to log in to the app but before that, you need to perform authentication for login functionality.

✔️ Code With Example

▶️ timeOut Attribute

When you know that one of the test case will take a long time to execute and other test cases are failing because of that one then you can use timeOut attribute.

Appium has feature for the implicit wait but that will be equal for all test cases but if you know that only one specific test case needs more time to execute then you can use the “timeOut” attribute for that specific test.

✔️ For Example, When you need to scroll the list but the items in the list are generating in real-time then you can increase the wait time limit for that specific method.

✔️ Code With Example

▶️ enabled Attribute

if you know that one of the functionality or flow is not working or there is some bug that is already reported and we are aware of that then TestNG provides a feature to safely skip that test case and execute all other test cases.

✔️ For Example, Let’s say in our application searching functionality is not working then we can skip this functionality by using the enabled attribute.

✔️ Code With Example

We can use the enabled attribute with “false” or “true” that depends on the scenario. Like if the bug for the functionality is removed and the test case is working now so you can assign enabled “true” then the test case will not skip.

If you’re interested to learn more about the TestNG framework, follow my articles.

Best of luck 👍

--

--

Fareena Imran
CodixLab

SQA Engineer| Tech Writer | Write stories about SQA