You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I call assertThat(0).isEqualTo(1);, I get an exception with a stacktrace
org.opentest4j.AssertionFailedError:
expected: 1
but was: 0
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at net.amygdalum.WorldTest.testStacktrace(WorldTest.java:13)
at ...
The first two lines are superfluous and not understandable (WorldTest:13 does not call newInstanceWithCaller). I think that some bug fix removing assertj internals from the stack now does not remove these lines any more.
This bug seems so obvious to me, that I am uncertain whether my configuration is the reason, so I added my IDE and my build system to the context below. Feel free to ask more, if you have a suspect.
I would also consider the bug quite obvious but yours seems to be the first feedback on a code that never changed since the forking from Fest Assert (66f11f8) 🙂
According to the Javadoc example of removeAssertJRelatedElementsFromStackTrace, pruning all the stack trace elements triggered by AssertJ was never intended. Only the one right before the first AssertJ method is supposed to be removed.
you would see how the stack trace really looks like:
...
kept --> at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
kept --> at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
removed --> at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
removed --> at org.assertj.core.error.ConstructorInvoker.newInstance(ConstructorInvoker.java:28)
removed --> at org.assertj.core.error.ShouldBeEqual.assertionFailedError(ShouldBeEqual.java:223)
...
I believe any element that is a consequence of org.assertj.core.error.ConstructorInvoker.newInstance is not valuable for the users and should be pruned.
Referring to the original example, what users should see is only:
org.opentest4j.AssertionFailedError:
expected: 1
but was: 0
at net.amygdalum.WorldTest.testStacktrace(WorldTest.java:13)
at ...
scordio
changed the title
Stacktrace for "isEqualTo" errors contains too many linesremoveAssertJRelatedElementsFromStackTrace does not remove all the JDK elements triggered by AssertJ
Apr 29, 2024
Here the superfluous lines from the example above appear in the middle of the stack trace. I have no preference how to handle this, but just wanted to point out that this test is similar but different.
If I call
assertThat(0).isEqualTo(1);
, I get an exception with a stacktraceThe first two lines are superfluous and not understandable (
WorldTest:13
does not callnewInstanceWithCaller
). I think that some bug fix removing assertj internals from the stack now does not remove these lines any more.This bug seems so obvious to me, that I am uncertain whether my configuration is the reason, so I added my IDE and my build system to the context below. Feel free to ask more, if you have a suspect.
Test case reproducing the bug
The text was updated successfully, but these errors were encountered: