DEV Community

Discussion on: Sociable Tests: Integration tests without the pain!

Collapse
 
kahdev profile image
Kah

Nice article! I think both approaches have their trade offs. Sure the social test has less lines of code, but it also "relies" on PricingEngine working correctly. Don't get me wrong - that could be totally fine too!

If you were using the social unit test approach, would you also have a separate test just for PricingEngine.calculatePrice?

Collapse
 
dylanwatsonsoftware profile image
Dylan Watson

Yep I think they both have their merits.
But the trade-off as I see it is, would you rather:
1) needing to change the tests for all the classes that depend on yours, when you change a method signature (or move it entirely)
OR
2) Have the occasional extra test break, when you actually make a breaking change to functionality?

With regards to PricingEngine, it probably depends on how complicated it is... But I would usually expect it to have its own set of tests... Though I did always like the idea of testing functionality in groups rather than classes... Since classes can change and be refactored away.