Skip to content

Instantly share code, notes, and snippets.

@dave-shawley
Created February 22, 2013 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave-shawley/5013968 to your computer and use it in GitHub Desktop.
Save dave-shawley/5013968 to your computer and use it in GitHub Desktop.
Little helper function that runs a bunch of named tests back-to-back calling setUp() and tearDown() methods. Very useful for spot checking unit test coverage in Eclipse but not nearly general purpose.
private void runTestsNamed(String... testNames) throws Exception {
for (int i=0; i<testNames.length; ++i) {
Method testCase = this.getClass().getMethod(testNames[i]);
testCase.invoke(this);
if ((i + 1) < testNames.length) {
tearDown();
setUp();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment