Package org.assertj.core.api
Interface AssertProvider<A>
- Type Parameters:
A
- the type of the assert (not typed - to allow any kind of assert)
public interface AssertProvider<A>
Provides 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");
}
- Author:
- Tobias Liefke
-
Method Summary
-
Method Details
-
assertThat
A assertThat()Returns the associatedAssert
for this object.- Returns:
- the assert object for use in conjunction with
Assertions.assertThat(AssertProvider)
-