Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 25 18:20
    codecov[bot] commented #1380
  • Oct 25 18:19
    codecov[bot] commented #1380
  • Oct 25 18:18
    codecov[bot] commented #1380
  • Oct 25 18:17
    codecov[bot] commented #1380
  • Oct 25 18:16
    codecov[bot] commented #1380
  • Oct 25 18:16
    codecov[bot] commented #1380
  • Oct 25 18:15
    codecov[bot] commented #1380
  • Oct 25 18:11
    codecov[bot] commented #1380
  • Oct 25 18:11
    leonard84 synchronize #1380
  • Oct 25 18:11
    leonard84 review_requested #1386
  • Oct 25 18:11
    leonard84 ready_for_review #1386
  • Oct 25 18:10
    leonard84 review_requested #1387
  • Oct 24 17:44
    codecov[bot] commented #1386
  • Oct 24 17:42
    codecov[bot] commented #1386
  • Oct 24 17:42
    codecov[bot] commented #1386
  • Oct 24 17:41
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
  • Oct 24 17:40
    codecov[bot] commented #1386
Alexander Kriegisch
@kriegaex
What I mean is: Your question is not unlike "Does anyone know how to drive a car?" and then someone saying "yeah, sure". It would be the correct answer, but not helpful to the person asking.
treethingy
@treethingy
Hi, I'm looking for a sophisticated way to modify the way "Condition not satisfied:" output is rendered. I'm validating XML agains XSD and Schematron. I've created a hamcrest matcher and implemented "describeMismatch". Is there a better way to do it?
3 replies
liubo404
@liubo404
Error:Groovyc: While compiling tests of iceim: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/ben/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation  because of exception java.lang.NullPointerException
how to resolve this error, any ideas, thanks a lot
I google for an hour, nothing useful can help~
the maven dependency below:
    <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>

  <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
陆龟
@xialugui
@liubo404 试试显示指定groovy版本
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>3.0.8</version>
    <type>pom</type>
</dependency>
liubo404
@liubo404
image.png
@xialugui 好象还是不太行, 多谢~
Alexander Kriegisch
@kriegaex

@xialugui, groovy-all is not necessary for Spock 2.0.

@liubo404 , it is hard to reason about a partial POM without any code. Please be so kind as to share a reproducer on GitHub. This is called an MCVE. It helps us to understand and analyse your problem and you to get the answers you need.

liubo404
@liubo404
I think it's my problem, I used spock with spring-boot 2.4.4, that's why this error occurs.
thanks very much @kriegaex
I commit this to github issue, and close it.
spockframework/spock-example#44
├── pom.xml     //1.here inherit from spring-boot-starter-parent
├── README.md
└── spocky
    ├── pom.xml //2.spock depency 
    ├── spocky.iml
    └── src
        ├── main
        │   ├── java
        │   └── resources
        └── test
            ├── groovy
            │   └── com
            │       └── abc
            │           └── DemoSpec.groovy
            └── java
                └── DemoTest.java

//1.pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.abc</groupId>
    <artifactId>demo-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>xxxx</name>
    <description>xxx</description>
    <packaging>pom</packaging>

    <modules>
        <module>spocky</module>
    </modules>
</project>


//2.spock depency pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>internal-control-parent</artifactId>
        <groupId>com.abc</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spocky</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-spring</artifactId>
            <version>2.0-groovy-3.0</version>
            <scope>test</scope>
        </dependency>
   <!--
        with this or not, still the same ERROR:Groovyc....
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.5.0</version>
            <scope>test</scope>
        </dependency>

    --> 

    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


//3.DemoSpec.groovy

package com.abc;

import spock.lang.Specification

class DemoSpec extends Specification {
    def "an integer can be incremented"() {
        given:
        int i = 1
        when:
        i++
        then:
        i == 2
    }
}
liubo404
@liubo404
finally, I change the spock-core version to 2.0-groovy-2.5, it's solve the problem
//2.spock depency pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>internal-control-parent</artifactId>
        <groupId>com.ctjsoft</groupId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>spocky</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>2.0-groovy-2.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <version>1.12.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compileTests</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <useFile>false</useFile>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
XIA YUN
@unxia
Hi, I'm looking for a way to inject spring bean into spock interceptor to prepare data , kind of like https://github.com/janbols/spock-dbunit, but using spring to do it
Alexander Kriegisch
@kriegaex
@liubo404, oh, you cross-posted from a Spock issue. In that case, a link would have suficed, no need to copy & paste everything here. Anyway, I am happy you solved your build configuration problem. Of course, you canot combine Groovy 3 with Spock for Groovy 2.5 or the other way around. You need to use the Groovy and Spock artifacts which match with each other. In your case, you chose to keep Groovy 2.5 and adjust Spock to it. The other way would have been to upgrade to Groovy 3.

@unxia, have you tried using Spock's Spring integration?
https://spockframework.org/spock/docs/2.0/all_in_one.html#_spring_module

If something is not working as expected there, it would make sense to publish an MCVE on GitHub in order to illustrate your problem. Writing one sentence, saying "I want to do A, similar to project B" does not quite precisely describe your problem.

