Enabling or Disabling a Test case in TestNG

To enable or disable a test case in testng, an attribute called enabled is passed which is a boolean attribute where when the value is:

true – test case will be executed.

false – test case will not be executed.

By Default, the value of this attribute is true.

Let us consider below example which has 4 test cases, we are passing enabled = false in testcase2 method.

Here, in above code, as testcase2 method is disabled. So it will not be executed and output will be:

Test case 3
Test case 1
Test case 4

PS: For any questions queries or comment feel free to write us at saurabh@qatechhub.com or support@qatechhub.com. Happy Learning 🙂

Saurabh Dhingra

About the Author

Saurabh Dhingra

Follow Saurabh Dhingra: