Sunday, December 13, 2009

Unit Testing: What to Test? Right-BICEP and CORRECT

I've finally gotten round to reading Pragmatic Unit Testing by Andrew Hunt and David Thomas (the Java with JUnit version - which confirms that it was purchased a while ago now I am focusing upon .NET development).

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?

1 comment:

Unknown said...

I'd also like people to have this in mind.

[F]ast
[I]solated
[R]epeatable
[S]elf-validating
[T]imely