My project is of client/server type. The client side is using Java and the server side is using C. It uses socket to send data via packets to the clients. Clients communicating to server with the same way: using socket.
We are told to do "unit test" on each sides. For my server side, I have to test my C code. The problem is that if I don't modify the code, it will try to connect to the client therefore it is no longer a "unit test" but some kind of intergration test.
1. Hard code the "send" and "receive" packet part of the code, use printf or use debugging mode ( gdb ) to confirm "send" and "receive" data step by step.
This is very time consuming, we have to do the same thing with all the codes, and we have to remove test code after unit test is finished.
I think there must be more effective ways to do "unit test" with my case, and "unit test" in general client/server model.
Please share your opinions how to test such kind of code ( unit test ).
I am thinking of a new way to test my C code, without connecting to the client side ( so it will be independent to the Java programs ). So far, only one idea pops up in my mind: