Last active
July 2, 2016 08:41
-
-
Save krmahadevan/4befa0686bf3f1a05374edcb32dfc4ee to your computer and use it in GitHub Desktop.
A Sample Suite Listener which can retrieve the names of all methods that are part of a group.
This file contains hidden or 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
public static class GroupPrinter implements ISuiteListener { | |
@Override | |
public void onStart(ISuite suite) { | |
String groupName = System.getProperty("groupName", "all"); | |
List<ITestNGMethod> allMethods = suite.getAllMethods(); | |
List<ITestNGMethod> filteredMethods = new ArrayList<>(); | |
for (ITestNGMethod method : allMethods) { | |
if (Arrays.asList(method.getGroups()).contains(groupName)) { | |
filteredMethods.add(method); | |
} | |
if (Arrays.asList(method.getBeforeGroups()).contains(groupName)) { | |
filteredMethods.add(method); | |
} | |
if (Arrays.asList(method.getAfterGroups()).contains(groupName)) { | |
filteredMethods.add(method); | |
} | |
} | |
System.err.println("**** Filtered Groups " + filteredMethods); | |
} | |
@Override | |
public void onFinish(ISuite suite) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment