Reputation: 1
For example, for this assertion -
aString = "stack overflow"; another string = "stack";
assertThat(aString).startsWith(anotherString);
is it possible to add a logger like this -
assertThat(aString ["stack overflow"]).startsWith(another strong ["stack"])
..or something similar. I'm interested in logging the type of assertions and the name and current values of fields under assertion implicitly.
Upvotes: 0
Views: 377
Reputation: 7076
As NoDataFound pointed out, there is no logging of assertions out of the box in AssertJ, adding such a mechanism is being discussed here https://github.com/joel-costigliola/assertj-core/issues/1518.
Upvotes: 0
Reputation: 11959
You should read the code of AssertJ (for your example, that would be AbstractStringAssert, AbstractCharSequenceAssert and AbstractAssert) and you'll have your answer: this is not possible in AssertJ directly. Even if, in case of failure, the error should clearly indicate the assertion being tested.
You could however do it in other ways:
Upvotes: 1