Objective

Quickly learning ways to skip or ignore a test case in TestNG.

Ignoring a test

One can ignore a test during execution by simply adding enabled=false in the test. Example:

@Test(enabled = false)
   public void testPrintMessage() {
      System.out.println("Test to be ignored")
   }

SkipException

Another way is to use SkipException to skip the test. Below is the code example on how to use this exception

@Test
    public void testCaseSkipException(){
        System.out.println("Im in skip exception");
        throw new SkipException("Skipping this test");
    }

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s