in reply to Re: Best Approach: package module tests with tcp
in thread Best Approach: package module tests with tcp

My apologies, but how to test using Test::MockObject seems simple according to the documentation. Where I fall down however is what and how to test in context.

Testing an object that munges text or does calculations is pretty straight forward I would think. You know the in and out going into the test. But what about a network client in which there isn't one method to test, but instead it's the whole connect/send/receive/disconnet conversation that needs to be tested? It is at that point that I don't understand or have a clue where to start, esp without a server to conect to or a mock server to use.

-=Chris

  • Comment on Re: Re: Best Approach: package module tests with tcp

Replies are listed 'Best First'.
Re: Re: Re: Best Approach: package module tests with tcp
by chromatic (Archbishop) on Jan 24, 2003 at 21:08 UTC

    If something's hard to test, that's a sign that it could be simpler. Break it into smaller pieces based on logical behavior. If you have a function that connects to a socket and logs some data and prints some data, turn it into three functions.

    I'd start with the functions that only expect a live socket connection to be passed in, mock one up, and see what happens there.