Created
October 27, 2016 04:52
-
-
Save krmahadevan/6349e75fbf27ff9b43aa674df801895b to your computer and use it in GitHub Desktop.
How to execute selective methods from a group using Beanshell in TestNG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.rationale.emotions; | |
import org.testng.annotations.Test; | |
public class GroupTest { | |
@Test(groups = "dragon-lord") | |
public void foo() { | |
System.err.println("foo() says hello"); | |
} | |
@Test(groups = "dragon-lord") | |
public void bar() { | |
System.err.println("bar() says hello"); | |
} | |
@Test(groups = "dragon-lord") | |
public void foobar() { | |
System.err.println("foobar() says hello"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > | |
<suite name="My Suite" verbose="1" parallel="false" thread-count="1"> | |
<test name="groups-demo"> | |
<method-selectors> | |
<method-selector> | |
<script language="beanshell"> | |
<![CDATA[ | |
whatGroup = System.getProperty("whatgroup","dragon-lord"); | |
whatMethod = System.getProperty("methodToRun", "foo"); | |
if (whatGroup.isEmpty() || whatMethod.isEmpty()) { | |
return true; | |
} | |
return groups.containsKey(whatGroup) && method.getName().equals(whatMethod); | |
]]> | |
</script> | |
</method-selector> | |
</method-selectors> | |
<classes> | |
<class name="org.rationale.emotions.GroupTest"/> | |
</classes> | |
</test> | |
</suite> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment