您为 Symfony 使用哪个单元测试框架?

2022-01-25 00:00:00 unit-testing php symfony1 phpunit

您为 Symfony 使用哪个单元测试框架?

Which unit testing framework do you use for Symfony?

Lime 还是 PHPUnit?使用它们的优缺点是什么?

Lime or PHPUnit? What are the pros and cons of using them?

推荐答案

在我看来,我想到了以下几点:

In my opinion, here are a few things that come to my mind :

  • PHPUnit 与其他工具的集成度更高,例如,
    • Selenium(PHPUnit 可以用它打开真正的浏览器来测试你的网站)
    • phpUnderControl 用于连续集成
    • PHPUnit is more integrated with other tools, like, for instance,
      • Selenium (PHPUnit can use it to open true real browsers to test your site)
      • phpUnderControl for continuous-integration

      但请注意,我不使用 symfony,也不使用石灰...
      不过,除了那些使用 symfony 的人之外,我从未听过任何人谈论它——这不是一件好事,因为有一天你将不得不使用另一个框架(是的,这会发生 ^^)

      But note I don't work with symfony, nor lime...
      Still, I've never heards anyone speak about it, except for those working with symfony -- that not a good thing, for the day you'll have to work with another framework (yes, this happens ^^ )


      PHPUnit 中没有的一件事:


      One thing that's not in PHPUnit :

      • 假"浏览器(能够向应用程序发出 HTTP 请求,无需使用 Selenium 打开真正的浏览器)

      但有些框架(Zend Framework 确实如此,它的 Zend_Test 组件) 与 PHPUnit 集成(或使用它),同时允许将数据注入 MVC 并获取响应,而无需发出任何 HTTP 请求.
      我不知道 symfony 是否允许这样做,但对于 ZF/PHPUnit 来说这是一件好事 ^^

      But some frameworks (Zend Framework does, with it's Zend_Test component) integrate with PHPUnit (or use it), while allowing injection of data into the MVC and fetching of the response, without having to issue any HTTP Request.
      I don't know if symfony allows that, but that's a nice thing with ZF/PHPUnit ^^


      (是的,不是特定于 symfony 的答案;但我所说的内容必须仍然适用于该框架)

相关文章