Also related is TDD
because writing a test first forces you to focus on module interface early and from the point of view of the module user.
In your example discussion, module tests that employed a mock DNS server running on a different port would have
caught this specific module interface issue before the module was released.
Not only that, having your own mock DNS server controlled by your tests makes it easier to test module robustness
and recovery (for example, how your module handles timeouts, broken connections, data corruption, ...).