The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,602 other followers

Archive for August 21st, 2014

The Little Mocker (on Test Doubles; via: 8th Light)

Posted by jpluimers on 2014/08/21

Recently, I bumbped into the The Little Mocker | 8th Light by uncle Bob C. Martin.

It’s a nice conversation of a mocker, that explains about Test Doubles (with examples).

Mocks are a bit to Test Doubles like Stunt Doubles are to Body Doubles: a specific kind of Test Doubles.

The conversation step by step explains these Test Doubles probably based on Martin Fowler‘s list of Test Doubles or Mocks, Fakes, Stubs and Dummies at XUnitPatterns.com:

  • Test Dummy: returns nulls (or equivalents null) to consumers as they should not have used: the dummy is a filler in the parameter list to setup the System under Test.
  • Test Double: the generic term (sometimes informally called mocks, but they are not; see Test Mock below).
  • Test Stub: like a Test Dummy, but returns a specific value for a specific test (or group of tests). For instance return true for a LoginStub.
  • Test Spy: like a Test Dummy (or evenTest Stub) but also makes a note (or log) of each call (so you can spy on the calls). It can lead to coupling, so might make your tests fragile.
  • Test Mock: like a Test Spy, but allows verification of certain existence of absence notes or log entries (called Expectations). Like ensuring a certain call to theTest Mock was made with certain parameters.
  • Test Fake: unlike a Test Stub, as fakes have business-like behaviour (so it simulates business behaviour to a certain extent, for instance by having certain data-sets in memory, or responding with certain business logic for instance returning true for certain Login conditions). It also means thatTest Fakes need unit tests of their own.

The links in the above list all contain a small diagram showing the dataflow between the Test Double, System under Test, stc. Jeff Atwood has some nice graphics to go with them at Test Doubles: A Taxonomy of Pretend Objects.

In practice, Stubs and Spies are probably used most, followed by Mocks (either in code or with a Mocking tool).

Notes:

  1. The above order is how the story explains them, not the list by Martin Fowler or the list on WikiPedia.
  2. Want to know more on how to use Test Doubles? Read Test Double at XUnitPatterns.com and Mocks Aren’t Stubs or buy xUnit Test Patterns: Refactoring Test Code: Gerard Meszaros: 9780131495050: Amazon.com: Books.

–jeroen

Posted in Agile, Development, Software Development, Unit Testing | Leave a Comment »

Linux/bash: using mutt to send a file as an email attachment (via: Stack Overflow)

Posted by jpluimers on 2014/08/21

Just in case I need this again:

None of the mutt ones worked for me. It was thinking the email address was part of the attachemnt. Had to do:

echo “This is the message body” | mutt -a “/path/to/file.to.attach” -s “subject of message” — recipient@domain.com

Thanks Alexander Bird for noticing the double-dash, rynop for the modified answer and Chris N for the original answer.

From mutt(1): Mutt Mail User Agent – Linux man page: Read the rest of this entry »

Posted in *nix, bash, Development, Linux, Power User, Scripting, Software Development, SuSE Linux | Leave a Comment »

 
%d bloggers like this: