Class RestartableJenkinsRule
- All Implemented Interfaces:
org.junit.rules.MethodRule
To use this, add this rule instead of JenkinsRule
to the test,
then from your test method, call then(org.jvnet.hudson.test.RestartableJenkinsRule.Step)
repeatedly.
You may test scenarios related to abrupt shutdowns or failures to start using thenWithHardShutdown(org.jvnet.hudson.test.RestartableJenkinsRule.Step)
and
thenDoesNotStart()
.
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 JenkinsSessionRule
if you want each step to be executed immediately when
then(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 to UnitTestSupportingPluginManager
.
This can be accomplished by annotating the test with @WithPluginManager(UnitTestSupportingPluginManager.class)
.
- Since:
- 1.567
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static interface
One step to run, intended to be a SAM for lambdas withthen(org.jvnet.hudson.test.RestartableJenkinsRule.Step)
. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addStep
(org.junit.runners.model.Statement step) Deprecated.void
addStep
(org.junit.runners.model.Statement step, boolean expectedToStartCorrectly) Deprecated.void
addStepWithDirtyShutdown
(org.junit.runners.model.Statement step) Deprecated.org.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target) protected JenkinsRule
createJenkinsRule
(org.junit.runner.Description description) void
step
(groovy.lang.Closure<?> c) Deprecated.void
Run one Jenkins session and shut down.void
void
Run one Jenkins session and then simulate the Jenkins process ending without a clean shutdown.
-
Field Details
-
j
-
home
JENKINS_HOME
-
-
Constructor Details
-
RestartableJenkinsRule
public RestartableJenkinsRule()
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runners.model.FrameworkMethod method, Object target) - Specified by:
apply
in interfaceorg.junit.rules.MethodRule
-
step
Deprecated. -
then
Run one Jenkins session and shut down.- Since:
- 2.24
-
thenWithHardShutdown
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. -
addStep
@Deprecated public void addStep(org.junit.runners.model.Statement step, boolean expectedToStartCorrectly) Deprecated. -
addStepWithDirtyShutdown
Deprecated. -
createJenkinsRule
-
then(org.jvnet.hudson.test.RestartableJenkinsRule.Step)
instead.