Think of a situation where you are required to skip one or more @Test from your testng class. In testng, you can easily able to handle this situation by setting the ‘enabled’ parameter to ‘false’ for e.g.:
@Test(enabled = false)
To use two or more parameters in a single annotation, separate
them with a comma:
@Test(priority = 3, enabled = false)
Let's take an example and set the value false for the third
test.
package automationFramework;
import
org.openqa.selenium.WebDriver;
import
org.testng.annotations.Test;
public class MultipleTest {
public
WebDriver driver;
@Test(priority = 0)
public void One() {
System.out.println("This is the Test
Case number One");
}
@Test(priority = 1)
public void Two() {
System.out.println("This is the Test
Case number Two");
}
@Test(priority = 2, enabled = false)
public void Three() {
System.out.println("This is the Test
Case number Three");
}
@Test(priority = 3)
public void Four() {
System.out.println("This is the Test
Case number Four");
}
}
Output of the above example:
This is the Test Case number One
This is the Test Case number Two
This is the Test Case number Four
No comments:
Post a Comment