您的Web应用程序或网站中是否有健康检查?
过去,我已经为多个项目构建了基于PHP的运行状况检查"脚本,但是这些脚本始终是为这种情况而定制的,而不是作为独立产品抽象编写的.我想知道是否存在这样的解决方案.
I have built PHP based "health check" scripts for several projects in the past, but they were always custom-made for the occasion and not written for abstraction as an independent product. I would like to know whether such a solution exists.
我通过运行状况检查"评估的是一个受保护的网页,其功能类似于一组单元测试,但在操作性更高的级别上,显示诸如此类的红色/黄色/绿色状态
What I meam by "health check" is a protected web page that functions much like a suite of unit tests, but on a more operational level, showing red/yellow/green statuses for things like
- 缓存目录可写吗?
- PHP版本是否正确,是否安装了必需的扩展名?
- 数据库服务器是否可以访问?
- 数据库中是否存在必需的表?
- 是否有足够的可用磁盘空间?
- 网站的首页是否可以访问并且可以完全呈现(=没有PHP错误)?
- 项目库的MD5校验和与原始校验和相符吗?
- 首页的输出是否通过W3C验证程序?
您是否在应用程序和网站中执行此操作(或部分操作)?
Do you do this - or parts of it - in your applications and web sites?
是否有标准化的工具来结合所有功能来执行测试(理想情况下是作为插件),并且只需要进行相应的配置?
Are there any standardized tools for this that bring along all the functionality to perform the tests (ideally as plugins), and just need to be configured accordingly?
我正在谈论一种轻量级的解决方案,该解决方案甚至可以在基于PHP的最小的Web程序包上运行,而无需扩展名和服务器访问权限.
I am talking about a lightweight solution that can run even on the tiniest of PHP-based web packages with no extensions and server access.
也许有一种使用可用于PHP的单元测试框架(最好是PHPUnit)进行设置的方法吗?如果是这样,您知道概述任何方法的资源/教程吗?
Is there, maybe, a way to set this up using one of the Unit Testing frameworks available for PHP (preferably PHPUnit)? If so, do you know any resources / tutorials outlining how?
更新:似乎没有流行的现成解决方案,否则,如果有100多个视图,我敢肯定会提到它.看到对构建像开源项目这样的工具有一些最初的兴趣,请随时发布适合您的理想解决方案以及它必须具备的功能.
Update: There does not seem to be a popular ready-made solution for this, otherwise, with more than 100 views, I'm sure there would have been some mention of it. Seeing as there's some initial interest in building such a tool as an open source project, please feel free to post what an ideal solution for you would look like, and what features it would have to have.
有趣的问题,但这很广泛.我还没有看到可以同时进行所有后端,中端和前端测试的单元测试工具.我检查了此列表,但没人能做到.但是,有一种通用方法 xUnit (全自动测试).
Interesting question, but this is pretty broad. I haven't seen an unit testing tool yet which does all the backend, midend and frontend testing at once. I checked this list, but no one does it all. There is however one generic approach, xUnit (fully automated testing).
主要的阻碍因素是,后端测试是特定于平台/数据库的,而中期测试是特定于编程语言的.然后再将这些限制与前端测试结合起来.然后,该工具应该必须支持全世界所知道的几乎所有语言和平台.我认为这样的工具永远不会在开源世界中可用.这是一个乌托邦.
The major blockers are that backend testing is platform/DB specific and that midend testing is programming-language specific. And then yet to combine those limitations with frontend testing. The tool should then have to support almost all languages and platforms the world is aware of. I don't think such tool would ever be available in open source world. It's an utopia.
从理论上讲,确实有可能有一个具有插件功能的测试框架,也许是基于xUnit意识形态的,但是还没有人编写/发明/开源它.你?这确实是市场上的一个空洞.
In theory it's indeed possible to have a testing framework with plugin capabilities, maybe based on the xUnit ideology, but one has yet to write/invent/opensource it. You? It's indeed a hole in the market.
无论如何,对于前端单元测试(HTML/CSS/JS/forms),我建议 Selenium ,或者如果您有钱,请 TestComplete .几年前,我已经在IBM看到了它的使用,看到它在运行中真是太棒了,测试人员对此感到非常满意.
At any way, for frontend unit testing (HTML/CSS/JS/forms) I would recommend Selenium, or if you have the money, TestComplete. I have seen it been used at IBM several years back, it was awesome to see it in action and the testers were very happy with this.
对于中端单元测试(编程代码,业务逻辑),只需继续使用特定于编程语言的单元测试工具,例如适用于PHP的PHPUnit 和适用于Java的 JUnit .
For midend unit testing (programming code, the business logic), just continue with the programming language specific unit testing tools like PHPUnit for PHP and JUnit for Java.
关于后端单元测试(数据库,文件系统),我已经将 PGTap 用于PostgreSQL,但是也有可用于此目的的通用数据库工具,例如 SQLUnit (但是最近更新了将近4年...) .对于本地磁盘文件系统条件,您必须使用平台特定的脚本语言.
Regarding backend unit testing (DB, filesystem), I've used PGTap for PostgreSQL, but there are also generic DB tools available for this such as SQLUnit (which is however last updated almost 4 years back...). For the local disk file system conditions you'll have to grab platform specific scripting languages.