Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 26 23:46
    szpak commented #1382
  • Jan 26 23:12
    szpak commented #1382
  • Jan 26 23:12
    szpak commented #1382
  • Jan 26 22:37
    codecov[bot] commented #1382
  • Jan 26 22:36
    codecov[bot] commented #1382
  • Jan 26 22:36
    codecov[bot] commented #1382
  • Jan 26 22:36
    codecov[bot] commented #1382
  • Jan 26 22:35
    szpak synchronize #1382
  • Jan 26 22:33
    codecov[bot] commented #1382
  • Jan 26 22:32
    codecov[bot] commented #1382
  • Jan 26 22:32
    codecov[bot] commented #1382
  • Jan 26 22:32
    codecov[bot] commented #1382
  • Jan 26 22:32
    codecov[bot] commented #1382
  • Jan 26 22:31
    codecov[bot] commented #1382
  • Jan 26 22:31
    codecov[bot] commented #1382
  • Jan 26 22:28
    codecov[bot] commented #1382
  • Jan 26 22:28
    szpak synchronize #1382
  • Jan 26 22:25
    codecov[bot] commented #1382
  • Jan 26 22:23
    codecov[bot] commented #1382
  • Jan 26 22:23
    codecov[bot] commented #1382
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
Vladimir Orany
@musketyr
Hi, I'm finally migrating to 2.0 (sight) and I'm facing a following issue: I have existing trait with methods annotated with @Before and @After which got executed before/after feature method calls in 1.3 but when I migrate the project to 2.0 and change the annotations to @BeforeEach and @AfterEach then these method are ignored. Am I missing something?
Vladimir Orany
@musketyr
thanks @kriegaex! I wonder if this is something new - I can’t see it in the 1.3 documentation. anyway I’ll try to figure another approach then.
Alexander Kriegisch
@kriegaex
Besdides, if you are talking about @Before* and @After* annotations from JUnit, you are not meant to use those in connection with Spock at all, mixing two technologies. Spock has its own mechanisms to cover those topics, namels setup, setupSpec, cleanup, cleanupSpec methods.
Well, the Spock 2 manual just mentions it because it is some kind of FAQ, but actually it is a Groovy issue, not a Spock one.
So it is not new at all
If it worked in 1.3., you were just lucky. Even more so if you mixed Spock with JUnit 4 annotations.
It was wrong to use them to begin with.
Maybe you want to read the excellent Spock manual, you will find all this information and much more in there. But of course it is fine to ask here, too.
Vladimir Orany
@musketyr

well, JUnit annotations were supported since 0.6

https://spockframework.org/spock/docs/2.0/all_in_one.html#_junit_fixture_annotations

and traits were the base of the Grails testing support

https://github.com/grails/grails-testing-support/tree/master/grails-web-testing-support/src/main/groovy/grails/testing/web

traits + JUnit annotations worked well and I was able to avoid writing custom extensions.

I will re-read the docs. I can see there’s a lot of useful new stuff since the time I first read it.

Krystian Matysiak
@KrystianMatysiak

Hello everyone,

I'm struggling with Spock test inheritance problem. Basically I would like to create DomainEntitySpec class containing abstract methods which has to be overriden in concrete Spec classes:

abstract class DomainEntitySpec extends Specification {

abstract def "should throw validation error"()

abstract def "should create minimal object"()

}

class SendAllocationCostsRequestSpec extends DomainEntitySpec {

def "should throw validation error"() {

...
}

However I got:
Can't have an abstract method in a non-abstract class. The class 'com.ista.ade.gateway.domain.allocationcost.entity.SendAllocationCostsRequestSpec' must be declared abstract or the method 'java.lang.Object should create minimal object()' must be implemented.
@ line 12, column 1.

Alexander Kriegisch
@kriegaex
@KrystianMatysiak: The error message tells you what to do: You need to implement both abstract nethods in your concrete spec, not just one of them. As far as I can see from your fragmentary code, this is a basic Java or Groovy problem, completely unrelated to Spock.
Leonard Brünings
@leonard84
Johannes Gottschalk
@johannesgottschalk
Hi everyone, my name is Johannes. I am a test engineer who likes to work with Spock. I would very much like to contribute to the development of the framework and would like to know, what would be the most helpful way that I could contribute. From testing to coding I am happy to do what ever is needed and am looking forward to hear from you. Kind regards 🦄
2 replies
Alpharius12
@Alpharius12
Hey everyone, just quick question if I may. I started using spock recently for testing purposes and I am just wondering does spock support annotations like one that we can find in testng? Example: @Test({groups = Api, Slow, Fast}, description = "some clever description")
Or I need to create something like this using spockconfig? Thank you!
2 replies
DmitriyShakshin
@DmitriyShakshin
Hello everyone! Could you help me with CompileStatic? I have a problem with Adopt OpenJDK 11, Spock 2.0.0, Groovy 3.0 and Static Compile Tests. I can't use inner static builder class. Also I got exception unknown variables when i use parametherized tests
2 replies
pdargel
@pdargel
Hey, I'm new to spock and just read the documentation. I tried the @Issue extension with a valid url but nothing happened. What is supposed to happen there? should the url be part of the output if the feature fails? Is there a way to get Intellij to recognize them?
1 reply
venky
@venky6669
Hi Team, Does anyone know what versions of Groovy and spock are compatible with JDK 17 ?
1 reply
allforone
@allforone
哪位老哥给个和spring融合的demo
2 replies
Boris Petrov
@boris-petrov

Hi all, I'm having troubles with additionalInterfaces. Using 2.1-M2. I don't understand why this doesn't call the method foo:

    class A {}
    class B {}
    interface C { B foo() }
...
        def a = Stub(A, additionalInterfaces: [C]) {
            foo() >> { println 2; new B() }
        }
        println(a instanceof C)
        def b = a.foo()
        println b.getClass()

This prints true and then class java.lang.Object. 2 is not printed. Why isn't this calling my stubbed method?!

26 replies
I hit this trying to debug another issue with additionalInterfaces where the method is called and I return a nice value but I get a NPE in org.spockframework.gentyref.GenericTypeReflector:73- java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "type" is null.
balavivek143
@balavivek143

Hello Every one.. We are using spock core version 1.3-groovy-2.5 version and running few of our SpringBootTest using EmbeddedSpecRunner.groovy with RunListeners.

EmbeddedSpecRunner runner = new EmbeddedSpecRunner();
runner.setListeners(Collections.singletonList(new TextListener(System.out)));

When we are upgrading to 2.1-M2-groovy-3.0, we are seeing setListeners are not available ! also seeing in the source code, listener array variable got removed in the commit 693832c3cfaeebf349025002561acc556d7dbcae

Now how to add any run listener with EmbeddedSpecRunner ?

1 reply
Juliane Hochstein
@exwima
Hi everyone! As a part-time student in computer science, I wrote a short paper about Spock for university last term and really liked how it made me think about writing tests. :-) So somehow I volunteered to give a talk about Spock in a public lecture series at the city library of Stuttgart, Germany. Due to the pandemic, the talk will now happen online on this thursday, see https://www.cccs.de/events/202201-testframework-spock/ (text in German, like my talk). Maybe someone here is interested? Please note: I am really no expert in programming or unit testing and still a beginner at Spock myself, so the talk will only be a basic introduction for other people who might be interested in learning about Spock, too.
5 replies
Roland Tepp
@roland-tepp:matrix.org
[m]

Hi, I am getting a weird issue with Spock where as soon as I declare throws in my then: block, the test starts to fail with a NullPointerException.

If I remove the throws assertion, the test fails with the expected (UnsupportedOperationException) exception as it should.

Leonard Brünings
@leonard84
It is probably caused by some re-ordering caused by the throws special handling, but without any sample code I can't help you. You can however use https://gwc-experiment.appspot.com/ to look at the AST to see the transformed code and where the issue is.