Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 1.97 KB

testing.md

File metadata and controls

47 lines (38 loc) · 1.97 KB

Generic Notes on Software Testing

Test Object Terminology

The terminology here comes from Gerard Meszaros' XUnit Test Patterns via Martin Fowler's Mocks Aren't Stubs.

  • SUT: "System Under Test" or the thing you're focused on testing. (In unit testing, usually a function or perhaps a class.)
  • collaborator: Something involved in the tests that's not part of the SUT.
  • test double: An object used for testing purposes in place of the "real" object. Particular types include:
    • dummy objects passed around but never used.
    • fake objects with working implementations but not usable in production (due to shortcuts, e.g., an in-memory database)
    • stubs programmed just for the test(s), e.g. providing canned answers.
    • spies are stubs that record information about how they were called.
    • mocks are pre-programmed with expectations about the calls they should receive.
  • state verification: Determining correctness by examining the state of a SUT and its collaborators after exercising code.
  • behaviour verification: Determining correctness by tracking what the exercising code did during its run.
'Classical' vs. 'Mockist'

fowler-mocks discusses in detail the 'classical' vs. 'mockist' TDD styles. Mainly:

  • Classical tends toward using real objects for collaborators where possible, maybe stubbing others. The test collaborators can get complex, generating object mothers (om-paper). Tests being sometimes mini-integration tests, bugs can cause ripple failures.
  • Mockest tends toward generating minimal collaborators on the fly for each test.