Skip to content

Instantly share code, notes, and snippets.

@colinbut
Created August 12, 2021 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinbut/32fc3eead375cceb56ef251585483af8 to your computer and use it in GitHub Desktop.
Save colinbut/32fc3eead375cceb56ef251585483af8 to your computer and use it in GitHub Desktop.
import com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
import com.mycompany.colinbut.Git
class BuildJavaAppSpec extends JenkinsPipelineSpecification {
def buildJavaApp = null
def setup() {
buildJavaApp = loadPipelineScriptForTest("vars/buildJavaApp.groovy")
}
def "Test run BuildJavaApp pipeline"() {
setup:
def body = Mock(Closure)
def git = GroovyMock(Git.class, global: true)
new Git(buildJavaApp) >> git
when:
buildJavaApp repo: "http://github.com/colinbut/examplerepo.git", body
then:
1 * git.checkout("http://github.com/colinbut/examplerepo.git")
1 * getPipelineMock("sh")("./mvnw clean compile")
1 * getPipelineMock("sh")("./mvnw test")
1 * getPipelineMock("sh")("./mvnw verify")
1 * getPipelineMock("sh")("./mvnw package -DskipTests=true")
1 * body()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment