1 JUnit jump-start

This chapter covers

  • Understanding JUnit
  • Installing JUnit
  • Writing your first tests
  • Running tests

Never in the field of software development was so much owed by so many to so few lines of code.

--Martin Fowler

All code needs to be tested. During development, the first thing we do is run our own programmer’s acceptance test. We code, compile, and run. When we run, we test. The test may just consist of clicking a button to see whether it brings up the expected menu or looking at a result to compare it with the expected value. Nevertheless, every day, we code, we compile, we run, and we test.

When we test, we often find issues, especially during early runs. So we code, compile, run, and test again.

Most of us quickly develop ...

Get JUnit in Action, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.