assertj
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
when assertions fails, the message returned to the user can be consfusing
using the method describedAs
, allows you to pass in a message and possible values to give a better output to help the user make changes to pass the test
You will need to use this at the beginning of the assertion
assertThat(false).describedAs("Message to help with passing test").isTrue();
public class CoffeeAssert extends AbstractAssert<CoffeeAssert, Coffee> {
public CoffeeAssert(Coffee actual) {
super(actual, CoffeeAssert.class);
}
Using the assetion
import static com.example.coffee.CoffeeAssert.assertThat;
...
Coffee coffee = new Coffee();
coffee.setStrength(Strength.STRONG);
coffee.setType(Type.ESPRESSO);
assertThat(coffee)
.hasType(Type.ESPRESSO)
.isNotDecaf();