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

Assume/Abort in sub Steps creates Passed Scenario in the report with odd count of Steps/Skipped #314

Closed
lunmag opened this issue Jul 28, 2023 · 11 comments · Fixed by #317
Closed
Assignees
Milestone

Comments

@lunmag
Copy link

lunmag commented Jul 28, 2023

Describe the bug

Hi!

Related to #299 in a way...
When an Assume/Abort - statement is made to stop the Scenario if needed, the Scenario-status in the @After-part (scenario.getStatus()) says SKIPPED.

However, I only get a Skipped Scenario in the report if there are no (zero) successful Steps completed.
If one or more Steps are completed before the Assume/Abort takes place, the Scenario is Passed in the Report.
Also, it does not calculate the skipped steps correctly, well , I added two snapshots for a look.

To Reproduce
Steps to reproduce the behavior:

Create a Feature with at least two Steps

Perform a
assumeTrue(false,"Oh No");
or
org.junit.jupiter.api.Assumptions.abort("stopping after a few steps");

at
Test 1/ the first Step of the Feature
Test 2/ the last Step of the Feature

1 => Skipped
2 => Passed

Expected behavior
I'd assume, :-) , that since the scenario.getStatus() reports SKIPPED, I'd get Skipped scenarios in both cases in the Report.

Attachments
2 Scenarios with Assume/Abort done in sub steps of their Features.

Screenshot 1
Screenshot 2

** Note **
Cucumber 7.11.1, JUnit 5.9.3

@bischoffdev bischoffdev self-assigned this Aug 1, 2023
@bischoffdev
Copy link
Collaborator

Thank you for reporting, I will look into this.

@bischoffdev bischoffdev added this to the 3.3.0 milestone Aug 2, 2023
@bischoffdev
Copy link
Collaborator

bischoffdev commented Aug 2, 2023

A scenario is considered skipped when all steps are skipped. When there are passing steps before it is considered passed. This is according to the official Cucumber guidelines.

(see issue #283)

Could you send me the JSON result file of your use case so I can check this better?

@lunmag
Copy link
Author

lunmag commented Aug 2, 2023

Hi!
Thanks for quick handling!
Added .txt to JSON (It contains an image too, but should be ok)

Console-Out.txt
cucumber.json.txt

@bischoffdev
Copy link
Collaborator

Your example shows a passed step and then a skipped one. According to the Cucumber specs, this is considered passed.

@bischoffdev
Copy link
Collaborator

Also the step counts seem to be correct here.

@mpkorstanje
Copy link

@bischoffdev the state of a scenario is the most severe status of it's steps. But I didn't look at the json, maybe I'm reading your comment wrong.

https://github.com/cucumber/cucumber-jvm/blob/main/cucumber-core/src/main/java/io/cucumber/core/runner/TestCaseState.java#L54

@lunmag
Copy link
Author

lunmag commented Aug 3, 2023

I just tried Allure-reporting and got this for an Assume()/Abort() operation:
(w/o any claims of what is wrong or right, just as info)

image

@bischoffdev
Copy link
Collaborator

@mpkorstanje this is interesting. What does "the most severe" status mean concretely?

I know the status constants are

PASSED,
SKIPPED,
PENDING,
UNDEFINED,
AMBIGUOUS,
FAILED,
UNUSED

Would that mean that any step status that is lower down the list than any other steps in the scenario determines the scenario status? If so, this is new info. I remember getting my initial info from the Cucumber Slack.

E.g.

Step 1: passed
Step 2: skipped
Step 3: skipped

=> Scenario is skipped?

According to my former info, this would be considered passed.

@bischoffdev bischoffdev removed this from the 3.3.0 milestone Aug 4, 2023
@mpkorstanje
Copy link

mpkorstanje commented Aug 5, 2023

Yes, this specific example the scenario would be skipped.

Not sure what you got from Slack. I do remember this conversation:

https://cucumberbdd.slack.com/archives/C60TKS3SL/p1532961939000185?thread_ts=1532961939.000185&cid=C60TKS3SL

I think you interpreted the comment about scenario no. 3 as me saying the scenario passed. Rather the scenario is skipped, the execution of cucumber is passed (i.e. a zero exit code if this was the only scenario executed).

It is worth nothing that strict mode is default now and non-strict has been removed. So things are much simpler now.

@bischoffdev
Copy link
Collaborator

Ah cool! So I will refine the state handling again and adjust it to the official way. Thanks for your input!

@bischoffdev bischoffdev added this to the 3.3.0 milestone Aug 7, 2023
@bischoffdev
Copy link
Collaborator

Ready to release in v3.3.0

@bischoffdev bischoffdev linked a pull request Aug 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants