All Posts

JUnit Ignore Test

JUnit Ignore Test

In this tutorial, you will learn how to ignore a test in JUnit framework. In JUnit, @Ignore annotation is used to skip or ignore a test case/ test method if it is not ready to test. We need to import a statement “8” when working with @Ignore.

 

Example

Sample example to ignore a test as follows:

import org.junit.Ignore;
import org.junit.Test;
public class JUnitIgnoreTestExample {
	
	@Ignore("TO DO")
	@Test
	public void testCaseNotReady(){
			System.out.println(" Test case not ready : Under development");
		}
	
	@Test
	public void testCaseReady(){
			System.out.println("testCaseReady Executing ...");
		}
}

Screenshot

When you  execute the test class,  it will give the output as “2 test methods” executed.

Test method : testCaseNotReady – Ignored
Test method : testCaseReady – Passed

 

"JUnit