Search This Blog

Friday, February 19, 2010

02-18-2010

Will wants us to create a new Trac installation.  Here is a recommendation for naming unit tests:
  • name of the method being tested
  • scenario under which it is being tested
  • the expected behavior when the scenaio is invoked
methodUnderTest_scenario_behavior = wordCount_with_3_line_file_returns_3

  • stubs - Stubs are essentially the simplest possible implementation of a given interface you can think of. For example, stubs’ methods typically return hardcoded, meaningless values.
  • fakes - Fakes are a degree more sophisticated than stubs in that they can be considered an alternative implementation of the interface. In other words, a fake looks like a duck and walks like a duck even though it isn’t a real duck. In contrast, a stub only looks like a duck.
  • mocks - Mocks can be considered even more sophisticated in terms of their implementation, because they incorporate assertions for verifying expected collaboration with other objects during a test. Depending on the implementation of a mock, it can be set up either to return hardcoded values or to provide a fake implementation of the logic. Mocks are typically generated dynamically with frameworks and libraries, such as EasyMock, but they can also be implemented by hand.
Should only use one Mock per test.  Mocks are the only test double that can fail a test.  Stubs and Fakes make "happy noises" and provide only enough functionality to get to the code being tested.

Created a new Trac instance.  Could not use the command-line version.  Had to execute the interactive mode: sudo trac-admin /opt/trac/megatron initenv . Very strange.

No comments:

Post a Comment