Coupling and Testability

Coupling is the degree to which one section of code depends on another. Clearly, test code depends on the code it tests based on the nature of that relationship. For black-box testing, test code depends on the interface of the test target as well as any data types or dependent interfaces or signatures used in the interface. If a method takes a type in its parameter list, the calling code—and therefore the tests—need to be able to obtain or create that type. When a method returns a type, the calling code uses that value, expressing a degree of knowledge about that type. The same holds true even when interfaces are used because interfaces specify types. Functional, procedural, and dynamic languages are not immune to this ...

Get Quality Code: Software Testing Principles, Practices, and Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.