Timeline for How do I test a system where the objects are difficult to mock?
Current License: CC BY-SA 3.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 16, 2020 at 10:01 | history | edited | CommunityBot | Commonmark migration | |
| Oct 24, 2015 at 8:50 | audit | Suggested edits | |||
| Oct 24, 2015 at 8:51 | |||||
| Oct 12, 2015 at 13:22 | audit | First posts | |||
| Oct 12, 2015 at 13:22 | |||||
| Oct 10, 2015 at 21:56 | vote | accept | durron597 | ||
| Oct 7, 2015 at 10:54 | comment | added | Dan | The saying "all problems in coding can be solved by a layer of indirection (except, of course, the problem of too many layers of indirection)" comes to mind here.. | |
| Oct 7, 2015 at 8:41 | comment | added | Matthieu M. | A perfect illustration of the evil of built-ins. Why does not the library return a Timestamp class (containing any representation they want) and provide named methods (.seconds(), .milliseconds(), .microseconds(), .nanoseconds()) and of course named constructors. Then there would have been no issues. | |
| Oct 7, 2015 at 0:15 | comment | added | jpmc26 | The adapter around the third party library? Yes, that's exactly what I recommend. Those unit tests won't improve your code. They won't make it more reliable or more maintainable. You're just partially duplicating someone else's code at that point; in this case, you're duplicating some poorly written code from the sound of it. That's a net loss. Some of the answers suggest doing some integration testing; that's a good idea if you just want an, "Is this working?" sanity check. Good testing is hard, and it takes just as much skill and intuition as good code. | |
| Oct 7, 2015 at 0:12 | comment | added | durron597 | @jpmc26 so what do you suggest instead? Not unit test my adapter behavior at all? | |
| Oct 7, 2015 at 0:10 | comment | added | jpmc26 | Just gonna add a piece of advice: don't mock third party objects. (From here.) I tend to think this is good advice. | |
| Oct 6, 2015 at 19:23 | history | tweeted | twitter.com/StackProgrammer/status/651477870037086208 | ||
| Oct 6, 2015 at 17:16 | answer | added | cbojar | timeline score: 6 | |
| Oct 6, 2015 at 17:11 | answer | added | Josh Kelley | timeline score: 11 | |
| Oct 6, 2015 at 17:08 | answer | added | svidgen | timeline score: 27 | |
| Oct 6, 2015 at 17:02 | answer | added | Mike Nakis | timeline score: 1 | |
| Oct 6, 2015 at 16:52 | comment | added | cbojar | Someone could write a book on problems like this. In fact, Michael Feathers did write just that book: c2.com/cgi/wiki?WorkingEffectivelyWithLegacyCode In it, he describes a number of techniques for breaking difficult dependencies so that code can become more testable. | |
| Oct 6, 2015 at 16:44 | answer | added | ptyx | timeline score: 5 | |
| Oct 6, 2015 at 16:02 | comment | added | durron597 | I have a fake data feed that I use in integration tests but since I deploy the whole system it's hard to see what the problem is. | |
| Oct 6, 2015 at 15:57 | comment | added | Idan Arye | Can your "record" a real data feed and "play" it later into the third party library? | |
| Oct 6, 2015 at 15:54 | answer | added | BЈовић | timeline score: 2 | |
| Oct 6, 2015 at 15:49 | history | asked | durron597 | CC BY-SA 3.0 |