Testing for people who hate writing tests
Tips and tricks for organizing and writing simple tests with pytest.
Writing tests is painful
● what to test● how to do it● takes time● QQ...
User facing● Mobile API (Bono)● Livelovely.com (Spot)● Pro.livelovely.com (Pearl)● Messaging API (Ditto)● Photo API (Jiris)
Case study
Organizing
● mimic application structure○ easy to remember○ helps scope tests○ easy test hooks
● pytest discovery○ http://pytest.org/latest/goodpractises.
html#conventions-for-python-test-discovery
Theres a fixture for that...
● test fixture is a fixed state of the software under test used as a baseline for running tests; also known as the test context.
● reusable bits of code that are used to write tests.
● fixtures replace traditional setup/teardown● fixtures can be built on top of each other
Request fixture
User fixture
Test using fixture
Interaction Fixture
Test using fixture
@linuxlewis -- @lovely http://livelovely.com
http://github.com/linuxlewis
https://github.com/linuxlewis/sfpython-pytest