From 1d5cdddf1f0e72ef629961b880d248aa5018ef8a Mon Sep 17 00:00:00 2001 From: Stephen Connolly Date: Wed, 19 Oct 2011 16:37:22 +0100 Subject: [PATCH] Add an annotation to enable skipping Jenkins provisioning for specific tests --- .../org/jvnet/hudson/test/JenkinsRule.java | 4 ++++ .../org/jvnet/hudson/test/WithoutJenkins.java | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/src/main/java/org/jvnet/hudson/test/WithoutJenkins.java diff --git a/test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java b/test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java index 6a8c5be9dd..9d08f68330 100644 --- a/test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java +++ b/test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java @@ -412,6 +412,10 @@ public class JenkinsRule implements TestRule, RootAction { } public Statement apply(final Statement base, final Description description) { + if (description.getAnnotation(WithoutJenkins.class) != null) { + // request has been made to not create the instance for this test method + return tempFolder.apply(base, description); + } return tempFolder.apply(new Statement() { @Override public void evaluate() throws Throwable { diff --git a/test/src/main/java/org/jvnet/hudson/test/WithoutJenkins.java b/test/src/main/java/org/jvnet/hudson/test/WithoutJenkins.java new file mode 100644 index 0000000000..90c6a35240 --- /dev/null +++ b/test/src/main/java/org/jvnet/hudson/test/WithoutJenkins.java @@ -0,0 +1,19 @@ +package org.jvnet.hudson.test; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * An annotation for test methods that do not require the {@link JenkinsRule} to create and tear down the jenkins + * instance. + */ +@Retention(RUNTIME) +@Documented +@Target(METHOD) +public @interface WithoutJenkins { +}