TDD, Unit Test and architectural changes

Posted by Leandro on Stack Overflow See other posts from Stack Overflow or by Leandro
Published on 2010-05-25T14:24:48Z Indexed on 2010/05/25 15:11 UTC
Read the original article Hit count: 166

Filed under:
|
|

I'm writing an RPC middleware in C++. I have a class named RPCClientProxy that contains a socket client inside:

class RPCClientProxy {
  ...
  private:
    Socket* pSocket;
  ...
}

The constructor:

RPCClientProxy::RPCClientProxy(host, port) {
  pSocket = new Socket(host, port);
}

As you can see, I don't need to tell the user that I have a socket inside.

Although, to make unit tests for my proxies it would be necessary to create mocks for sockets and pass them to the proxies, and to do so I must use a setter or pass a factory to the sockets in the proxies's constructors.

My question: According to TDD, is it acceptable to do it ONLY because the tests? As you can see, these changes would change the way the library is used by a programmer.

© Stack Overflow or respective owner

Related posts about c++

Related posts about unit-testing