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

If there is Background and 2 or more tests, if 1 test failed the others are also marked as failed. #23

Closed
vitaliirymar opened this issue Feb 27, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@vitaliirymar
Copy link
Contributor

vitaliirymar commented Feb 27, 2024

Describe the bug
In a scenario outline with examples, if 1 example passed and another one failed, the report shows 2 failed tests

Steps to Reproduce
Steps to reproduce the behavior:

  1. Run Scenario Outline with at least 2 Examples where one of them fails.
    E.g.
    Scenario Outline: Verify math
    Given def mathResult = < vara > + < varb >
    Then assert mathResult == < result >

    Examples:
    | vara | varb| result |
    | 2 | 2 | 4 |
    | 1 | 2 | 5 |

  2. Check ReportPortal results

Expected behavior
ReportPortal displays 1 passed test and 1 failed test

Actual behavior
ReportPortal displays 2 failed tests
The passed test is marked as a failed, but without failed steps and without error log inside the steps.

Dependency versions
agent-java-karate 5.0.0

Bug_2_failed_tests_when_1_passed_and_1_failed
Bug_2_failed_tests_when_1_passed_and_1_failed_

@vitaliirymar vitaliirymar added the bug Something isn't working label Feb 27, 2024
@HardNorth
Copy link
Member

HardNorth commented Feb 27, 2024

@vitaliirymar Thanks for reporting this, but unfortunately I cannot reproduce your case. I created a separate test just for this, but it passes normally:
Screenshot 2024-02-27 at 16 53 10

Could you please isolate and share your example?

@vitaliirymar
Copy link
Contributor Author

vitaliirymar commented Feb 27, 2024

@HardNorth I managed to reproduce it with Background. Will rename the issue title.

@HardNorth
Copy link
Member

@vitaliirymar, Please provide any example. Since I also have tests covering Background functionality.

@vitaliirymar
Copy link
Contributor Author

vitaliirymar commented Feb 27, 2024

@HardNorth try this one:

Feature: Karate Scenario Examples

  Background:
    * def util = Java.type('helpers')

  Scenario Outline: Verify math
    Given def mathResult = < vara > + < varb >
    Then assert mathResult == < result >

    Examples:
      | vara | varb| result |
      | 2 | 2 | 4 |
      | 1 | 2 | 5 |

@vitaliirymar
Copy link
Contributor Author

vitaliirymar commented Feb 27, 2024

@HardNorth one more request - could you please run the same test (no matter with/without Background) with 2 Examples wit the ReportPortalHook() runner:

 @Test
    public void TestRunner() {
        Results results = Runner
                .path("classpath:testExamples")
                .hook(new ReportPortalHook())
                .outputCucumberJson(true)//.path("target/cucumber-reports")
                .tags("~@ignore")
                .parallel(5);
    }

I see the following - one scenario example is outside the Feature
image

@vitaliirymar
Copy link
Contributor Author

Update: The issue is also reproducible with 2 or more regular tests when 1 of them fails, all the other tests are marked as failed, if there is Background. E.g.:

Feature: Karate Scenario Examples

  Background: Set varb
    Given def varb = 2

  Scenario: Verify math 1
    Given def mathResult = 4 + varb
    Then assert mathResult == 6

  Scenario: Verify math 2
    Given def mathResult = 2 + 3
    Then assert mathResult == 4

@vitaliirymar vitaliirymar changed the title In a scenario outline with examples, if 1 example passed and another one failed, the report shows 2 failed tests If there is Background and 2 or more tests, if 1 test failed the others are also marked as failed. Feb 29, 2024
HardNorth added a commit that referenced this issue Mar 4, 2024
* Update CI build workflow

* Update build scripts

* Add the first integration test

* Dependency update

* The first Code Reference test, ReportPortal format apply, ignore target folder

* Do not output Cucumber to avoid failures in CI

* Revert last change

* A try to fix tests

* Add code reference for simple scenarios

* Add code reference for Examples scenarios

* Format fixes

* Code reference generation: sort by example key to unify code reference

* Add Test Case ID

* Attribute handling

* Fix tests

* System attributes reporting add

* Refactor item start method

* Add more tests

* Add scenario parameters reporting

* Update property format

* Add parameter handling for steps

* Add parameter log message verification

* Table parameters handling

* Background steps handling

* Test fixes

* Fix typing

* Background logic update

* Another background test

* Fix Table test

* Fix Table test

* Fix description

* Add another test

* Add Launch description test

* Small fix

* Small fix

* Add test

* Add junit-jupiter-params dependency

* Description and item name tests and fixes

* Fix test

* Refactoring

* Add parameter description to examples

* Add examples description tests

* Refactoring

* Add test

* Add test

* Fix test

* Update step logging

* Add test

* Add another test

* Add ReportPortal runtime hook publisher

* Refactoring, move common code to util class

* Fix parameter reporting

* Fix javadocs

* ReportPortalHook: WIP

* ReportPortalHook: WIP

* ReportPortalHook: WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* ReportPortalHook: Tests WIP

* Add timing test and javadocs

* Add feature parameters tests

* Bump version

* Client version update

* Client version update

* Fix version number

* Update copyrights

* Update copyrights

* Code format apply

* Add README_TEMPLATE.md file

* Update README_TEMPLATE.md file

* Update release branch

* Update release.yml

* Update release.yml

* Update README.md

* Update README.md

* Update CHANGELOG.md

* Dependency versions update

* Actions versions update

* Karate version update

* Slack link update

* Add more tests

* Fixes issue #23 - scenarios outside features in parallel execution

---------

Co-authored-by: Reingold Shekhtel <13565058+raikbitters@users.noreply.github.com>
@HardNorth
Copy link
Member

@vitaliirymar
Copy link
Contributor Author

@HardNorth , the issue is still reproducible. It is related to Background.
Check these scenarios:
#23 (comment)
#23 (comment)
image

@HardNorth
Copy link
Member

@vrymar
Copy link
Collaborator

vrymar commented Mar 5, 2024

@HardNorth thanks! It's fixed now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants