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

Throw AssertionError instead of Error in case of approval failure #596

Closed
nicerloop opened this issue Nov 29, 2024 · 5 comments
Closed

Throw AssertionError instead of Error in case of approval failure #596

nicerloop opened this issue Nov 29, 2024 · 5 comments

Comments

@nicerloop
Copy link

Approval failures currently throw Error, but should throw AssertionError to actually distinguish functional failure (AssertionError) from technical failure (everything else).

See PR #595

@LarsEckart
Copy link
Contributor

hm, that AssertionError comes from java.lang though. There is also https://github.com/ota4j-team/opentest4j which was my first thought when I saw the subject of this Issue. Are you aware of this, wouldnt this not the preferred Exception to throw?

I've seen your PR, we (or other maintainers) will have a look the next time we get together. (In my case that's 9.12.)

@nicerloop
Copy link
Author

As explained in https://github.com/ota4j-team/opentest4j#status-quo the base common ground is AssertionError which should be used in Approval instead of Error in case of failure.

Using opentest4j is cleaner but requires an external dependency, which would be a larger change than just using AssertionError from the base Java runtime.

@LarsEckart
Copy link
Contributor

hello again, we've been thinking about this and haven't quite understood what problem does it solve when we switch from throwing Error to AssertionError ?

@LarsEckart
Copy link
Contributor

We couldn't let it go, and we rather not change it as we don't see what it solves. Regardless, with release 24.11.0 you can now customize it on your side if this is necessary for you.

@nicerloop
Copy link
Author

nicerloop commented Dec 9, 2024

hello again, we've been thinking about this and haven't quite understood what problem does it solve when we switch from throwing Error to AssertionError ?

The problem is that a test can fail due either to a technical problem or a functional problem. As explained in https://github.com/ota4j-team/opentest4j#status-quo AssertionError is the simplest Java provided throwable describing a failed assertion, i.e. a functional test failure. Error on the other hand signals a generic technical failure.

As an example, using Eclipse test runner, or Serenity BDD, the test is reported differently is Error or AssertionError is thrown: Error marks the test as (technically) broken, AssertionError marks the test as (functionally) failed.

I am currently integrating ApprovalTests.Java with Cucumber and Serenity, and I don't want my (functional) failures to be reported as (technical) broken tests.

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

2 participants