liubo404
@liubo404
@kriegaex thanks, I'll try to upgrade to 3.0
陆龟
@xialugui
@liubo404 Spock的依赖很迷,即使你的版本是2.0-groovy-3.0,他的groovy版本也会是2.5。
Alexander Kriegisch
@kriegaex

@liubo404 Spock的依赖很迷,即使你的版本是2.0-groovy-3.0,他的groovy版本也会是2.5。

Like I said, this is not supposed to work and the Spock artifact should fit the Groovy version.

liubo404
@liubo404
@xialugui 多谢,刚开始学spock测试..版本确定很迷
force to use the 3.0 version
image.png
liubo404
@liubo404
I close this issue spockframework/spock-example#44
there @szpak recommented a elegant way to solve the version problem,
Overriding Dependency Versions with Spring Boot
Explicitly manage only the Groovy version via a property in maven
thanks
Juliane Hochstein
@exwima
Hi there, I'm new here. I'm trying to use the Spock Web Console at https://meetspock.appspot.com/ with the given example MyFirstSpec, but I'm getting an error message "Error interacting with the Spock Web Console server: error". Does anoyone know about this? I used the Spock Web Console at appspot sometimes during summer and it worked fine then.
Leonard Brünings
@leonard84
@exwima please try the new version https://gwc-experiment.appspot.com/
Juliane Hochstein
@exwima
@leonard84 That seems to work, thanks!
@leonard84 Is there an option to start with a Spock Test already given? And could you put the new URL into #1321 , too? That would be helpful.
Leonard Brünings
@leonard84
look at the section "sharing scripts", for how to provide prefilled data
Juliane Hochstein
@exwima
Ah, thanks!
Juliane Hochstein
@exwima
(My error, just pasted a Spock example in the Groovy Web Console and tried if it runs. The information about linking example scripts is right there if you read the page...)
I'm trying to give a short presentation about Spock in a course and wanted to refer to the web console if somebody wants to give it a first try. It's easier if there is already a short Spock test given, so I'll probably try to add an example for my fellow students. Thanks for the new URL!
Leonard Brünings
@leonard84
@exwima if you haven't seen it, there is also the Share as Linkbutton that will encode the current script into an url so that you can easily share it.
Juliane Hochstein
@exwima
Thanks again. :-)
emma.hi
@emma.hi:matrix.org
[m]
Hey, anyone know how to create unit test for service (grails 2.5.4)? I have tried to create TestServiceSpec and call some method in the service. Got this error --> No tests found in {packageName}.TestServiceSpec
Quinn
@qtpeters
Can anyone point me to where the versioning for the Spock Framework is explained? What does this actually mean: 1.2-groovy-2.4? Spock 1.2 FOR Groovy 2.4?
1 reply
Tor-Nets
@Tor-Nets
How do i set defaultExecutionMode for spock? I can find absolutely no documentation on this...
1 reply
Jegors Čemisovs
@rabestro
How to properly use CSV file for parameters?
DimitrisMetaxakis
@DimitrisMetaxakis
Hi guys, i am new here and Junior QA tester. I am trying to setup my InteliJ for Geb and Spock with Groovy. Watched many tutorials but most of them are outdated. Does anyone has Links or knows something so i can setup my InteliJ?
DimitrisMetaxakis
@DimitrisMetaxakis
Thanks a lot, it was a really fast response ! :)
James Hardwick
@jamesdh
Hey guys, we're experiencing a really bizarre problem I thought I'd just throw out here to see if anyone might have any pointers we could try before creating a full-blown GitHub issue and project containing the failing example....
James Hardwick
@jamesdh
We have an asynchronous integration test against a GCP PubSubEmulator running via TestContainers. We @SpringSpy the bean that receives the message. Occasionally this test fails with "too few invocations" on the spied on bean. Upon further inspection, when it fails, the bean appears as class GCPPubSubReceiver and when it passes, as class GCPPubSubReceiver$SpockMock
James Hardwick
@jamesdh
Strangely enough, if running with IntelliJ's debugger on the gradle test task, the test passes every time. If running via gradle via CLI or within IntelliJ without the debugger, it fails most of the time on our dev machines, but passes in CI.
If running the test solo, regardless of debug/run mode, it passes every time.
James Hardwick
@jamesdh
It appears that if another test which @Autowired the same bean runs first, then the 2nd test that uses @SpringSpy doesn't actually get the SpockMock
But if the test containing the @SpringSpy runs first, then it does
James Hardwick
@jamesdh
So this ended up being unrelated to Spock. Had to do with the fact @SpringBootTest would launch a new application context with every spec, and therefore multiple instances of our subscribing bean would be registered with the PubSub emulator and could continue to receive messages even though our tests had moved on to an entirely different context and instance of the same bean. That in turn meant that the wrong bean may actually receive the message, and hence too few invocations.
Sergey Teplov
@serjteplov

Hi there!
I have a bug suggestion regarding using of DetachedMockFactory to test spring-cloud-stream functions.
When spring test context is created by TestChannelBinderConfiguration and depency is created by DetachedMockFactory, the mocking itself didn't happen. Mock has been created, but method call isn't. Here is screenshot: https://i.stack.imgur.com/4G74V.png

In the test wrote via junit5 all is good and working.
I created sample project to demonstrate this issue: https://github.com/serjteplov/demo-kafka-mock.git

8 replies