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

JUnit5: StepListener get wrongly SUCCESS when an Exception is thrown in test #3443

Closed
zeners opened this issue Apr 18, 2024 · 9 comments
Closed

Comments

@zeners
Copy link
Contributor

zeners commented Apr 18, 2024

What happened?

net.serenitybdd.junit5.SerenityTestExecutionListener#testFinished missed to call updateResultsUsingTestExecutionResult() with TestExecutionResult.Status.FAILED because result.isLessSevereThan(TestResult.FAILURE) has to be negated or flipped.

What did you expect to happen?

get the correct FAILED result in net.thucydides.model.steps.StepListener#testFinished(net.thucydides.model.domain.TestOutcome) if an exception is thrown inside a test, but outside a step

Serenity BDD version

4.0.12

JDK version

17

Execution environment

caused by net.serenity-bdd:serenity-junit5:4.0.12

How to reproduce the bug.

  • create a junit5 test with throw new RuntimeException("Test-Error");
  • do one of
    • create a net.thucydides.model.steps.StepListener service and try to log result.getResult() inside void testFinished(TestOutcome result)
    • set a breakpoint in SerenityTestExecutionListener#testFinished
    • register net.thucydides.core.steps.Listeners#getLoggingListener() (eg with StepEventBus.getEventBus().registerListener(getLoggingListener()))
  • run the test

test failed, but the Listener got an result SUCCESS

this can be seen

  • inside testFinished(TestOutcome result) with result.getResult() == TestResult.SUCCESS
  • that SerenityTestExecutionListener#testFinished missed to call updateResultsUsingTestExecutionResult()
  • that the loggingListener prints Test Passed

please note that the method void testFailed(TestOutcome testOutcome, Throwable cause) is correctly called

How can we make it happen?

Add it to the Serenity BDD backlog and wait for a volunteer to pick it up

@wakaleo
Copy link
Member

wakaleo commented Apr 18, 2024

Can you propose a PR?

@wakaleo
Copy link
Member

wakaleo commented Apr 18, 2024

I would need to check but I believe if a test fails, the test finished listener is not meant to be triggered.

@wakaleo
Copy link
Member

wakaleo commented Apr 18, 2024

(Also 4.0.12 is an old version, have you tried with the latest versions)

@zeners
Copy link
Contributor Author

zeners commented Apr 18, 2024

  • the test finished is called, if i call the missed routine inside debugger
  • the spotted line is unchanged in current master

@wakaleo
Copy link
Member

wakaleo commented Apr 18, 2024

Can you propose a PR?

@zeners
Copy link
Contributor Author

zeners commented Apr 18, 2024

will take some time, my dev environment is outdated

@zeners
Copy link
Contributor Author

zeners commented Apr 18, 2024

i have troubles to reproduce it with current version 4.1.6

@zeners
Copy link
Contributor Author

zeners commented Apr 18, 2024

found:
4.0.12 > TestResult.SUCCESS.isLessSevereThan(TestResult.FAILURE) return false
4.1.6 > TestResult.SUCCESS.isLessSevereThan(TestResult.FAILURE) return true (correct)

@zeners zeners closed this as completed Apr 18, 2024
@zeners
Copy link
Contributor Author

zeners commented Apr 18, 2024

duplicate of #3299

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

Successfully merging a pull request may close this issue.

2 participants