JUnit – Ignore Test

Sometimes, it is required not to execute any testcase. So by using @Ignore annotation, you can bypass any testcase. Following example demonstrates how to ignore a testcase.

First create a new Java Project and configure it as Maven Project. For Reference, Click Here

Add the following dependencies in pom.xml


1. JUnit Class

Create following class

package com.kruders.junit;

import static org.junit.Assert.assertEquals;

import org.junit.Ignore;
import org.junit.Test;

public class JUnitIgnoreTest {
	public void testAdd(){
		assertEquals(15, 10 + 5);
		System.out.println("@Test called - Addition");
	public void testSubtract(){
		assertEquals(5, 10 - 5);
		System.out.println("@Test called - Subtraction");

2. Testing

When you run the above example you’ll get an output like:

@Test called – Addition

No comments yet.

Leave a Reply