jfrunit
jfrunit copied to clipboard
Mismatch reporting should include actual events
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.