HelloWorld v 2.0
Once upon a time we used to write:
Now I prefer:
The test is of course using the beautiful test double framework Mockito
public static void main(String[] args) {
System.out.println(”Hello World”);
}@Test
public void shouldSayHelloToTheGivenName() throws Exception {
// given
PrintStream mockStream = mock(PrintStream.class);
Greeter greeter = new Greeter(mockStream);
// when
greeter.helloworld(”toni”);
// then
verify(mockStream).println(”Hello world, toni”);
}