mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
f8e5733486
* use new base class for testing * initialize jenkins unit test framework only once for all test classes * minor test cleanups
46 lines
1.1 KiB
Groovy
46 lines
1.1 KiB
Groovy
#!groovy
|
|
|
|
package util
|
|
|
|
import com.sap.piper.GitUtils
|
|
import com.sap.piper.Utils
|
|
import org.codehaus.groovy.runtime.InvokerHelper
|
|
import org.springframework.context.annotation.Bean
|
|
import org.springframework.context.annotation.Configuration
|
|
|
|
@Configuration
|
|
class BasePiperTestContext {
|
|
|
|
@Bean
|
|
Script nullScript() {
|
|
def nullScript = InvokerHelper.createScript(null, new Binding())
|
|
nullScript.currentBuild = [:]
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(nullScript)
|
|
return nullScript
|
|
}
|
|
|
|
@Bean
|
|
GitUtils mockGitUtils() {
|
|
def mockGitUtils = new GitUtils()
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockGitUtils)
|
|
return mockGitUtils
|
|
}
|
|
|
|
@Bean
|
|
Utils mockUtils() {
|
|
def mockUtils = new Utils()
|
|
mockUtils.steps = [
|
|
stash : { m -> println "stash name = ${m.name}" },
|
|
unstash: { println "unstash called ..." }
|
|
]
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils)
|
|
return mockUtils
|
|
}
|
|
|
|
@Bean
|
|
MockHelper mockHelper() {
|
|
return new MockHelper()
|
|
}
|
|
|
|
}
|