Chapter 1. JUnit jumpstart

This chapter covers

  • Writing simple tests by hand

  • Installing JUnit and running tests

  • Writing better tests with JUnit

 

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

 
 --Martin Fowler

All code is tested.

During development, the first thing we do is run our own programmer’s “acceptance test.” We code, compile, and run. And when we run, we test. The “test” may just be clicking a button to see if it brings up the expected menu. But, still, every day, we code, we compile, we run...and we test.

When we test, we often find issues—especially on the first run. So we code, compile, run, and test again.

Most of us will quickly develop a pattern for our informal tests: We add a record, view ...

Get JUnit in Action 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.