O'Reilly logo

Effective Unit Testing: A guide for Java Developers by Lasse Koskela

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. JUnit primer

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required