diff --git a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/GlobalEventsPluginTest.groovy b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/GlobalEventsPluginTest.groovy index 56e779f..e9eb9be 100644 --- a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/GlobalEventsPluginTest.groovy +++ b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/GlobalEventsPluginTest.groovy @@ -5,6 +5,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder +import org.jvnet.hudson.test.JenkinsRule import java.util.concurrent.Callable import java.util.concurrent.ExecutorService @@ -18,6 +19,8 @@ import static groovy.test.GroovyAssert.shouldFail * Created by nickgrealy@gmail.com. */ class GlobalEventsPluginTest { + @Rule + public JenkinsRule jenkinsRule = new JenkinsRule() private GlobalEventsPlugin.DescriptorImpl plugin private LoggerTrap logger @@ -27,8 +30,6 @@ class GlobalEventsPluginTest { @Before void setup() { - // disable load method, create new plugin... - GlobalEventsPlugin.DescriptorImpl.metaClass.load = {} plugin = new GlobalEventsPlugin.DescriptorImpl(ClassLoader.getSystemClassLoader()) logger = new LoggerTrap(GlobalEventsPluginTest.name) } diff --git a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/AcceptanceTests.java b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/AcceptanceTests.java index a626df0..fa1167e 100644 --- a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/AcceptanceTests.java +++ b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/AcceptanceTests.java @@ -2,7 +2,9 @@ import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; +import org.junit.ClassRule; import org.junit.runner.RunWith; +import org.jvnet.hudson.test.JenkinsRule; @RunWith(Cucumber.class) @CucumberOptions( @@ -10,4 +12,6 @@ tags = "not @ignore" ) public class AcceptanceTests { + @ClassRule + public static JenkinsRule jenkinsRule = new JenkinsRule(); } diff --git a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/StepDefs.groovy b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/StepDefs.groovy index 5e9dd33..1f63c38 100644 --- a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/StepDefs.groovy +++ b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/StepDefs.groovy @@ -15,7 +15,6 @@ import org.jenkinsci.plugins.globalEventsPlugin.GlobalQueueListener import org.jenkinsci.plugins.globalEventsPlugin.LoggerTrap class StepDefs { - GlobalEventsPlugin.DescriptorImpl plugin GlobalRunListener runListener GlobalComputerListener computerListener @@ -30,8 +29,6 @@ class StepDefs { @Before void setup() { - // disable load method, create new plugin... - GlobalEventsPlugin.DescriptorImpl.metaClass.load = {} plugin = new GlobalEventsPlugin.DescriptorImpl(ClassLoader.getSystemClassLoader()) logger = new LoggerTrap(GlobalEventsPluginTest.name) diff --git a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/WipAcceptanceTests.java b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/WipAcceptanceTests.java index 56d783a..4db563a 100644 --- a/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/WipAcceptanceTests.java +++ b/src/test/groovy/org/jenkinsci/plugins/globalEventsPlugin/acceptance/WipAcceptanceTests.java @@ -2,7 +2,9 @@ import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; +import org.junit.ClassRule; import org.junit.runner.RunWith; +import org.jvnet.hudson.test.JenkinsRule; @RunWith(Cucumber.class) @CucumberOptions( @@ -10,4 +12,6 @@ tags = "@wip and not @ignore" ) public class WipAcceptanceTests { + @ClassRule + public static JenkinsRule jenkinsRule = new JenkinsRule(); } diff --git a/src/test/resources/org/jenkinsci/plugins/globalEventsPlugin/acceptance/Groovy Script - Runtime.feature b/src/test/resources/org/jenkinsci/plugins/globalEventsPlugin/acceptance/Groovy Script - Runtime.feature index 9aeeebb..8b758e3 100644 --- a/src/test/resources/org/jenkinsci/plugins/globalEventsPlugin/acceptance/Groovy Script - Runtime.feature +++ b/src/test/resources/org/jenkinsci/plugins/globalEventsPlugin/acceptance/Groovy Script - Runtime.feature @@ -63,12 +63,11 @@ Feature: Groovy Script - Runtime Scenario: All relevant job parameters should passed into the script, so that I don't have to manually retrieve data Given the script """ - log.info("${log.class}, $listener, $jenkins, $context, $run, $event, $env") + log.info("${log.class}, $listener, null, $context, $run, $event, $env") """ When the Run.onStarted event is triggered Then the log level info should display 'class org.jenkinsci.plugins.globalEventsPlugin.LoggerTrap, null, null, [:], null, RunListener.onStarted, [:]' - Scenario: If the script outputs a map, it should be placed into the cache for subsequent executions, so that the script can keep "memory" Given the script """