testNG : How to ignore or disable a test in testNG

Some times a failing test causes the build to fail. In that cases before the test is fixed a quick remedy is to disable the test to get the build passed. That can be done easily through annotation.

@Test(enabled=false)

The TestNG engine will just bypass this method.

import org.testng.annotations.*;

public class TestNGTest3 {

	@Test(enabled=false)
	public void divisionWithException() {  
	  System.out.println("Method is not ready yet");
	}  

}

In above example, TestNG will not test the divisionWithException() method.

One thought on “testNG : How to ignore or disable a test in testNG

  1. A better way is to put your test method in a group, say “broken”, and exclude that group from your runs. The advantage of this approach is that you can use the reports to find out all the methods that are part of the “broken” group to keep track of them.

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.