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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s