为什么要在PHP中使用测试框架? [英] Why should I be using testing frameworks in PHP?

查看:82
本文介绍了为什么要在PHP中使用测试框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我听到很多人争相使用PHP测试功能(例如PHPunit和SimpleTest)以及他们选择的IDE(对我来说是Eclipse).在研究了这个主题之后,我仍然很难理解使用这些测试框架来加快开发的利弊.

I have recently heard a lot of people argue about using PHP testing features like PHPunit and SimpleTest together with their IDE of choice (Eclipse for me). After googling the subject, I have still a hard time understanding the pros and cons of using these testing frameworks to speed up development.

如果任何人都可以在更基本的层面上为我解释这一点,我将不胜感激.我正在使用PHP5进行通知.

If anyone could explain this for me in a more basic level, I would really appreciate it. I am using PHP5 for the notice.

非常感谢!

推荐答案

我不是单元测试的忠实拥护者:我并不是说它们没有用,它们在某些情况下非常有用.

I'm not a big fan of unit testing: I'm not saying they're useless, they can be very useful - in certain situations.

问题是有些人倾向于高估单元测试的作用.

The thing is that some people tend to overestimate what they can do with unit test.

只需记住两件事: 1)单元测试不能替代beta测试.即使接口背后的代码有效,不良的接口也仍然是不良的接口. (例如:如果按钮不可点击,则其所连接的功能是否起作用并不重要) 2)单元测试需要时间来编写.如果您是独自开发一个小型项目,或者是一个小组,则可以利用这段时间来改进代码.

Just remember two things: 1) Unit test CANNOT substitute beta testing. A bad interface remains a bad interface even if the code behind it works. (e.g.: if a button is unclickable it doesn't really matter whether the function to which it is attached works or not) 2) Unit test require time to be written. If you're developing a small project alone or in a small team maybe you can use that time to improve your code.

看看这件事(请读一会儿盐,很明显,作者在写作方式上是挑衅性的): http://www.wilshipley. com/blog/2005/09/unit-testing-is-teh-suck-urr.html

And have a look at this (please read it with a pinch of salt, it is obvious that the author is being provocative in the way he writes things): http://www.wilshipley.com/blog/2005/09/unit-testing-is-teh-suck-urr.html

这篇关于为什么要在PHP中使用测试框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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