什么是简单测试?

发布于 2024-08-31 06:10:53 字数 96 浏览 9 评论 0 原文

什么是简单测试? assertTrue($b) 在 SimpleTest 中做什么? PHP 程序员经常使用 SimpleTest 来测试他们的程序吗?

What is SimpleTest? What does assertTrue($b) do in SimpleTest? Do PHP programmers use SimpleTest often to test their programs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你列表最软的妹 2024-09-07 06:10:53

这是一个 PHP 单元测试和 Web 测试
框架。 JUnit 的用户将是
熟悉大部分界面。
JWebUnit 风格的功能是
现在更完整了。它支持
SSL、表单、框架、代理和基本
验证。这个想法是
常见但繁琐的 PHP 任务,例如
登录网站,可以测试
很容易。

http://www.simpletest.org/

It is a PHP unit test and web test
framework. Users of JUnit will be
familiar with most of the interface.
The JWebUnit style functionality is
more complete now. It has support for
SSL, forms, frames, proxies and basic
authentication. The idea is that
common but fiddly PHP tasks, such as
logging into a site, can be tested
easily.

http://www.simpletest.org/

愛放△進行李 2024-09-07 06:10:53

assertTrue($b) 字面上表示您认为 $b 中的值应该是布尔值 true。您还可以申请一些其他条件。您使用给定的输入运行一些代码,之后,给定一组输入,变量(例如函数的返回值)应该是特定的值。

PHPUnit 更流行且最新(如 SimpleTest 有一段时间没有新版本了),尽管对于测试 Webforms,它仍然非常有用,因为 PHPunit 对此没有很好的支持。据说 Simpletest 对一些更高级的技术有更好的支持,称为“Mocking”,用您自己控制的东西替换部分类来进行测试。

使用单元测试框架可以帮助开发更好的代码(请参阅:测试驱动开发) ,并确保在编写代码后不会出现错误(例如,如果您进行了一些小更改以添加新功能,但同时也为一段代码添加了问题)。如果您经常运行单元测试,您可以确信所有正在测试的代码仍然按设计工作。

有关测试的介绍以及为什么这是一个好主意,请参阅 PHPunit 手册有一个很好的页面

The assertTrue($b) literally says that you believe that the value in $b should be a boolean true. There's a number of other conditions you could also claim. You run some code, with a given input, and after that, a variable (say a return from the function), should be a particular value, given the set of inputs.

PHPUnit is more popular and up to date (as SimpleTest hasn't had a new release for some time), though for testing Webforms, it's still very useful as PHPunit does not have good support for that. It's also said that Simpletest has better support for some of the more advanced techniques, called 'Mocking', replacing part of a class to test with something under your own control.

Using a unit-testing framework can help develop better code (see: Test Driven Development), and ensure that bugs do not creep into your code after it's been written (for example, if you make a small change to add new functionality, but you also add a problem for a piece of code). If you run unit tests frequently you can have some confidence that all the code you have that is being tested is still working as designed.

For one introduction to testing, and why it's a good idea, the PHPunit manual has a good page

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文