Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 23 18:50
    codecov[bot] commented #1476
  • May 23 18:49
    codecov[bot] commented #1476
  • May 23 18:49
    codecov[bot] commented #1476
  • May 23 18:49
    codecov[bot] commented #1476
  • May 23 18:48
    codecov[bot] commented #1476
  • May 23 18:48
    codecov[bot] commented #1476
  • May 23 18:47
    codecov[bot] commented #1476
  • May 23 18:47
    codecov[bot] commented #1476
  • May 23 18:47
    codecov[bot] commented #1476
  • May 23 18:47
    codecov[bot] commented #1476
  • May 23 18:45
    codecov[bot] commented #1475
  • May 23 18:44
    codecov[bot] commented #1476
  • May 23 18:44
    codecov[bot] commented #1476
  • May 23 18:44
    codecov[bot] commented #1476
  • May 23 18:44
    codecov[bot] commented #1475
  • May 23 18:43
    codecov[bot] commented #1476
  • May 23 18:43
    codecov[bot] commented #1475
  • May 23 18:42
    codecov[bot] commented #1475
  • May 23 18:41
    codecov[bot] commented #1475
  • May 23 18:40
    codecov[bot] commented #1475
hichhiker
@hichhiker:matrix.org
[m]
The largest headache of the Jenkins pipeline developer
😀
Jenkins pipelines does not run Groovy as is, it first transforms Groovy using a CPS transform - which breaks/confuses a lot of things
(last one is most useful)
Josh Beauregard
@sanguis

oi now I am getting the error java.lang.NullPointerException: Cannot invoke method trim() on null object with

package com.foo.jenkins

import com.maark.jenkins.testing.JenkinsPipelineSpecification

class SemVerSetTypeSpec extends JenkinsPipelineSpecification {


    def "expected minor value"() {
        setup:
            def semVerSetType = loadPipelineScriptForTest("vars/semVerSetType.groovy")
        when:
            def type = semVerSetType("abc123")
            1 * getPipelineMock("sh")([script: "git show -s  --format=%s ${commitId}",
                'returnStdout': true]) >> "Feature/test"

        then:
            type == "minor"
    }
}

I thought trim was core groovy

1 reply
oh wait, its not getting the mock I get it
hichhiker
@hichhiker:matrix.org
[m]
if you want to handle null gracefully - you can use message?.trim() or even better message?.trim() ?: ''
Alexander Kriegisch
@kriegaex
@hichhiker:matrix.org, @sanguis: Interesting discussion. Maybe next time you want to reply to each other in a thread in order to compartmentalise the topic a bit. Then it would be easier to find and re-read, especially if, unlike today, other discussions are going on in parallel. :-)
1 reply
hichhiker
@hichhiker:matrix.org
[m]
mock stands in for the real thing - it checks that it is called, and if so, you can control the return value
RealForce1024
@RealForce1024
when I try the spock github example https://github.com/spockframework/spock-example. I copy the maven pom to myself. But failed.
Exception in thread "main" java.lang.NoClassDefFoundError: org/junit/platform/engine/discovery/NestedClassSelector
at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:132)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.discovery.NestedClassSelector
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
RealForce1024
@RealForce1024
hi,I solved it. It worked when I add the junit5 depency <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
Alexander Kriegisch
@kriegaex
The Jupiter engine should not be necessary, unless you also have JUnit 5 Jupiter tests in your project. Spock 2 has its own engine directly on top of the JUnit 5 platform, not related to Jupiter.
So if this helps in a plain Spock project, it is not the real solution, you are just hiding another problem.
RealForce1024
@RealForce1024
yes. Now I have found the other problem , It worked when I click the class title to run ,but it failed when I click the method to run the spock test. I was so confuse.
Alexander Kriegisch
@kriegaex
So you are having IntelliJ IDEA problems, not Maven ones.
Running a single method should work, too. There was a problem with this in IDEA, see https://youtrack.jetbrains.com/issue/IDEA-233864. But it has been fixed in 2021.3. Maybe you need to upgrade IDEA.
RealForce1024
@RealForce1024
Yes I also think that's the problem. When I remove the junit5 dependency it worked after I click the class title. But click the method It failed again.
Alexander Kriegisch
@kriegaex
Then please upgrade and report back if it solves the problem.
RealForce1024
@RealForce1024
I was using the newest version 2022.1.EAP. Ok,thx, I will try to solve the problem or report the issue to jetbrains. thx again.
Alexander Kriegisch
@kriegaex
I cannot say anything about EAP versions, I only use stable versions. Maybe you don't need to be so cutting edge, but up to you.
If you report anything, either here or to JetBrains, please be more specific, provide a full example project to reproduce the problem and if it is about IDE issues, also add screenshots. Otherwise they cannot help you either.
Leonard Brünings
@leonard84
Spock depends on JUnit 5.8.1, I guess something in your build downgrades the version
RealForce1024
@RealForce1024
Yes, I will. your suggest is good for me. thx
jacattau
@jacattau
With Spock 2.0, @Unroll is no longer explicitly required which is nice. However I notice there is an extra "test" now. For example, let's say I have test "test letter #letter" where letter << ["a","b","c']. Previously this was 3 tests and would get reported as "test letter a", "test letter b", and "test letter c". Now, it's getting reported like that except with the addition of "test letter #letter" also, as if there were 4 tests ran. Is there a way to not report on the method name?
Alexander Kriegisch
@kriegaex
This conforms to the JUnit 5 concept of test containers. The additional item you are seeing is a container.
image.png
Random screenshot from what I was working on earlier today:
You see the spec as a container, below that the feature method, below that the iterations with unrolled names.
IDEs like IntelliJ IDEA can report test results like that for JUnit 5.
jacattau
@jacattau
However, when I run through gradle I get this:
DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state > geb.tests.DentalPlanSelectionPageTest.Dental plan: verify ecommerce footer for Default PASSED

DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state > geb.tests.DentalPlanSelectionPageTest.Dental plan: verify ecommerce footer for Colorado PASSED

DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state > geb.tests.DentalPlanSelectionPageTest.Dental plan: verify ecommerce footer for New York PASSED

DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state > geb.tests.DentalPlanSelectionPageTest.Dental plan: verify ecommerce footer for New Mexico PASSED

DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state > geb.tests.DentalPlanSelectionPageTest.Dental plan: verify ecommerce footer for Washington PASSED

DentalPlanSelectionPageTest > Dental plan: verify ecommerce footer for #state PASSED
that last one should not be reported like that
Alexander Kriegisch
@kriegaex
More and more, I come to appreciate the combination of a fixed, human-readable feature name after def plus descriptive, parameter-based @Unroll names, usually shorter and relying on the container / child relationship.
Argh, with Gradle I am usually out, I am a Maven guy. But I guess that might mean that the container as a whole has also passed, because all of its contained tests have. I might be wrong, but that would make most sense.
This is how IDEA would visualise it, see screenshot above.
jacattau
@jacattau
it's not really a big deal, it still works. But it throws off our results a bit. This method is 5 tests, however 6 passes are being reported
Alexander Kriegisch
@kriegaex
Yes, that takes getting used to. Believe me, at first I was quite irritated too. Sometimes I still am, reminding myself of the circumstances and of the benefits.
Oops, 00.30 here already. I guess, I am off to bed. Talk to you soon!
jacattau
@jacattau
would be nice to maybe have a config option or something to turn this off. It was great with Spock 1.3
Alexander Kriegisch
@kriegaex
Spock 1.3 was JUnit 4. Spock 2 is JUnit 5. I would not expect that to change, if I was you. ;-)
RealForce1024
@RealForce1024
I cannot say anything about EAP versions, I only use stable versions. Maybe you don't need to be so cutting edge, but up to you.
@kriegaex Thx. You are right. It worked when I back to the release version of intellij idea.
tnandini09
@tnandini09
Hi All, I am nullpointerexception when calling restTemplate.exchange
Could someone help me
Joshua Gossett
@jgossett
Hey, is there anyway to run a method before all the test classes are executed? I want to seed a no sql database.
2 replies
Sidney Coelho
@sidneydemoraes

Hello everyone. I have a problem similar to RealForce1024 but I already have the Jupiter dependency corretly setup. I'm trying to create a Spec but TestEngine with ID 'spock' failed to discover tests.
Can anyone give me some light on this?

I'm using IntelliJ and this is my build.gradle file:

plugins {
    id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'

    implementation 'org.codehaus.groovy:groovy:3.0.10'
    testImplementation platform("org.spockframework:spock-bom:2.1-groovy-3.0")
    testImplementation "org.spockframework:spock-core"
    testRuntimeOnly 'net.bytebuddy:byte-buddy:1.12.8'
}

test {
    useJUnitPlatform()
}
Sidney Coelho
@sidneydemoraes
Tried the official documentation but it doesnt help much actually.
Sidney Coelho
@sidneydemoraes
Just found the root cause. It was related to Gradle, not Spock. It was missing the Groovy plugin. There is no mention at all to that on the documentation.
Mark Logs
@mark-logs-code-hub
Hi,guys. I have mutiple spock test. I wanna composite it. and this spock test have order. How to do that ?
1 reply
sorry , I'm not English native speaker.