Skip to content

Latest commit

 

History

History
115 lines (80 loc) · 2.5 KB

property-testing-for-fun-and-profit.md

File metadata and controls

115 lines (80 loc) · 2.5 KB
title author patat
Property testing
James Santucci
wrap margins
true
left right
40
40

Welcome

This talk

  • tests are programs that verify your expectations about other programs
  • property testing can save you from having to state your expectations separately about a lot of similar cases
  • you can property test anywhere

What's testing

  • programs that verify some expected behavior occurs under known conditions

Programs that verify

  • is this a test?
from .lib import foo

def test_foo():
    result = foo(3, 4)
    assert result == 7

Programs that verify

  • is this a test?
from .lib import foo

def test_foo():
    result = foo(3, 4)
    assert result == 7, "oh no"
$ python -m pytest

Programs that verify

  • is this a test?
from .lib import foo

def should_work():
    result = foo(3, 4)
    assert result == 7, "oh no"

if __name__ == '__main__':
    should_work()
$ python thing_that_should_work.py

Programs that verify

  • is this a test?
$ sbt compile

A library

When should you property test?

  • when there are laws
  • when you have an oracle
  • when you have a black box
  • when you have an expected round trip

Property testing everywhere

This talk

  • tests are programs that verify your expectations about other programs
  • property testing can save you from having to state your expectations separately about a lot of similar cases
  • you can property test anywhere