A
- the type of the assert (not typed - to allow any kind of assert)public interface AssertProvider<A>
Assert
for the current object.
Used to map an object to its Assert without having to create a new "Assertions" class.
Usage: public class Button implements AssertProvider<ButtonAssert> {
public ButtonAssert assertThat() {
return new ButtonAssert(this);
}
}
public class ButtonAssert extends Assert<ButtonAssert, Button> {
public ButtonAssert containsText(String text) {
...
}
}
void testMethod() {
Button button = ...;
// First option
Assertions.assertThat(button).containsText("Test");
// Second option
button.assertThat().containsText("Test");
}
Modifier and Type | Method and Description |
---|---|
A |
assertThat()
Returns the associated
Assert for this object. |
A assertThat()
Assert
for this object.Assertions.assertThat(AssertProvider)
Copyright © 2014–2019 AssertJ. All rights reserved.