Appendix B. JUnit on OS X

JUnit is a Java test-driven development (TDD) framework. Traditional software development starts with some sort of requirement documents, followed by massive amounts of programming, and finishes off with some sort of manual or automated testing. Test-driven development starts with requirements, followed by the writing of automated tests, and concludes with the creation of the computer program that allows the previously written tests to pass.

The mental reordering that test-driven development requires can make you dizzy at first. It is not for every company. However, test-driven development leads to well-thought-out programs that are easier to maintain than the spaghetti that result from no planning.

JUnit also works for regression testing and more casual testing efforts. Create regression tests by finding bugs in your code. Next, create a test that fails because of the bug. Finally, fix the program, and the test passes. Leave the tests in place, and run these tests frequently to ensure that the bugs do not reappear.

Regression testing is great for projects with lots of developers working on the same code. If the project is managed without clear definitions as to who owns and makes changes to specific code, a programmer may fix a bug that creates other bugs. When another programmer comes along and fixes those other bugs, the programmer may introduce the original bug while ...

Get Java® and Mac OS® X 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.