Sunday, May 18, 2014

There are 100 testcases i want to execute only 3 test cases without using testng groups?

Note- just include those methods in testng.xml which you want to execute.

For ex- inside com.CC.scripts.Login class there are 100 test cases but you want to execute only 3 methods- at_loginValid, at_loginBlank and at_loginInValid. In that case you can edit your xml as below-

<suite name="Suite" parallel="none">
<test name="Test">
<classes>
<class name="com.CC.scripts.Login">
<methods>
<include name="at_loginValid"></include>
<include name="at_loginInValid"></include>
<include name="at_loginBlank"></include>
</methods>
</class>
</classes>
</test>
</suite>


Login class- Here hello method will not execute by using above testng.xml

package com.CC.scripts;
import org.testng.annotations.Test;

public class Login {
    @Test
    public void at_loginValid(){
        System.out.println("at_loginValid");
    }
    @Test
    public void at_loginInValid(){
        System.out.println("at_loginInValid");
    }
    @Test
    public void at_loginBlank(){
        System.out.println("at_loginBlank");
    }
    @Test
    public void hello(){
        System.out.println("hello");
    }
}

No comments:

Post a Comment