jfrunit icon indicating copy to clipboard operation
jfrunit copied to clipboard

Mismatch reporting should include actual events

Open marcphilipp opened this issue 5 years ago • 0 comments

Currently, when an assertion fails the exception message only includes the expectation, but not the actual events.

For example, the following assertion inspired by the JUnit 5 codebase fails with AssertionError: No JFR event of type <org.junit.EngineDiscovery> with attributes <{uniqueId=[engine:does-not-exist]}>:

assertThat(jfrEvents)
	.contains(event("org.junit.EngineDiscovery")
		.with("uniqueId", "[engine:does-not-exist]"));

To find out what went wrong, I then had to add println statements to the test code, e.g.

		jfrEvents.filter(event -> "org.junit.EngineDiscovery".equals(event.getEventType().getName()))
				.forEach(System.out::println);

It would be great if the assertion message would include a (possibly shortened) list of actual events of the event type in question.

marcphilipp avatar Dec 23 '20 16:12 marcphilipp