Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondwu1 committed Nov 27, 2024
1 parent 4b8286e commit 6d10e48
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

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(
plugin = {"pretty"},
tags = "not @ignore"
)
public class AcceptanceTests {
@ClassRule
public static JenkinsRule jenkinsRule = new JenkinsRule();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

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(
plugin = {"pretty"},
tags = "@wip and not @ignore"
)
public class WipAcceptanceTests {
@ClassRule
public static JenkinsRule jenkinsRule = new JenkinsRule();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down

0 comments on commit 6d10e48

Please sign in to comment.