Reading:  

Working with TestNG - Starters Guide


How to ignore a test in testNG

In some situation user need to ignore the test case to achive this TestNG provides an annotation @Test (enabled=false) which disables the test case from execution process.

Create a Class:

This class having three test cases (TestCase1, TestCase2, TestCase3) where one case ignore (TestCase2) by using annotation "@Test (enable=false)"

package testNG;

import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;

public class TestNGIngore {@Test
	public void TestCase1() {
		System.out.println("inside the TestCase1");
		String msg = "Welcome to TestNG";
		assertEquals("Welcome to TestNG", msg);
	}

	@Test(enabled = false)
	public void TestCase2() {
		System.out.println("inside the TestCase2");
	}

	@Test
	public void TestCase3() {
		System.out.println("inside the TestCase3");
	}

}


Run above class by clicking on run button in eclipse

The Output

You can see that our TestCase2 was not entertained. This was possible because of the attribute enabled=false,  which tells testNG to skip this test.

 

 

 

Description

This tutorial is focused on getting you started on TestNG, the testing framework inspired from JUnit and NUnit. Here is a quick table of contents

  1. What is TestNG?
  2. Environment Set-up
  3. Writing Tests
  4. Basic Annotations
  5. Execution Procedure
  6. Executing Tests
  7. Suite Test
  8. Ignore Test
  9. Group Test
  10. Exception Test
  11. Dependency Test
  12. Parametrized Test
  13. JUnit Tests
  14. Test Reports
  15. Running tests without Eclipse
  16. Plugin with ANT

 

 



Environment

A computer capable of running Java. IntelliJ Community IDE is also required for this course.

Prerequisites

Good knowledge of Java programming language and eclipse is essential.

Audience

Students looking to get started with TestNG

Learning Objectives

This tutorial will get you started with TestNG.

Author: Subject Coach
Added on: 12th Mar 2015

You must be logged in as Student to ask a Question.

None just yet!