Skip to content

removeAssertJRelatedElementsFromStackTrace does not remove all the JDK elements triggered by AssertJ #3449

@almondtools

Description

@almondtools

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.

  • assertj core version: 3.25.3
  • java version: 21
  • test framework version: Junit Jupiter
  • os (if relevant): Windows
  • build: grade
  • IDE: Eclipse

Test case reproducing the bug

class WorldTest {

	@Test
	void testStacktrace() {
		assertThat(0).isEqualTo(1);
	}
}

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions