提交 ffff8fb8 编写于 作者: K Kohsuke Kawaguchi

added a mechanism to run test without a Jenkins instance

上级 72cad376
......@@ -300,6 +300,10 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
protected void setUp() throws Exception {
env.pin();
recipe();
for (Runner r : recipes) {
if (r instanceof WithoutJenkins.RunnerImpl)
return; // no setup
}
AbstractProject.WORKSPACE.toString();
User.clear();
......@@ -404,11 +408,13 @@ public abstract class HudsonTestCase extends TestCase implements RootAction {
}
} finally {
server.stop();
if (server!=null)
server.stop();
for (LenientRunnable r : tearDowns)
r.run();
jenkins.cleanUp();
if (jenkins!=null)
jenkins.cleanUp();
env.dispose();
ExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances();
......
package org.jvnet.hudson.test;
import org.apache.commons.io.FileUtils;
import org.jvnet.hudson.test.recipes.Recipe;
import org.jvnet.hudson.test.recipes.WithPlugin;
import java.io.File;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.net.URL;
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
* An annotation for test methods that do not require the {@link JenkinsRule}/{@link HudsonTestCase} to create and tear down the jenkins
* instance.
*/
@Retention(RUNTIME)
@Documented
@Target(METHOD)
@Recipe(WithoutJenkins.RunnerImpl.class)
public @interface WithoutJenkins {
class RunnerImpl extends Recipe.Runner<WithPlugin> {
// bogus. this recipe is handled differently by HudsonTestCase
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册