Auto Mocking with Sourcery

Make your life easier

Steven Curtis
6 min readJan 18, 2023
Photo by Elena Joland on Unsplash

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:

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.

--

--

No responses yet