use of org.jvnet.hudson.test.recipes.Recipe in project hudson-2.x by hudson.
the class HudsonTestCase method recipe.
//
// recipe methods. Control the test environments.
//
/**
* Called during the {@link #setUp()} to give a test case an opportunity to
* control the test environment in which Hudson is run.
*
* <p>
* One could override this method and call a series of {@code withXXX} methods,
* or you can use the annotations with {@link Recipe} meta-annotation.
*/
protected void recipe() throws Exception {
recipeLoadCurrentPlugin();
// look for recipe meta-annotation
try {
Method runMethod = getClass().getMethod(getName());
for (final Annotation a : runMethod.getAnnotations()) {
Recipe r = a.annotationType().getAnnotation(Recipe.class);
if (r == null)
continue;
final Runner runner = r.value().newInstance();
recipes.add(runner);
tearDowns.add(new LenientRunnable() {
public void run() throws Exception {
runner.tearDown(HudsonTestCase.this, a);
}
});
runner.setup(this, a);
}
} catch (NoSuchMethodException e) {
// not a plain JUnit test.
}
}
Aggregations