Managing data for end to end Tests are always difficult. To keep tests isolated many people will drop and repopulate the database before every test execution. The Test Data Builder Pattern provides an alternative to this anti-pattern.
8. What is a Builder?
new UserBuilder()
an object that knows how to construct another
object
User user = .build();
9. the object is complex to
construct
public class UserBuilder {
uses sensible default values
}
public User build() {
return new User(name, password,
email);
}
private String name = ``charlie``;
private String password = ``password``;
private String email = ``charlie@behave.pro``;