Auto Mocking with Sourcery
Make your life easier
Before we start
Difficulty: Beginner | Easy | Normal | Challenging
Keywords and Terminology:
Mocking: A fake response to the method call for of an object, allowing the checking of a particular method call or property
Prerequisites:
- None, although knowing something about Mocking would be useful, and if you are interested I’ve mocked using this set of techniques
The need
So I’ve been hand crafting mocks for some time. It is quite time-consuming.
Sourcery can help us out here and this article goes into detail about how it can help you out (as well as how you might set this up)
To experiment I’ve created a small project which has a single label on the screen:
Which is both unexciting and not something which you might usually test. However, my plan here is to have such a visual test to make it clear that “Hello dave” is the standard text returned by the software onto the label and then test that.