BCS SPA2015

Software Practice Advancement Conference

SPA Conference session: To Mock or to Stub?

One-line description:A practical experiment to compare the effectiveness of mocking versus stubbing in test code.
 
Session format: Simulation/Workshop 150 minute [read about the different session types]
 
Abstract:Most developers will have an opinion one way or another, but there is almost no experimental evidence to suggest which is better. In this session we will explore the stub versus mock debate through experimental means. We will write an application that exercises an API using both techniques, and explore how much time it takes to "solve" the problem both ways, and compare the resulting code.

After a short introduction to mocking and stubbing techniques, we will split into pairs for the exercises. Each pair will attempt to complete a series of small stories using an API, using either mocking or stubbing. Half way through the session we will stop, collect data about how far each pair has managed to get, then the pairs will switch approach to solve the same set of stories.

The session will finish with a group discussion to reflect on the observed results and identify whether any interesting discoveries were revealed during the experiment.
 
Audience background:Familiarity with one of the supported language/testing framework combinations.

Some experience of mocking or stubbing techniques.

This session is relevant for anyone who writes code.
 
Benefits of participating:You will have a chance to write some code in pairs and try to practice a constraint that may not be how you normally write tests. You will also get the opportunity to reflect on the merits of different solutions produced in groups and gain some insight on the impact on your design that selection of test-double can make. Should be fun!
 
Materials provided:Code skeleton on memory stick and to download from GitHub. Attendees should come along with a laptop with editor/IDE ready to code in Java, JavaScript Ruby, Scala.
 
Process:After a short introduction to mocking and stubbing techniques, we will split into pairs for the exercises. Each pair will attempt to complete a series of small stories using an API, using either mocking or stubbing. Half way through the session we will stop, collect data about how far each pair has managed to get, then the pairs will switch approach to solve the same set of stories.

The session will finish with a group discussion to reflect on the observed results and identify whether any interesting discoveries were revealed during the experiment.
 
Detailed timetable:00:00-00:15 Introduction to the experiment and the difference between a mock and a stub
00:15-00:20 Get into pairs and get sample code loaded
00:20-00:50 Round 1
00:50-01:00 Collect results from round 1
01:00-01:10 break
01:10-01:40 Round 2
01:40-01:50 Collect results from round 2
01:50-02:00 Pairs reflect and compare
02:00-02:30 Pairs share insights and summarise

 
Outputs:We can encourage participants to check-in their code into a Git repo and write up conclusions on a SPA community wiki page.
 
History:New session.
 
Presenters
1. Clive Evans
Unruly
2. Alex Wilson 3.