February 2013
Intermediate to advanced
258 pages
7h 26m
English
In the Java ecosystem, the de facto unit-testing framework today is JUnit. Year after year, you’re less and less likely to meet a Java programmer who hasn’t at least seen JUnit test code. Nevertheless, there’s always the first time for everybody and some of you may have been using a different test framework, so we’ve included this short appendix as a quick start to writing tests with JUnit.
There are two elemental things to understand about JUnit. First, you must understand the structure and lifecycle of JUnit test code. This is where we’ll start. We’ll look at how to define test methods inside test classes and then familiarize you with these tests’ lifecycle—how and when JUnit instantiates and invokes your test classes ...