title | author | patat | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Property testing |
James Santucci |
|
- 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
- programs that verify some expected behavior occurs under known conditions
- is this a test?
from .lib import foo
def test_foo():
result = foo(3, 4)
assert result == 7
- is this a test?
from .lib import foo
def test_foo():
result = foo(3, 4)
assert result == 7, "oh no"
$ python -m pytest
- 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
- is this a test?
$ sbt compile
- when there are laws
- when you have an oracle
- when you have a black box
- when you have an expected round trip
- 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
✅