May 2018
Beginner to intermediate
290 pages
6h 43m
English
So which is better, traditional unit tests or generative tests? The answer is simple: yes. Both traditional tests and their generative cousins have strengths and weaknesses. And both have a place in making sure your code is doing what it is supposed to be doing.
Traditional unit tests do have one huge advantage: they are shatteringly obvious. Does it work when I do this? Yes. Does it work when I do that? Yes. OK, then we’re good. So, if we were trying to test this simple function:
| | (defn f [a b] (/ a b)) |
we might write this test:
| | (deftest test-f |
| | (is (= 1/2 (f 1 2))) |
| | (is (= 1/2 (f 3 6))) |
| | (is (= 1 (f 10 10)))) |
And we know that for these specific instances, it works. The drawback of this kind ...
Read now
Unlock full access