# Testing communications and epiphanies

A simple metaphor to explain what TDD is about to me.

## MY belief before

Before going to PHPForum Paris and listening to this enlightening talk I used, or thought I used, TDD to keep objects isolated. Just researching the word in my blog will come up with far too much results dealing with it.
What Konstantin Kudryashov exposed is a simple truth: to make objects testable each object has to expose its communications and its relations.

## The metaphor

Think of an object as a black box: testing it means not knowing how it works inside and just knowing what goes into it and what comes out of it.
Tests relying on inside knowledge of the box are missing the point: set up pre-conditions, test post-conditions, set up input and test the output.
If I ever need to know how an object works inside than I know I’m trying to make two, or more, objects into one.
And still that temptation lingers (code from function-mocker tests)

/**
* @test
* it should build an instance mock using a mock object and its invocation matcher
*/
public function it_should_build_an_instance_mock_using_a_mock_object_and_its_invocation_matcher() {
$sut = FunctionMocker::mock(__NAMESPACE__. '\SomeClass::instanceMethod');$this->assertSame($sut->__invocation,$sut->__object...
}

and is wrong as it’s peeking at the inner workings…