testing for people who hate testing

12
Testing for people who hate writing tests Tips and tricks for organizing and writing simple tests with pytest.

Upload: sam-bolgert

Post on 29-Jun-2015

228 views

Category:

Technology


1 download

DESCRIPTION

SF Python Meetup lightning talk on unit testing with pytest.

TRANSCRIPT

Page 1: Testing for people who hate testing

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

Writing tests is painful

● what to test● how to do it● takes time● QQ...

Page 3: Testing for people who hate testing

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

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
Page 6: Testing for people who hate testing

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

Request fixture

Page 8: Testing for people who hate testing

User fixture

Page 9: Testing for people who hate testing

Test using fixture

Page 10: Testing for people who hate testing

Interaction Fixture

Page 11: Testing for people who hate testing

Test using fixture

Page 12: Testing for people who hate testing

@linuxlewis -- @lovely http://livelovely.com

[email protected]

http://github.com/linuxlewis

https://github.com/linuxlewis/sfpython-pytest