Tests and Coverage

Types of Tests:
  • Mutation test: introduce deliberate errors, check what fails
  • Fuzz testing: Random inputs, API calls, wierd URLs
  • DU coverage: Is every pair Define-Use executed?
  • Black-box: Unit test doesn't know implementation
  • White-box/Glass-box: Knows implementation details

Different Levels of Test Coverage:
  • C0 code coverage tells you whether a given line of code was executed. (if statement in itself)
  • C1 coverage tells you whether each branch of each line of code was executed. (if true and false branches)
  • C1+Decision coverage tells you whether every subexpression in each branch of each line of code was executed. (A || B, C && D: Each of subexpression A, B, C & D in every if true and false branches)
  • C2 coverage tells you whether each code path (across lines) was executed. (All combinations of branches across all lines)
C0 and C1 are widely used.

Unit tests: Model specs
Functional/Module tests: Controller specs
Integration/System tests: Cucumber scenarios (browerser to app everything)

Unit tests should be FIRST:

  • Fast: Run subset quickly
  • Independent: Can run any subset without worrying about dependency
  • Repeatable: Same results, so that bugs can be isolated
  • Self-checking: Automatically detect if passed (no human intervention)
  • Timely: Written the same time as (actually, before) code under test

No comments:

Post a Comment