Background Image
Table of Contents Table of Contents
Previous Page  363 / 478 Next Page
Information
Show Menu
Previous Page 363 / 478 Next Page
Page Background

$

python3 manage.py test functional_tests

[...]

Ran 7 tests in 93.819s

OK

But we know we cheated to get there. The Testing Goat is eyeing us suspiciously. We left

a test failing at one layer while we implemented its dependencies at the lower layer. Let’s

see how things would play out if we were to use better test isolation…

Outside-In TDD

Outside-In TDD

Amethodology for building code, driven by tests, which proceeds by starting from

the “outside” layers (presentation, GUI), and moving “inwards” step by step, via

view/controller layers, down towards themodel layer. The idea is to drive the design

of your code from the use to which it is going to be put, rather than trying to

anticipate requirements from the ground up.

Programming by wishful thinking

The outside-in process is sometimes called “programming by wishful thinking”.

Actually, any kind of TDD involves some wishful thinking. We’re always writing

tests for things that don’t exist yet.

The pitfalls of outside-in

Outside-In isn’t a silver bullet. It encourages us to focus on things that are imme‐

diately visible to the user, but it won’t automatically remind us to write other critical

tests that are less user-visible, things like security for example. You’ll need to re‐

member them yourself.

Moving Down to the Model Layer

|

335