Timeline for How to test a complex method (without rewriting it in the test)?
Current License: CC BY-SA 4.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 14, 2019 at 4:26 | history | edited | Jörg W Mittag | CC BY-SA 4.0 | added 612 characters in body |
| Oct 14, 2019 at 4:21 | comment | added | Jörg W Mittag | @candied_orange: Indeed. I'll try to make that clearer. This is one of the advantages of TDD: since the code and this the interface doesn't exist yet when you write the tests, and since humans are naturally lazy, you will tend to "dream up" simple to use interfaces for writing your tests against. | |
| Oct 14, 2019 at 0:54 | comment | added | candied_orange | Tests force you to use your method. If your method is hard to test it might be because you made it hard to use. | |
| Oct 13, 2019 at 19:18 | history | edited | Jörg W Mittag | CC BY-SA 4.0 | added 726 characters in body |
| Oct 13, 2019 at 19:11 | comment | added | Jörg W Mittag | @Aganju: One thing I forgot, that I will add as #5 shortly: it doesn't even have to be a simpler implementation of the same algorithm, it can be a different, simpler algorithm altogether. I.e. use brute-force search in your test and min-max with pruning in your production code. | |
| Oct 13, 2019 at 19:06 | comment | added | Aganju | Especially the point "the implementation that is used in the test is simpler than the one in the production code" is a great tip - it can be slow but straightforward, as the test speed doesn't matter, but the quality of its 'verifiabilty' does. Thanks! | |
| Oct 13, 2019 at 19:03 | history | edited | Jörg W Mittag | CC BY-SA 4.0 | added 134 characters in body |
| Oct 13, 2019 at 18:45 | comment | added | Jörg W Mittag | My answer is basically just "Yes, you do all of those things you listed in your question." | |
| Oct 13, 2019 at 18:34 | history | answered | Jörg W Mittag | CC BY-SA 4.0 |