HowTo Unit Test Client Server Code

后端 未结 5 1945
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 03:55

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

5条回答
  •  一向
    一向 (楼主)
    2020-12-29 04:42

    The latest approach to solve this problem is by using Docker containers. Create a docker file containing a base image and all the necessary dependencies required for your client server application. Create a separate container for each node type of your distributed client-server system and test all the entry point server API/client interactions using TestNG or JUnit. The best part of this approach is that you are not mocking any service calls. In most cases you can orchestrate all the end-to-end client-server interactions.

    There is a little bit of learning curve involved in this approach but Docker is becoming highly popular in the Dev community especially for solving this problem.

    Here is an example of how you could use docker client api to pull docker images in your JUnit test: https://github.com/influxdb/influxdb-java/blob/master/src/test/java/org/influxdb/InfluxDBTest.java

提交回复
热议问题