TestNG @Test attributes - AlwaysRun

alwaysRun is a testNG attribute which makes a test method run always even if it's dependent method is not run...

let's see the code implementation

public class AlwaysRun {
     WebDriver driver;
     @Test
     public void test1()
 {
    driver = new FirefoxDriver();
    driver.get("http:\\qavalidation.com");
    Assert.assertTrue(driver.getTitle().contains("Testing"));
 }
     @Test(dependsOnMethods = {"test1"}, alwaysRun=true)
     public void test2()
 {
     driver.findElement(By.linkText("Selenium Tutorial!")).click();
 }
}

Observe the output, even though test1 did not run, test2 executed.

No comments:

Post a Comment