In this post I will show you how to ignore testng test case to execute,  TestNg provide attribute enabled which make the test to be execute or not, if test mark @Test(enabled = false) then test will not execute. By default enabled value is true.
Here is example for ignore test case:
Here is example for ignore test case:
package com.test;
import org.testng.Assert;
import org.testng.annotations.Test;
public class IgnoreTestClass {
        @Test
        public
void testMethod1() {
               Assert.assertTrue(true);
        }
        @Test(enabled
= false)
        public
void testMethod2() {
               Assert.assertTrue(true);
        }
        @Test(enabled
= true)
        public
void testMethod3() {
               Assert.assertTrue(true);
        }
}
Run above test you will see that testMethod2 will ignored and not executed:
PASSED: testMethod1
PASSED: testMethod3
===============================================
   
Default test
   
Tests run: 2, Failures: 0, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 2, Failures: 0, Skips:
0
====================================   
No comments:
Post a Comment
Leave your comments, queries, suggestion I will try to provide solution