Skip to content

HowTo Unit Test Client Server Code

I’m currently writing a Java Client Server Application. So i want to implement two Libraries, one for the Client and one for the Server. The Client Server Communication has a very strict protocol, that I wan’t to test with JUnit.

As build tool im using Maven and a Husdon Server for continues Integration.

Actually I do not have any good Idea how to test these Client / Server Libraries.

I got following Approaches:

  1. Just write a Dummy Client for testing the server and write a Dummy Server to test the Client. Disadvantages: Unfortunately this will result in many extra work. I could not be 100% sure that client and Server could work together, because I’m not sure that the Tests are completely identical.

  2. Write an separate Test Project that Tests the Client and the Server together.
    Disadvantages: The Unit Tests does not belong to the Project it self, so Hudson will not run them automatically. Everyone who changes anything at one of these Libraries, will have to run the Tests manually to ensure, everything is correct. Also i will not receive any Code Coverage Report.

Are there any better approaches to test codes like that? Maybe test a Maven Multi Module Project, or something like that.

I hope any one got a good solution for that Issue.




So finally the resolution was to build a Multi Module Project, with a separate Test Module that includes the Server and the Client Module Works great in Husdon. And even better in the Eclipse IDE. Thanks @ Aaron for the hint

5 People found this is helpful