How do you unit-test a TCP Server? Is it even worth it?

后端 未结 8 1210
一整个雨季
一整个雨季 2021-02-05 10:03

I\'m developing a small TCP server, which will process some TCP packets and behave differently based on the request.

How can I write unit test for this? If it\'s really

8条回答
  •  伪装坚强ぢ
    2021-02-05 10:43

    It's certainly worth the effort. What I've dome for a HTTP small server=based app I'm working on is have aseries of scripts that fire requests at the server using wget. I then usen diff to compare the saved wget output with what I expected to get, and report any fifferences. I run this bunch of scripts every time I change the server, and it has caught a lot of errors.

    Obviously, this only works for HTTP servers, but it will be worth your while to write a small app that can fire TCP requests at your server and save the results.

提交回复
热议问题