3 ms·
Tests and TDD are different things. I view TDD as a workaround for a lack of a REPL. When the code is finished, the tests can be written or polished but writi
by pvdebbe 9y ago
Tests and TDD are different things.
I view TDD as a workaround for a lack of a REPL.
When the code is finished, the tests can be written or polished but writing them before any code is just one variation of testing.
- zepolen 9y agoThe point of TDD is you can define the behavior before writing the code. ie. you define the expected result: def test_sum(): assert sum(1, 2, 3) == 6 def test_sum_no_args(): assert sum() == 0 def test_sum_negatives(): assert sum(-1, -2) == -3 etc, and then you write the function. This means you only do the "REPL" testing once ever for each case - and you can rerun the tests for all future changes. If ever type the same function + args into the REPL more than once - you have done redundant work and are wasting your time. Likewise if you're in the habit of writing tests after your function is made - it shows you haven't put much thought, which means you haven't done the proper analysis of why the function exists, if the function is really one function or should be two functions, what arguments it can take, what it should return etc.
- arenaninja 9y ago> if you're in the habit of writing tests after your function is made - it shows you haven't put much thought, which means you haven't done the proper analysis of why the function exists, if the function is really one function or should be two functions, what arguments it can take, what it should return etc. I'd say that's a pretty broad brush you're painting there with
- zepolen 9y agoI'm not wrong.
- arenaninja 9y agoI would say that you are, but you've convinced yourself otherwise. But testing is important, for sure.
- pmarreck 9y ago> I view TDD as a workaround for a lack of a REPL. Every manual test you do of your code in a REPL is literally a unit test screaming out at you that it wants to live in your suite.