unit testing with BOOST

Jan 20, 2015 at 10:44 PM
I am attempting to do some unit testing. I saw a thread about being able to use the client and server test files located in Release\tests\Functional\http\utilities. But there really is not much documentation and the comments inside the code are not very helpful either.

I'm sure I could struggle through this for a day or two and work it all out, but I am in a time crunch with lots more testing to do, so if someone could share how to use these objects in an example that would be very helpful. I'm sure I can't be the only one trying to unit test their final client and server implementation.

My current test case would be to create my client and send a request. Then to use the casablanca test server to recieve the request and return a specified response. My client would then receieve the response and I will verify that it is the response I am expecting. That's it!

Should be simple enough but it would be much faster with a working example if anyone has one already built?

I should point out that I am new to the client server world, so I am also welcome to any suggestions or advice anyone might have on improving my unit testing and other possible test cases that you would reccomend trying, ie client timeout with no response ect...

Thanks very much,
Jan 21, 2015 at 9:43 PM
Hi Robyn,

Yes we don't have a lot documentation regarding the tests. My recommendation would be to open up and take a look at the HTTP client test cases for how the test server can be used. Try opening the VS project under Release\tests\functional\http\client\vs12\HttpClient120_test.vcxproj. For example look at some of the test cases in request_helper_tests.cpp. The test_http_server class basically creates a simple HTTP server that will queue up received requests. You can asynchronously or synchronously be notified about each request using test_http_server::wait_for_request or test_http_server::next_request APIs. A pointer to a test_request structure is returned which contains the HTTP request data and allows you to respond with data. There is a RAII structure to help with opening/closing the test server, test_http_server::scoped_server.

Please note we could change and potentially break the API of the test utilities in the future, really at anytime.