March 2018
Intermediate to advanced
324 pages
8h 30m
English
As the BirthdayGreetingService class does not have a collaborator injected that could be used to attach additional responsibilities to the object, the only option is to go outside this service class to test it. An option would be to change the EmailMessageSender class for a mock or fake implementation, but this would risk the implementation in that class.
Another option is to create an end-to-end test for this functionality:
public class EndToEndTest { @Test public void email_an_employee() { final StringBuilder systemOutput = injectSystemOutput(); final Employee john = new Employee( new Email("john@example.com")); new BirthdayGreetingService().greet(john); assertThat(systemOutput.toString(), equalTo("Sent email to " + ...Read now
Unlock full access