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

@setup scenarios run even when Feature is skipped #2169

Closed
edwardsph opened this issue Nov 3, 2022 · 3 comments
Closed

@setup scenarios run even when Feature is skipped #2169

edwardsph opened this issue Nov 3, 2022 · 3 comments
Assignees

Comments

@edwardsph
Copy link
Contributor

I discovered this in 1.3.0RC2 minutes after 1.3.0 was released and have upgraded to confirm it still an issue.

I created a feature:

@test
Feature: sample karate test script
  Background:
    * url 'https://jsonplaceholder.typicode.com'

  @setup
  Scenario: setup
    * table tests
      | test    |
      | 'users' |

  Scenario Outline: get all <test>
    Given path '<test>'
    When method get
    Then status 200

    Examples:
      | karate.setup().tests |

If I run this without skipping any tags it reports:

features:     1 | skipped:    0 | efficiency: 0.05
scenarios:    2 | passed:     2 | failed: 0

image

Problem 1: Ideally a @setup scenario would not be included in the counts as it is misleading. It is only run for the benefit of the other scenario.

If I then run with .tags("~@test") it reports:

features:     1 | skipped:    0 | efficiency: 0.00
scenarios:    1 | passed:     1 | failed: 0

image

Problem 2: This is even more misleading since I wouldn't want any scenarios to count, nor should the feature be counted

If I convert it to a standard scenario with no @setup and run it with the tag skipped the results are:

features:     0 | skipped:    1 | efficiency: 0.00
scenarios:    0 | passed:     0 | failed: 0

image

This is what I would expect in the second case.

I think it makes sense to show the @setup scenario results in the report but it makes less sense to have it included in test results counts and to impact feature counts in the way it does.

@ptrthomas ptrthomas self-assigned this Nov 3, 2022
@ptrthomas ptrthomas added the bug label Nov 3, 2022
@ptrthomas ptrthomas added this to the 1.4.0 milestone Nov 3, 2022
@ptrthomas
Copy link
Member

@edwardsph thanks for raising this, I was able to fix the .tags("~@test") case. but I'm still stuck trying to get the reports to not be counted. I'm exploring the option of adding a "fake" first step and treating the @setup like a call. will sleep on it

ptrthomas added a commit that referenced this issue Nov 3, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@ptrthomas
Copy link
Member

@edwardsph just made a commit. would be great if you could build-locally and put it through some examples. I think table does not collapse in the HTML report, but other than that - please see if this is a reasonable solution.

we can collect tips on how the Karate HTML report can be improved, we hope to do a clean-up in the next version.

@ptrthomas
Copy link
Member

1.3.1 released

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

No branches or pull requests

2 participants