CORREC[T]: [T]ime

Learn about the time boundary condition in writing JUnit tests.

The last boundary condition in the CORRECT acronym is time. We need to keep several aspects of time in mind:

  • Relative time (ordering in time)
  • Absolute time (elapsed and wall clock)
  • Concurrency issues

Some interfaces are inherently stateful. We expect login() to be called before logout(), open() before read(), read() before close(), and so on.

Consider what happens if methods are called out of order. Try various alternate sequences. Try skipping the first, last, and middle of a sequence. Just as the order of data matters, the order of the calling sequence of methods matters.

Get hands-on with 1200+ tech skills courses.