How to Skip @Test in TestNG

· Read in about 1 min · (174 words) ·

Skipping test is also an important concept in TestNG. You can skip the test from running as you don’t want to Run the @test and mark the @test as Skip in reports.

To Skip the test we need to use org.testng.SkipException an Exception Class from TestNG. We have to throw an exception to the first line and code will come out from the test. You can have a look at Java document to read more about exception throwing.

How to Skip @Test:

We are going to throw SkipException in the following example Class.

package com.tutorial.testng;

import org.testng.Assert;
import org.testng.SkipException;
import org.testng.annotations.Test;

public class SkipTestInTestng {
	// Skip Test
	public void skipTestMethod() {
		throw new SkipException("Skipped Test");

	// Pass Test
	public void passTestMethod() {

	// Fail Test
	public void failTestMethod() {

When You Run the Class:

When we ran the above example class TestNG report has one Test Failure and one Test marked as Skipped.

    Default test
    Tests run: 3, Failures: 1, Skips: 1