Skip to content

@Stepwise does not automatically trigger previous features anymore with Spock 2.x as well as with Gradle 2.12+ #1593

Closed

Description

@dartilla

After transition from spock1 to spock2 @stepwise functionality is lost (suspect junit4 to junit5 transition)

See spock.lang.StepwiseExtensionSpec.

Try to execute 'step 3'. No 'step 1' and 'step 2' executed at all.
Checked on 1b0b6764 and 5398f5eb

Activity

  1. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    This is not different from Spock 1 though, is it?
    Afair @Stepwise always only affected the order, not which tests are executed.

  2. dartilla commented on Mar 9, 2023

    @dartilla
    Author

    Yes Spock is not different.

    But Spock-2xx has moved to junit5 from junit4
    I think it is integration problem with junit5.

    But @stepwise is do affect which tests are executed, not the order see javadoc.
    " Also notice that if you run a single step (e.g. from the IDE's context menu), all prior steps will also be run."

    • this is exactly my case

    /**

    • Demonstrates how {@code @stepwise} causes a spec to be run in incremental steps.
    • Change a step's condition from {@literal true} to {@literal false}, and observe
    • how the remaining steps will be skipped automatically on the next run.
    • Also notice that if you run a single step (e.g. from the IDE's context menu),
    • all prior steps will also be run.
    • {@code @stepwise} is particularly useful for higher-level specs whose

    • methods have logical dependencies.
    • @SInCE 0.4
      */
      @stepwise
      class StepwiseExtensionSpec extends Specification {
  3. changed the title [-]spock 2.1 @Stepwise not work[/-] [+]spock 2.1 @Stepwise not work (junit5 issue?)[/+] on Mar 9, 2023
  4. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    Well, seems that comment is wrong.
    If you checkout the spock-1.x branch which is the last commit before switching to Spock 2.x you see that it behaves exactly the same, just as I said. :-)
    If this ever worked like mentioned in the comment, then this changed even longer ago.

  5. dartilla commented on Mar 9, 2023

    @dartilla
    Author

    2023-03-09_18-56-39
    Comment is not wrong. Just checked it in 7d231048 - last commit in spock-1x branch.
    Use case:

    1. Open StepwiseExtensionSpec
    2. Execute step3 only.
    3. Confirm that step1 then step2 then step3 executed
  6. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    It's not a Spock 1 vs. Spock 2 issue.
    The behavior is identical between spock-1.x branch and master.
    If you delegate the test execution in IntelliJ to Gradle, only step 3 is executed.
    If you do not delegate test execution in IntelliJ to Gradle, all three steps are executed.
    I did a little bisect, this broke with commit spockframework/spock-example@3d454b9 which changed Gradle version from 2.8 to 3.2.1.
    So something in Gradle changed that makes this not work any longer.
    I narrowed it down further, with Gradle 2.11 it still worked, with Gradle 2.12 it does not work anymore.

    I'm transferring this issue to the main spock repository where it belongs.

  7. changed the title [-]spock 2.1 @Stepwise not work (junit5 issue?)[/-] [+]@Stepwise does not trigger previous features when run through Gradle since Gradle 2.12[/+] on Mar 9, 2023
  8. changed the title [-]@Stepwise does not trigger previous features when run through Gradle since Gradle 2.12[/-] [+]@Stepwise does not automatically trigger previous features when run through Gradle since Gradle 2.12[/+] on Mar 9, 2023
  9. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    Running through Maven also does not trigger the previous features

  10. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    Ah, sorry, I probably made too many different tests.
    Indeed now master without Gradle delegation also only runs step 3 here.

  11. changed the title [-]@Stepwise does not automatically trigger previous features when run through Gradle since Gradle 2.12[/-] [+]@Stepwise does not always automatically trigger previous features[/+] on Mar 9, 2023
  12. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    So to summarize:

    Gradle 2.11 + Spock 1.0 => works
    Gradle 2.12 + Spock 1.0 => does not work
    IntelliJ (without Gradle delegation) + Spock 1.3 => works
    IntelliJ (without Gradle delegation) + Spock 2.0 => does not work
    Maven 3.6.0 + Spock 1.3 => works
    Maven 3.6.0 + Spock 2.0 => does not work

    So changes in Spock 2.0 made it break and additionally changes in Gradle 2.12 made it break.

  13. changed the title [-]@Stepwise does not always automatically trigger previous features[/-] [+]@Stepwise does not automatically trigger previous features anymore with Spock 2.x as well as with Gradle 2.12+[/+] on Mar 9, 2023
  14. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    @marcphilipp can you maybe have a look?
    We have a test using a MethodSelector that works perfectly fine.
    But when for example testing a Maven-run, only the ClassSelector comes in.
    So without too much deeper analysis, I'd guess they only use the ClassSelector and do the method filtering themselves somehow which then breaks this Spock functionality.
    But can it really be that Maven, Gradle, and IntelliJ use JUnit platform incorrectly and all cause the same issue here?
    Or is there something Spock can do to fix this?

  15. Vampire commented on Mar 9, 2023

    @Vampire
    Member

    Yep, all three let JUnit Platform only filter for the right class and then use a post-discovery filter instead of a method selector to select the requested test. Maybe also because some support patterns like step*.

    I'm not sure Spock can do much about this without significant effort.

  16. leonard84 commented on Mar 10, 2023

    @leonard84
    Member

    Yes @Vampire is right, unless we break/ignore the JUnit Platform Execution model we can't fix this in Spock. If the tools would use the proper MethodSelector then Spock also adds the necessary methods back in, however they remove the nodes after the discovery.

  17. Vampire commented on Mar 10, 2023

    @Vampire
    Member

    Well, I wouldn't (and didn't) say "we can't fix".
    We can also dynamically add test nodes for data driven tests, so at least with some effort we could most probably also execute those features even if they fell through the post discovery filter.

  18. leonard84 commented on Mar 10, 2023

    @leonard84
    Member

    It is not something that an extension, like @Stepwise, can do at the moment.

    I'm not saying it is impossible to do, but they will be awkward workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions