Timeline for Are "Stocks" a TDD/Unit testing anti pattern?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 11, 2014 at 11:32 | comment | added | maple_shaft♦ | @SebastianRedl The isValid method implies to me that it is some kind of business logic and like all business logic should be covered by its own test. Perhaps you can include your comment as part of your answer? | |
| Mar 3, 2014 at 21:20 | comment | added | soru | If there is a bug in the function, but you can't detect that by external behaviour, then there isn't a bug in the function. At most there is a potential performance or style improvement - testing for those is like trying to test for typos in comments. | |
| Mar 3, 2014 at 18:01 | comment | added | John Raya | @SebastianRedl I think what Songo meant by "...another bug that causes it to pass" that there might be a bug in the function that uses isValid() not in isValid() itself. | |
| Mar 3, 2014 at 17:27 | comment | added | Sebastian Redl | You want to test your real isValid function separately. You want it to be idempotent so that it doesn't matter how often it is invoked. And then when you test whatever you're testing in your question, you stub it out. Or you could fake it out: make a fake ValidatorService where isValid is implemented as $x === "foo" and write your tests under that premise. That allows you to test that the correct data reaches isValid. | |
| Mar 3, 2014 at 17:22 | comment | added | Songo | well that's exactly what I meant. If I stub only how could I be sure that there isn't another bug that causes it to pass? I need to verify the end result and the way I got there too. | |
| Mar 3, 2014 at 16:45 | history | answered | Sebastian Redl | CC BY-SA 3.0 |