Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scenarios should be referenced by their name rather than line number #2522

Open
arnaldop opened this issue Mar 3, 2024 · 0 comments
Open

Comments

@arnaldop
Copy link

arnaldop commented Mar 3, 2024

(Original ticket here: karatelabs/intellij-plugin#32)

When running a single scenario, the framework (including the IntelliJ plugin) references the scenario by its line number. This creates issues when the scenario's definition line moves up or down due to code changes above it.

Ideally, given the file below, rather than using the line number, which can change:

-Dkarate.options=classpath:path/to/features/feature.feature:9"

we should do something like this:

-Dkarate.options=classpath:path/to/features/feature.feature:'Line changing scenario # this line number must change'"

Steps:

  1. Using scenario file 1 below, run the 2nd scenario.
    • This can be done with keyboard shortcuts, using the gutter shortcut or by right-clicking on the scenario and selecting "Run...".
  2. Scenario passes.
  3. Change the file in any way such that the 2nd scenario is on a different line number, higher or lower.
  4. ACTUAL: Scenario will not be found, and thus the test shows up as "Terminated".
    • EXPECTED: Scenario would be run by name, and thus would be found regardless of line number, as long as scenario name was unchanged.

Failure variation:

  1. Run first test as normal.
  2. Alter the file in such a way that the IntelliJ auto-formatter will alter the file.
    • Example: add 3 blank lines in between 1st and 2nd scenario.
  3. Run the 2nd scenario by gutter or keyboard shortcut or right-click.
  4. IntelliJ Karate Plugin is triggered to run based on current file conditions.
  5. When the Run window receives focus, the auto-formatter is triggered.
  6. The 2nd scenario moves up.
  7. ACTUAL: Scenario will not be found, and thus the test shows up as "Terminated".
    • EXPECTED: Scenario would be run by name, and thus would be found regardless of line number, as long as scenario name was unchanged.
Feature: A simple Karate test that always passes

  Scenario: Dummy Test

    * def foo = 1234
    * def bar = 1234
    * match foo == bar
# variations on this empty space will cause the issue
  Scenario: Line changing scenario # this line number must change

    * def foo = 1234
    * def bar = 1234
    * match foo == bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant