testing for people who hate testing
DESCRIPTION
SF Python Meetup lightning talk on unit testing with pytest.TRANSCRIPT
![Page 1: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/1.jpg)
Testing for people who hate writing tests
Tips and tricks for organizing and writing simple tests with pytest.
![Page 2: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/2.jpg)
Writing tests is painful
● what to test● how to do it● takes time● QQ...
![Page 3: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/3.jpg)
User facing● Mobile API (Bono)● Livelovely.com (Spot)● Pro.livelovely.com (Pearl)● Messaging API (Ditto)● Photo API (Jiris)
Case study
![Page 4: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/4.jpg)
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
![Page 5: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/5.jpg)
![Page 6: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/6.jpg)
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
![Page 7: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/7.jpg)
Request fixture
![Page 8: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/8.jpg)
User fixture
![Page 9: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/9.jpg)
Test using fixture
![Page 10: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/10.jpg)
Interaction Fixture
![Page 11: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/11.jpg)
Test using fixture
![Page 12: Testing for people who hate testing](https://reader034.vdocuments.net/reader034/viewer/2022042510/5590bda21a28abcd738b45ab/html5/thumbnails/12.jpg)
@linuxlewis -- @lovely http://livelovely.com
http://github.com/linuxlewis
https://github.com/linuxlewis/sfpython-pytest