Questions tagged [jenkins-spock]
12 questions
2
votes
1 answer
How to mock variables from a groovy file
I have a groovy file created under "vars" in a Jenkins-shared-lib.
Few variables are defined inside call().
I want to mock the variables in a groovy test file.
Variables are defined in sonarGradleProject.groovy in vars:
#!/usr/bin/env groovy
import…

Aniket Upadhyay
- 21
- 2
1
vote
0 answers
Jenkins-Spock test failed with NoClassDefFoundError
I installed jenkins-spock package in my Jenkins shared library project. When I attempt to run the test I created, I got the following error:
java.lang.NoClassDefFoundError: javax/servlet/ServletException
at…

XDimension0x
- 131
- 1
- 4
1
vote
1 answer
How do I write arbitrary text to the console in a spock test?
While writing tests I sometimes just want to write text to the console for debugging.
How do I do this in a spock test? I tried using the logger but it's throwing an error:
import javaposse.jobdsl.dsl.DslScriptLoader
import…

red888
- 27,709
- 55
- 204
- 392
1
vote
1 answer
java.lang.AbstractMethodError in implementing Spock-Reports Extension (renatoathaydes) for my SPOCK test
I'm very new to SPOCK so excuse me if this a silly question.
I've done report setup in my Maven based Spock-Groovy project as mentioned in the below git-hub project-
https://github.com/renatoathaydes/spock-reports
What I've done is-
Added below 3…

Satyendra Sharma
- 1,436
- 13
- 19
1
vote
1 answer
Jenkins Spock Tests failing with java.lang.NoSuchMethodError: com.google.common.collect.Sets
JenkinsPipelineSpecification based tests fail with the error: java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;

Ashok Rawat
- 11
- 1
0
votes
0 answers
jenkins instance is missing when writing spock test
I am writing a test for which having a Jenkins instance . so I need to mock the Jenkins class and set the instance to Jenkins. What is the method to set the instance?
Import jenkins.model.Jenkins

Prabagaran Sellamuthu
- 193
- 12
0
votes
0 answers
unable to resolve class com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification
I am trying to run some spock tests with Maven. I already ran tests before with groovy version 2.4. Now when I switched to 2.5+, it shows some error.
My minimal pom is:
org.codehaus.groovy
…

Subhojoy Dey
- 3
- 1
- 3
0
votes
1 answer
Evaluate return value from Jenkins shared library in unit test with jenkins-spock
So I have a scripted shared pipeline library in my vars folder that returns some value at the end:
def call() {
def a = 3
//does stuff
return a
}
Now I try to test it like this:
def "example test"() {
when:
def result =…

Kathi
- 323
- 2
- 13
0
votes
0 answers
Mocking Jenkins internal functions with Spock and jenkins-spock
What I'm trying to do is create a method mock that returns a mock so I can test the folloging disconnectNode method of a class. What I'm trying to mock is the getNode and toComputer calls in the getJenkinsNode method.
Computer getJenkinsNode(String…
0
votes
0 answers
Jenkins spock: Mocking http-request-plugin's httpRequest
Somewhere in my shared library I got a helper class like this:
class Helper {
def script
Helper(script) {
this.script = script
}
void sendTemplate(String webhook, String template, Map values, TemplateMapper…

Nunuzac
- 13
- 3
0
votes
1 answer
Jenkins-spock : method stub fails depending on the platform
Here is a (simplified) piece of code and the related unit test I wrote, and for which I was happy until recently.
File vars/deleteFile.groovy
@NonCPS
def call(String path) {
new File(path).delete() //Must be declared as authorized class & method…

Julien Nicol
- 31
- 1
- 2
0
votes
1 answer
Verifying Jenkins calls while testing pipeline code
I am writing a Jenkins pipeline library, and am having some difficulties with mocking/validating an existing Jenkins pipeline step.
I am using jenkins-spock by homeaway to unit test, but I think my problem is more Spock related.
import…

Xetius
- 44,755
- 24
- 88
- 123