How to prevent a test case from running using TestNG?

How to prevent a test case from running using TestNG?

Hey Charity,

You can prevent the execution of a test method by configuring the ‘enabled’ attribute and setting it to false.

// For an individual test method @Test(enabled = false) public void testMethod1() { // Test logic }

// For a test method within a specific group @Test(groups = {“NegativeTests”}, enabled = false) public void testMethod2() { // Test logic }

We hope this information proves helpful to you. Feel free to reach out if you have any additional questions or concerns.