Quantcast
Channel: User Filip Milovanović - Software Engineering Stack Exchange
Viewing all articles
Browse latest Browse all 164

Comment by Filip Milovanović on TDD and code reusability

$
0
0
You design the new component so that the reusable part is constructor-injected into it. In the test suite for the new component, you only write tests for the behavior that strictly relates to the new component itself. You inject a mock to "simulate" misc scenarios involving the reusable component, but you only "simulate" as much as needed for a specific test method. I.e., the mock (or the way it's configured) is specific to each particular test method, and only returns canned values and supports called methods, without actually replicating the internal workings of the real dependency.

Viewing all articles
Browse latest Browse all 164


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>