8

可能重复:
简单测试与 PHPunit

我是软件开发良好实践的新手。我需要知道我应该使用女巫测试单元框架。我看到有些人使用 PHPUnit,有些人使用 SimpleTest。我应该为初学者选择什么套餐?

此致,

4

5 回答 5

25

我真的困惑 Simpletest 仍然被认为是 phpunit 的替代品。也许我只是被误导了,但据我所知:

  • PHPUnit 是标准;大多数框架都使用它(如 Zend Framework、Cake、Agavi,甚至 Symfony 也在 Symfony 2 中为 phpunit 放弃了自己的框架)。
  • PHPUnit 集成在每个 PHP IDE(Eclipse、Netbeans、Zend Stuide、PHPStorm)中并且运行良好。
    • Simpletest 有一个 PHP 5.1 的 Eclipse 扩展(又名太老了,它在 sourceforge 上),没有别的。
  • PHPUnit 与每个连续集成服务器都可以正常工作,因为它输出所有标准日志文件以获取代码覆盖率和测试报告。
    • Simpletest 没有。虽然这不是一个大问题,但一旦你停止“只是测试”并开始开发软件,它就会给你带来很大的麻烦(是的,这句话很挑衅:) 不要太认真)。
  • PHPUnit 积极维护、稳定,适用于每一个代码库、每一个场景以及你想要编写测试的每一种方式。
    • Simpletest 未维护、过时并且不能很好地与 PHP 5.3(一年多前发布)一起使用
  • (主观)PHPUnit 提供比 Simpletest更好的代码覆盖率报告
    • 使用 PHPUnit,您还可以在 IDE(Netbeans、Eclipse、...)中获取这些报告

我还没有看到任何支持 Simpletest 的论据。由于 PHPUnit 可通过 pear 获得,因此安装起来并不简单:

pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit

和“第一次测试”看起来几乎一样。

对于您想要测试的所有内容,PHPUnit 都会有一个解决方案,并且您几乎可以在任何地方找到帮助(SO,freenode 上的#phpunit irc 频道,几乎每个 php 开发人员;))

如果我说错了什么或忘记了什么,请纠正我:)

于 2011-01-07T13:27:45.047 回答
5

I started with SimpleTest because the learning curve didn't seem as steep. But it's not maintained, and brings up loads of warnings in PHP5.3, as well as not being able to do everything I wanted. I eventually had to switch to PHPUnit, which was a long process converting my tests. If only I'd started with PHPUnit in the first place!

于 2011-01-07T09:39:14.367 回答
2

SimpleTest is slightly easier to grasp, but PHPUnit is the best ( in my opinion at least ) , so if you want to start learning and using a framework, start with the one you're going to use when you'll be a master in TDD. Don't look at if it's easier or harder now , because if you start with SimpleTest for example , then you start using Zend Framework because your boss tells you so , you'll have to use PHPUnit with ZF. So think of your future , because an easy to learn framework doesn't necessarily have to be the best one , usualy the harder to grasp the better the framework .

Also have a look at their revisions , see which one is maintained better .

于 2011-01-07T09:38:34.647 回答
0

我发现 SimpleTest 易于启动,并且可用于我的目的。目前没有发现大问题。手册/网站有点混乱,但是通过一些示例搜索就足够了。

感觉不是很专业,但是当你要求初学者框架时,一定要试试那个:)

于 2011-01-07T09:32:21.867 回答
0

这是一个很好的阅读...这使用 SimpleTest 并且开始它比 PHPUnit 更好...

单元测试新手指南

于 2011-01-07T09:33:16.040 回答