-
Notifications
You must be signed in to change notification settings - Fork 43
Domain specific language
Michael Karneim edited this page Jan 24, 2015
·
15 revisions
PojoBuilder is a powerful tool that helps you to write test data factories used for readable and robust automated tests.
This is how such a test could look like:
@Test
public void testSendOrder() {
// Given:
User user = database().insert(a($User()));
database().insert(a($listOf(
$Product().withId(1),
$Product().withId(2)
)));
OrderRequest request = an($OrderRequest()
.withItems($listOf(
$Item().withArticleId(1),
$Item().withArticleId(2)
)));
// When:
OrderResponse response = client().withCredentialsFrom(user).send(request);
// Then:
assertThat(response).isNotNull();
List<Order> orders = database().getAll(Order.class);
assertThat(orders).hasSize(1);
assertThat(orders.get(0)).matches(request);
}
For an example of the basis of such a DSL please have a look at