Recap¶
We can now summarize the essentials of the Testix approach:
use
Fakeobjects to simulate various entitiesuse a
Scenarioobject to define an exact set of demands or expectationsthe
Scenarioobject not only defines our expectations, it is also used in awithstatement to enforce them.return values from
Fakeobjects may be specified using>>.
By requiring the developer to define his or her demands using a the Scenario concept, Testix lends itself in particular to Test Driven Development - think about testing first, write the code only after you have exactly defined what you want it to do.
We can also now recognize some major advantages over the mock objects from the Python Standard Library.
Testix lends itself naturally to the Test Driven approach to development (TDD) through its
Scenarioconcept and the “no less - no more” approach that makes it harder to change the functionality of code without changing the test first.test syntax is more visually similar to the code under test, e.g. the
s.sock.send(b'the data')is visually similar to the same as the actual codesocket.send(data). This makes tests more readable and easy to understand.Whatever expectations you define for you mock objects - they will be exactly enforced - defining expectations and enforcing them is one and the same.