|
||||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
org.fest.assertions | Assertion methods bound to the type they apply. |
This document is the API specification for the FEST "Flexible Assertions" Module.
Currently, this module provides assertions that apply to the following data types:
Object
String
Collection
List
Map
boolean
, int
, char
, etc.)Object
arraysBufferedImage
Throwable
File
BigDecimal
Quick example:
int removed = employees.removeFired();assertThat
(removed).isZero
(); List<Employee> newEmployees = employees.hired(TODAY);assertThat
(newEmployees).hasSize
(6);
Assertions can also be extended by using custom
s. The following
condition verifies that the characters in a Condition
String
are in uppercase:
class UpperCaseCondition extends Condition
<String> {
public boolean matches(String value) {
if(isEmpty(value)) return false;
return value.equals(value.toUpperCase());
}
public static UpperCaseCondition isUpperCase() {
return new UpperCaseCondition("Uppercase");
}
}
This example shows how to use such condition:
which will fail with the message "assertThat
("hello").as("Greeting").satisfies
(isUppercase());
[Greeting] expected:Uppercase but was:<'hello'>
"
|
||||||||||
PREV NEXT | FRAMES NO FRAMES |