Class RestartableJenkinsRule
- java.lang.Object
-
- org.jvnet.hudson.test.RestartableJenkinsRule
-
- All Implemented Interfaces:
org.junit.rules.MethodRule
public class RestartableJenkinsRule extends Object implements org.junit.rules.MethodRule
Provides a pattern for executing a sequence of steps. In between steps, Jenkins gets restarted.To use this, add this rule instead of
JenkinsRuleto the test, then from your test method, callthen(org.jvnet.hudson.test.RestartableJenkinsRule.Step)repeatedly. You may test scenarios related to abrupt shutdowns or failures to start usingthenWithHardShutdown(org.jvnet.hudson.test.RestartableJenkinsRule.Step)andthenDoesNotStart().The rule will evaluate your test method to collect all steps, then execute them in turn and restart Jenkins in between each step. Consider using
JenkinsSessionRuleif you want each step to be executed immediately whenthen(org.jvnet.hudson.test.RestartableJenkinsRule.Step)is called.If your test requires disabling of a plugin then the default
PluginManager(TestPluginManager) used for tests will need to be changed toUnitTestSupportingPluginManager. This can be accomplished by annotating the test with@WithPluginManager(UnitTestSupportingPluginManager.class).- Since:
- 1.567
- Author:
- Kohsuke Kawaguchi
- See Also:
JenkinsRule
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRestartableJenkinsRule.Builderstatic interfaceRestartableJenkinsRule.StepOne step to run, intended to be a SAM for lambdas withthen(org.jvnet.hudson.test.RestartableJenkinsRule.Step).
-
Field Summary
Fields Modifier and Type Field Description FilehomeJENKINS_HOMEJenkinsRulej
-
Constructor Summary
Constructors Constructor Description RestartableJenkinsRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddStep(org.junit.runners.model.Statement step)Deprecated.voidaddStep(org.junit.runners.model.Statement step, boolean expectedToStartCorrectly)Deprecated.voidaddStepWithDirtyShutdown(org.junit.runners.model.Statement step)Deprecated.org.junit.runners.model.Statementapply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)protected JenkinsRulecreateJenkinsRule(org.junit.runner.Description description)voidstep(groovy.lang.Closure<?> c)Deprecated.voidthen(RestartableJenkinsRule.Step s)Run one Jenkins session and shut down.voidthenDoesNotStart()voidthenWithHardShutdown(RestartableJenkinsRule.Step s)Run one Jenkins session and then simulate the Jenkins process ending without a clean shutdown.
-
-
-
Field Detail
-
j
public JenkinsRule j
-
home
public File home
JENKINS_HOME
-
-
Method Detail
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target)- Specified by:
applyin interfaceorg.junit.rules.MethodRule
-
step
@Deprecated public void step(groovy.lang.Closure<?> c)
Deprecated.
-
then
public void then(RestartableJenkinsRule.Step s)
Run one Jenkins session and shut down.- Since:
- 2.24
-
thenWithHardShutdown
public void thenWithHardShutdown(RestartableJenkinsRule.Step s)
Run one Jenkins session and then simulate the Jenkins process ending without a clean shutdown. This can be used to test that data is appropriately persisted without relying on shutdown processes.Implementation note: we're actually just copying the JENKINS_HOME, which takes some time - so the shutdown isn't truly instant (additional data may be written while this happens).
-
thenDoesNotStart
public void thenDoesNotStart()
-
addStep
@Deprecated public void addStep(org.junit.runners.model.Statement step)
Deprecated.
-
addStep
@Deprecated public void addStep(org.junit.runners.model.Statement step, boolean expectedToStartCorrectly)
Deprecated.
-
addStepWithDirtyShutdown
@Deprecated public void addStepWithDirtyShutdown(org.junit.runners.model.Statement step)
Deprecated.
-
createJenkinsRule
protected JenkinsRule createJenkinsRule(org.junit.runner.Description description)
-
-