#To Mock or to Stub?
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.
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!
-
master
- Instructions -
ruby-rspec-stub
- ruby using stubs -
ruby-rspec-mocks
- ruby using rspec-mocks as a mocking framework -
java-junit-stub
- java using stubs -
java-junit-mockito
- java using mockito as a mocking framework -
js-mocha-chai-stub
- javascript using stubs -
js-mocha-chai-sinon
- javascript using sinon as a mocking framework
- Using the examples of the report writers already implemented, create a writer that prints out the forks as a tree (you may use simple indentation to achieve this effect)
- Create a feature that allows you to supply any arbitrary repo in the tree, that will print out the entire tree, starting from the parent
- Ensure that the starting fork is highlighted in the tree that is rendered in the previous feature
- Render the tree using ascii art