用于Delphi中单元测试的HTTP服务器 [英] HTTP server for unit tests in Delphi

查看:163
本文介绍了用于Delphi中单元测试的HTTP服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的Delphi应用程序中测试一些HTTP组件。我使用DUnit并希望在测试中添加一些自动化功能。

I need to test some HTTP components in my Delphi app. I use DUnit and want to add some automation into testing.

所以我的测试代码需要启动本地HTTP服务器,配置它(例如,在3秒内准备连接中断,或者模拟低带宽,或者询问对于登录/密码等),运行我的单元测试并关闭HTTP服务器。

So my testing code need to start the local HTTP server, configure it (for example, prepare for connection break in 3 seconds, or to simulate low bandwidth, or to ask for login/password etc), run my unit-tests and close HTTP server.

是否有一些HTTP服务器可用于Delphi / DUnit?

Are there some HTTP servers available exactly for Delphi/DUnit?

我知道Mozilla团队有这样的服务器,但将它集成到DUnit中并不容易。

I know that Mozilla team have such server, but it's not too easy to integrate it into DUnit.

推荐答案

我使用Indy的 TIdHttpServer 在同一进程中提供东西。

I use Indy's TIdHttpServer to serve stuff in the same process.

这种方法可以让我检查进来的请求是否正确,以及检查来自的行为客户端。

This approach allows me to check that the requests coming in are correct, as well as checking the behaviour from the client end.

此外,您可以逐个测试用例在测试用例上单独设置服务器,使您的单元测试更容易理解(意味着您没有一个在其他地方测试。

Also, you can individually set up the server on a testcase by testcase basis, making your unit tests easier to understand (meaning that you don't have a piece of the 'test' somewhere else).

这篇关于用于Delphi中单元测试的HTTP服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