Answer the question
In order to leave comments, you need to log in
How to organize unit testing of a network application?
I am writing a server application. It is necessary to organize unit testing. I am using cmake, boost unit test. There was a difficulty how best to organize the automatic start of the server before the start of the tests, and then its completion after the end of the tests.
Example scenario:
- starting the server
- running unit tests related to working with the server
- terminating tests
- shutting down the server
Answer the question
In order to leave comments, you need to log in
To implement unit testing, we had to reorganize the architecture of the server software. The disadvantage was the loss of time for reorganization, but, fortunately, there was not so much code to forward something. A huge plus was that the code became more beautiful. For example, due to adjustment to unit tests, it was necessary to create a handler for received packets, create additional processing queues, allow the programmer to assign his own handlers, etc. Thus, the entire verification procedure was reduced to the code level: separate calls for starting, stopping, transmitting data, receiving them, and processing them. Without adjusting to unit tests, it is unlikely that the project would have made it possible to assign handlers on its own.
Look towards docker or vagrant, integration testing and so on.
Those. prepare a container with the necessary environment and set your sample script as a container start script + add loading the results to a shared folder or CI system.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question