HTTP server for unit tests in Delphi

I need to test some HTTP components in my Delphi application. I am using DUnit and want to add some automation to the testing.

So, my test code needs to start a local HTTP server, configure it (for example, prepare for disconnection in 3 seconds or simulate low bandwidth or request a username / password, etc.), run my unit tests and close the HTTP server .

Are there some HTTP servers for Delphi / DUnit?

I know that the Mozilla team has such a server , but it is not too easy to integrate it into DUnit.

+6
source share
3 answers

I use Indy TIdHttpServer to feed stuff in the same process.

This approach allows me to check the correctness of incoming requests, as well as check the behavior from the end of the client.

In addition, you can individually configure the server for a test test case using a test test, which will simplify your unit tests (which means that you do not have a part of the “test” elsewhere).

+9
source

You can use unit test / DUnit to create automatic integration tests. Say you, HTTP components, like an http client, call a web service. You can make your own web service layout or just use any public web service, for example, one from Google or Amazon. Therefore, you just need to create a Google or Amazon developer account and use some basic maintenance features for testing.

0
source

If you are testing SOAP services, use SoapUI to support a mock-up service based on your WSDL. You can force it to return various responses (sequentially or use some simple scripts to match responses to the contents of the request). I did this by matching the “request identifier” (GUID only) in my request sent with DUnit to the response in SoapUI. This is a simple xpath request to match them.

You can force it to return "canned" errors / exceptions, and of course, if it does not work, you will have a test case of "no one at home."

0
source

Source: https://habr.com/ru/post/909437/


All Articles