Remote Control Mocking

Definition:

  • where a class that depends on a service is tested with those service’s complex dependencies mocked, rather than the service itself being mocked.

Code Example:

// pseudocode

given: mock connection factory will return a mock connection
given: mock connection, when queried will return a test collection
given: repository with mock connection factory
given: controller with repository
when: controller handles a get request
then: the result will be the test collection as json

References:

Quality attributes

  • - Code Example

  • - Cause and Effect

  • - Frequency

  • - Refactoring