Skip to content

Commit

Permalink
[JENKINS-20609] test case
Browse files Browse the repository at this point in the history
Originally-Committed-As: 3b0e6ac02a9c5ed643ba11e4eb11b575cb491918
  • Loading branch information
kohsuke committed Nov 16, 2013
1 parent 5db2ff6 commit 6a7dcd8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Expand Up @@ -229,9 +229,9 @@
@SuppressWarnings({"deprecation","rawtypes"})
public class JenkinsRule implements TestRule, MethodRule, RootAction {

private TestEnvironment env;
protected TestEnvironment env;

private Description testDescription;
protected Description testDescription;

/**
* Points to the same object as {@link #jenkins} does.
Expand Down Expand Up @@ -313,7 +313,7 @@ public Jenkins getInstance() {
* Override to set up your specific external resource.
* @throws Throwable if setup fails (which will disable {@code after}
*/
protected void before() throws Throwable {
public void before() throws Throwable {
env = new TestEnvironment(testDescription);
env.pin();
recipe();
Expand Down Expand Up @@ -394,10 +394,12 @@ public void run() {
/**
* Override to tear down your specific external resource.
*/
protected void after() throws Exception {
public void after() throws Exception {
try {
for (EndOfTestListener tl : jenkins.getExtensionList(EndOfTestListener.class))
tl.onTearDown();
if (jenkins!=null) {
for (EndOfTestListener tl : jenkins.getExtensionList(EndOfTestListener.class))
tl.onTearDown();
}

if (timeoutTimer!=null) {
timeoutTimer.cancel();
Expand Down Expand Up @@ -429,7 +431,8 @@ protected void after() throws Exception {
// ignore
}

jenkins.cleanUp();
if (jenkins!=null)
jenkins.cleanUp();
ExtensionList.clearLegacyInstances();
DescriptorExtensionList.clearLegacyInstances();

Expand Down

0 comments on commit 6a7dcd8

Please sign in to comment.