How to disable Selenium Testcases using TestNG Feature
Welcome to Selenium Tutorial, Today we are going to discuss very silent feature of TestNG which allow us to enable or disable our test case based on our requirement.
Why
to Disable Selenium Test cases?
Before moving forward you should have Eclipse TestNG setup ready if still not configured then please doSelenium Eclipse setup now.
Once our test suite size will increase day by day then chances are high that you don’t want to execute some test cases.
Ok so let’s consider a scenario that you have written 10 testcases but now you want to execute only 5 testcase because other 5 are working correctly
How to Disable Selenium Test cases?
In TestNG we can achieve this by simply adding enable attribute and can set value to true/false.
1
|
@Test(enable=false)
|
If test case enable as false them while running test cases TestRunner simply will ignore this testcase and will only run testcase whose enable is set to true.
Note- By default @Test is set to enable
Scenario – I have 3 test case but I want to execute only 2 test case.
Precondition- TestNG should be installed
Program for – Disable Selenium Test cases
import org.testng.annotations.Test;
public class TestEnableTC {
@Test
public void testLoginApp(){
System.out.println("User is able to login successfully");
}
@Test(enabled=false)
public void testRegisteruser(){
System.out.println("User is able to register successfully");
}
@Test
public void testLogoutApp(){
System.out.println("User is able to logout successfully");
}
}
No comments:
Post a Comment