Ignore a Specific TestNG Test Method

  • Estimate Completion Time
    not found 30 minutes
  • Difficulty Level:

Write three TestNG test methods and ignore a specific test method.

Steps to follow

Create a new test class named “Ignore Test”. Create three test methods “testMethod1”, “testMethod2” and “testMethod3”.

Use the ‘enabled=false’ attribute to ignore the second test. Now execute the test suite to observe that the second test method “testMethod2” is skipped.

Solution

package practice;

import org.testng.annotations.Test;

public class IgnoreTest {

	@Test
	public void testMethod1() {
		System.out.println("I am test Method 1");
		//write code
	}
	@Test(enabled=false)
	public void testMethod2() {
		System.out.println("I am test Method 2");
		//write code
	}
@Test
	public void testMethod3() {
		System.out.println("I am test Method 3");
		//write code
	}
}
TestNG Practice Exercises - QA Ads Banner

Proleed Academy

Proleed serves / offers professionally designed IT training courses
globally.

Copyright © 2023 - Proleed Academy | All Rights Reserved.