Unit Testing: Summary

Unit testing is the practice of testing individual units or components of an application, to validate that each of those units is working properly. In this course, it means testing every operation (method) of all implementations of an ADT. We will do this for every ADT.

In general, the anatomy of each unit test involves three logical steps:

  1. Arrange everything we need to run the test. For example, instantiate an object with some parameters.
  2. Act to set the test in motion; invoke the method to be tested (with some input).
  3. Assert the output (effects) of the method under test checks against the expected outcome.

JUnit is a unit testing framework in Java that provides us with utilities to write, run, and automate unit testing.

Unit Testing & Software Testing

Unit Testing is just one of the many different software testing strategies. You can read more on Software Testing at Software Testing Fundamentals Website

It must be noted, software testing is not a substitute for formal verification, proving that your code/algorithm/process does what it is supposed to do.

Test-First Development

In this class, we follow a popular software development practice known as Test-First Development.

Test first development is a practice where you write the unit tests before you write the code to test.

Don Wells has a great article, Code the Unit Test First, that elaborates on the values of this practice.

Test-First Development is closely related to another, more popular, software development practice called Test-Driven Development or TDD.