I have a client/server program and I want to make sure that its components are working correctly.
What are the best practices for writing unit-tests for such network-oriented programs?
The only thing that comes to my mind is writing some basic clients/servers that connect to main server/client, exchanges some specific packets and verify the responses.
Are there any better or simpler approaches?
This issue is not uncommon, and is an even more common scenario in the case of DB-oriented programs. That’s why people invented mocks.
The idea is that you don’t really need a client (or a server for that mater), you only need responses to your actions from some (possibly unknown) source. That’s exactly what a mock does. It fakes an implementation of an interface, and lets you tell it exactly how to react to each call it receives. Your replace your calls to the network (or DB) layer classes with calls to the mock that’s implementing their actions.
P.S, Even google can mock