How TestNG Enabled Annotation Works In Selenium Example Program?

TestNG Enabled Annotation Works Example

How does TestNG Enabled Annotation work In Selenium Example Program?

package com.selenium.TestNG;
import org.testng.annotations.Test;
public class AlwaysRunTest 
{
   @Test(priority=0)
    public void methodfail() { 
      System.out.println("Fail Method");
    }
    @Test(dependsOnMethods="error",priority=2) 
    public void alwaysruntrue() { 
      System.out.println("Always run is true");
    }   
    @Test(enabled=true,priority=1)
   public void error()
    {
    	System.out.println("Exception Occured");
    }
}
package com.selenium.TestNG;
import org.testng.Assert;
import org.testng.annotations.Test;
public class Testng_AlwaysRun 
{
   @Test
   public void show()
   {
      System.out.println("Show Executed");
      Assert.assertFalse(2>1);
   }
   @Test(enabled=true)
   public void show1()
   {
      System.out.println("Show1 Executed");
      Assert.assertEquals("manoj", "hjg");	
   }
   @Test(dependsOnMethods="show1",alwaysRun=true) // There Is No Such Option For False
   public void show2()
   {
      System.out.println("Show2 Executed");
   }
}

Avatar for Softwaretestingo Editorial Board

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

Leave a Comment