- Scala • main professional interest - developer communities If there is time left after my hobbies • mountain bicycle rider, snowboarder • consumer of rock music, contemporary art, etc
tell programmers “what” to do and, furthermore, they had to supervise “how” programmers did it.” Cristian Rennella http://qz.com/260846/why-our-startup-has-no-bosses-no-office-and-a-four-day-work-week/
during code reviews • Things that took me time to understand and prove that they are actually good way to go • Small things we have no time to discuss during big talks
Server server = new NotesServer(); // setup Note note = new Note("test note"); // setup Status status = server.add(note); // exercise assertEquals(SUCCESS, status); // verify server.shutdown(); // teardown }
@Before public void startServer() { server.start(); } @Test public void shouldServeEmptyUserList() { //todo: implement } @After public void stopServer() { server.stop(); } BAD GOOD
// only needed by dogShouldSayFoo dog = new Dog(); // only needed by catShouldSayBar } @Test public void dogShouldSayFoo() { assertThat(dog.says(), is("foo")) } @Test public void catShouldSayBar() { assertThat(cat.says(), is("bar")) }
// * set up which is actual for the current method // * use scope specific name Note singleLineNote = new Note("test note"); // setup Status status = server.add(singleLineNote); // exercise assertEquals(SUCCESS, status); // verify }
It is the process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure. Martin Fowler Refactoring: Improving the Design of Existing Code
your test //Will fix it later™ //@Test public void shouldBeZeroInitialy() { // assertEquals(0, account.getBalance()); //} @Test public void shouldBeZeroInitialy() { assertEquals(1, account.getBalance()); }
your test //Will fix it later™ //@Test public void shouldBeZeroInitialy() { // assertEquals(0, account.getBalance()); //} @Test public void shouldBeZeroInitialy() { assertEquals(1, account.getBalance()); } Who is Will?
assertion per test. Must be clear and readable • Proper tests should fail for exactly one reason • End to end - best case one assertion per test, but more are allowed • Consider custom matchers
assertion per test. Must be clear and readable • Proper tests should fail for exactly one reason • End to end - best case one assertion per test, but more are allowed • Consider custom matchers