0

Im currently building a custom maven test report plugin that captures unit and integration tests results. While trying to capture as much test information as possible, I am able to capture AssertJ descriptions using something like this >

// initialize the description consumer
final StringBuilder descriptionReportBuilder = new 
StringBuilder(String.format("Assertions:%n"));
Consumer<Description> descriptionConsumer = desc -> 
descriptionReportBuilder.append(String.format("-- %s%n", desc));

// use the description consumer for any following assertions descriptions.
Assertions.setDescriptionConsumer(descriptionConsumer);

// execute some assertions
TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, Race.HOBBIT);
assertThat(frodo.getName()).as("check name")
                      .isEqualTo("Frodo");
assertThat(frodo.getAge()).as("check age")
                      .isEqualTo(33);

// get the report
String descriptionReport = descriptionReportBuilder.toString();

Is there anything similar in the framework for consuming or capturing the actual values from assetThats, that are exectued during a test. Iv navigated through the code but cannot find anything. I am able to extend the Assertion class but id opt for a better way

Any help appreciate.

rogger2016
  • 821
  • 3
  • 11
  • 28

0 Answers0