The Pragmatic Programmer: your journey to mastery, 20th Anniversary Edition, 2nd Edition
by David Thomas, Andrew Hunt
Topic 42 | Property-Based Testing |
Доверяй, но проверяй (Trust, but verify)
We recommend writing unit tests for your functions. You do that by thinking about typical things that might be a problem, based on your knowledge of the thing you're testing.
There's a small but potentially significant problem lurking in that paragraph, though. If you write the original code and you write the tests, is it possible that an incorrect assumption could be expressed in both? The code passes the tests, because it does what it is supposed to based on your understanding.
One way around this is to have different people write tests and the code under test, but we don't like this: as we said in Topic 41, Test to Code, one of the biggest benefits ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access