Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 23 11:19
    kriegaex commented #1333
  • Jun 22 22:18
    leonard84 commented #1352
  • Jun 22 17:22
    rtretyak commented #1352
  • Jun 22 17:17
    rtretyak edited #1352
  • Jun 22 17:14
    rtretyak labeled #1352
  • Jun 22 17:14
    rtretyak opened #1352
  • Jun 22 04:41
    kriegaex commented #1351
  • Jun 21 15:33
    leonard84 commented #1351
  • Jun 21 15:15
    kriegaex commented #1351
  • Jun 21 12:56
    leonard84 labeled #1351
  • Jun 21 12:56
    leonard84 unlabeled #1351
  • Jun 21 12:56
    leonard84 closed #1351
  • Jun 21 12:56
    leonard84 commented #1351
  • Jun 21 00:18
    kriegaex opened #1351
  • Jun 21 00:18
    kriegaex labeled #1351
  • Jun 19 10:51
    leonard84 commented #1345
  • Jun 19 10:50

    leonard84 on master

    Build MethodSource with the cor… (compare)

  • Jun 19 10:50
    leonard84 closed #1345
  • Jun 19 10:00
    leonard84 edited #1345
  • Jun 18 18:55
    leonard84 review_requested #1345
Björn Kautler
@Vampire

https://twitter.com/spockframework/status/1377558567130107906

We have been advised of a copyright issue with the Spock name, to avoid future problems in this regard we have decided to rebrand. Henceforth, the Spock Framework will be renamed to GWT Framework (Given-When-Then).
Read the full announcement here https://spockframework.org/rebrand-announcement.html

spartanhooah
@spartanhooah

I'm taking a class on Reactive Spring, and I've been able to use Spock no problem so far, but now there's a test using StepVerifier.withVirtualTime() and it passes no matter what. Here's the whole test:

def "With virtual time"() {
    given:
    VirtualTimeScheduler.getOrSet()
    def longFlux = Flux.interval(Duration.ofSeconds(1))
        .take(3)
        .log()

    expect:
    StepVerifier.withVirtualTime({ longFlux.log() })
        .expectSubscription()
        .thenAwait(Duration.ofSeconds(3))
        .expectNext(0L, 1L, 2L)
        .verifyComplete()
}

I also don't see the logs from the flux. Any ideas?

Leonard Brünings
@leonard84
IIRC you need to create the flux inside the withVirtualTime method, see https://www.baeldung.com/reactive-streams-step-verifier-test-publisher#3-testing-time-based-publishers as an example. Also you don't need VirtualTimeScheduler.getOrSet()AFAIK.
spartanhooah
@spartanhooah
That's true, don't need VirtualTimeScheduler.getOrSet(), thanks.
kwangomango
@kwangomango
Is it possible to put Spock conditions in an external helper class and still get Spock to raise ConditionNotSatisfiedException? Any asserts i have in external helper methods just get treated like regular Groovy asserts.
class Testy extends Specification {

    Helper helper = new Helper()

    void "testy"() {

        expect:
           verify()
           helper.verify()

    }


    void verify() {  
        assert 1 == 2
    }
}

class Helper {

    void verify() {
        assert 1 == 3
    }
}
Leonard Brünings
@leonard84
No it is not possible, Spock only transforms classes derived from Specification. You might have a pseudo-Specification without any actual tests and only helper methods though.
kwangomango
@kwangomango
Thanks Leonard, so you are saying to have my Helper class extend Specification too? I see that works.
Leonard Brünings
@leonard84
yes
kwangomango
@kwangomango
:thumbsup:
Leonard Brünings
@leonard84
You can't have external mock interactions though
kwangomango
@kwangomango
That's fine, i'm mostly using Spock for integration tests on apis.
If i make the external helper a closure, rather than a method, then it works just like a local method on Specification. Why is that?
class ClosureTest extends Specification {

    Helper helper = new Helper()

    void "testy"() {

        expect:
            verify.call()
    }

}

class Helper {

