B
B
Boris Dergachev2014-11-19 15:14:57
C++ / C#
Boris Dergachev, 2014-11-19 15:14:57

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

2 answer(s)
B
Boris Dergachev, 2015-03-12
@froex

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.

B
brutal_lobster, 2014-11-20
@brutal_lobster

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 question

Ask a Question

731 491 924 answers to any question