Unit Test

less than 1 minute read

Two handy reminders when you are thinking about what to test in your unit tests are:

Right-BICEP

Right - Are the results right?

  • B - are all the boundary conditions correct?
  • I - can you check the inverse relationships?
  • C - can you cross-check results using other means?
  • E - can you force error conditions to happen?
  • P - are performance characteristics within bounds?

CORRECT

  • C - Conformance - does the value conform to an expected format?
  • O - Ordering - is the set of values ordered or unordered as appropriate?
  • R - Range - is the value within reasonable minimum and maximum values?
  • R - Reference - does the code reference anything external that isn’t under direct control of the code itself?
  • E - Existence - does the value exist (e.g. is not null, non-zero, present in a set)?
  • C - Cardinality - are there exactly enough values?
  • T - Time (absolute and relative) - is everything happening in order? At the right time? In time?

FIRST

  • F - Fast
  • I - Isolated
  • R - Repeatable
  • S - Self-validating
  • T - Timely

Ref: F.I.R.S.T Principles of Unit Testing