Skip to content

Is it possible to use java-snapshot-testing with Cucumber (features and steps) and Junit4? #167

Description

@maastha

Since Cucumber has its own test runner; annotating on the step class won't extend or change the cucumber test runner to be able to inject Expect expect instance variable.

Could you please share guidance/example of how to use this library in Cucumber steps?
Expect expect = Expect.of() requires a java.lang.reflect.Method method which I don't think is accessible in Cucumber steps.

Activity

  1. jackmatt2 commented on May 13, 2024

    @jackmatt2
    Collaborator

    I have never tried this library with Cucumber.

    Cucumber uses shared steps with actual tests being written in Gherkin syntax. As there is no uniqueness with the Java Test method it won't be able to identify the comparator test correctly. You would be forced using @SnapshotName or an equivalent to uniquely identity each test - this may require some small modifications to java-snapshot-testing.

    So unfortunately, unless you implement Gherkin integration and annotation it probably won't work.

    You might be able to hooking the "Scenario" keyword for the snapshot name

  2. locked and limited conversation to collaborators on May 13, 2024
  3. converted this issue into a discussion #168 on May 13, 2024
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