    Closure verify= { assert 1 == 2 }

}
Vahid Pazirandeh
@vahidpaz
What http client normally blends well with Spock website functional testing? I've looked at a few (httpbuilder, httpbuilder-ng) and I like their syntax (httpbuilder is nice) bit those projects are either abandoned or dormant. I'd like to use something actively support. thx
Leonard Brünings
@leonard84
you could use https://rest-assured.io/ although it has its own when-then methods
Vahid Pazirandeh
@vahidpaz
Yes I noticed it does. It looks to be an all-inclusive library, even allowing groovy syntax in strings (I guess that it eval()'s on). I'll play around and see if there's a happy middle-ground
Vahid Pazirandeh
@vahidpaz
@leonard84 - thank you for all the time/effort you put in for Spock. It's a real blessing for people around the world.
Leonard Brünings
@leonard84
thanks
Björn Kautler
@Vampire
@vahidpaz I heard and read very good things about Geb and it is nicely integrated with Spock too.
Leonard Brünings
@leonard84
Geb is for browser testing, I assumed the question was geared towards REST API testing
Björn Kautler
@Vampire
Which part of "website functional testing" makes you think so?
"i'm mostly using Spock for integration tests on apis" was a different user one message earlier
Leonard Brünings
@leonard84
Well, since the listed frameworks where http clients and not selenium/webdriver, I assumed testing should be done on the http/rest layer.
If you want browser tests, then sure Geb is the best choice for Spock.
Vahid Pazirandeh
@vahidpaz
@Vampire thank you for the info. Yes I was referring to rest api testing but when the time comes to sprinkle some web app UI testing (some call it user acceptance tests?) I will take a look at Geb. thx again
Luke Last
@lukelast
How do I set defaultExecutionMode=SAME_THREAD?
For spock 2.0
Alexander Kriegisch
@kriegaex
Copy from the linked test:
      runner {
        parallel {
          enabled true
          defaultSpecificationExecutionMode ExecutionMode.SAME_THREAD
          defaultExecutionMode ExecutionMode.SAME_THREAD
        }
      }
Leonard Brünings
@leonard84
Luke Last
@lukelast
Thank you Alexander! I hadn't found that example config. What ended up working for me was defaultExecutionMode org.spockframework.runtime.model.parallel.ExecutionMode.SAME_THREAD
Also, yay spock 2.0 and congrats!
sma-ops
@sma-ops
Hi. After seting up the pock project for idea (via ./gradlew cleanIdea idea), I try to run some tests, e.g., ./gradlew spock-core:test. But there does not seem to happen anything.

DESKTOP-CIDB3LU MINGW64 /e/projects/spock (master)
$ ./gradlew spock-core:test

Configure project :spock-core
[versioning] WARNING - the working copy has unstaged or uncommitted changes.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
5 actionable tasks: 5 up-to-date

A build scan was not published as you have not authenticated with server 'ge.spockframework.org'.

let me know if the question should be put somewhere else (its probably not a bug, but too specific for stackoverflow)
Leonard Brünings
@leonard84
spock uses build caching, so if you didn't change anything it will not execute any tasks that are already cached
you can try cleaning and then running with --no-build-cache, or change some code locally
sma-ops
@sma-ops
That does not help. I also changed some test files.
but it does not seem to pick up the change
wait, yes that worked. I was just changing things in the wrong test folder - thanks!
Nick Bensema
@unbibium
is there a clean way to write a "where" block that loads all combinations of two variables, given only the two lists? like a way to do "foo << [1,1,1,2,2,2,3,3,3]" "bar << [4,5,6,4,5,6,4,5,6]" without repeating the numbers?
a cartesian product, if you will. Maybe even with 3 properties.
Leonard Brünings
@leonard84
Nick Bensema
@unbibium
ah, ok. that should be pretty close.
all I needed was something like [foo,bar] << [ [1,2,3] , [4,5,6] ].combinations
Nick Bensema
@unbibium
i do wish i could change the order of loops so that the 1,2,3 column is the outer loop, but this will get me most of the way
Alexander Kriegisch
@kriegaex
You should not rely on the order of features or order of iterations within a feature. But would something like this do?
[[1,2,3], [4,5,6]].combinations()
# [[1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6]]

[[1,2,3], [4,5,6]].combinations().sort()
# [[1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6]]
For illustration:
[3, [1], [2], 1, [1,2], [1,1], [1,2,3], [1,2], 2, [1,2,2], [3]].sort()
# [1, 2, 3, [1], [2], [3], [1, 1], [1, 2], [1, 2], [1, 2, 2], [1, 2, 3]]
Alexander Kriegisch
@kriegaex
Otherwise you can call sort with a custom comparator, if you think it is worth the effort.
woodgiraffe
@woodgiraffe
hi, I'm looking for a way to pass a list of closures that are expected to all throw the same type of exception and verify this behavior without writing feature methods for every single one, I'd welcome any pointers that can put me in the right direction
Alexander Kriegisch
@kriegaex
Please post your code, explain what you tried and what is different from your expectation.