views:

265

answers:

2

i have seen the power of selenium and that it can give you the tests in different languages.

so the question is, why should i use phpunit or lime (for symfony) when a solution like selenium is available?

isn't it time-consuming to write all the tests by hand, when you can just use selenium?

thanks.

+3  A: 

phpunit and seleniukm do not test the same things phpunit test a unit of code selenium is designed for testing integrattion/functional testing of several modules together.

I think you need both types of tests. phpunit for unit testing and selenium for interface testing. The phpunit manual even explains how to integrate the two.

http://www.phpunit.de/manual/3.1/en/selenium.html

Also this article explains the purpose of both. http://software-testing-zone.blogspot.com/2007/01/unit-testing-versus-functional-tests.html

I understand the desire to use selenium for everything it seems so simple, you can just click and write a test, but it really is a a case of needing both. You may want to pick up a copy of "Expert PHP 5 Tools"

http://www.amazon.com/Expert-PHP-Tools-Dirk-Merkel/dp/1847198384/ref=sr_1_1?ie=UTF8&s=books&qid=1273111115&sr=8-1

It covers the different types of tests and their use quite well.

Steve Robillard
so phpunit does not do functional tests? lime is doing both. would you say that using selenium for functional tests is much more better than using lime and/or phpunit? cause apparently u dont have to code to test, u just have to test which seems to save a lot of time.
never_had_a_name
You can also do functional testing in phpunit. It would work the same and functional testing in lime... though if i recal there isnt a web client built in so you would have to use something like sfTestBrowser/sfWebBrowserPlugin or Zend_Http_Client. However Selenium isnt going to build unit tests for you i dont think (ive never used it)
prodigitalson
no exactly it doesn't build unit test and functional testing is not a replacement for unit test nor are unit tests a replacement for functional tests - that is my whole point.
Steve Robillard
ok so bottom line: phpunit/lime for unit tests, selenium for functional tests right? cause my point is that it's unnecessary to use phpunit/lime for functonal tests when you can just use selenium and it supports javascript.
never_had_a_name
A: 

Well in the case of sf+lime there is some good integration directly in the framework. And lime is so simple that tests take little time to write at all. Personally i prefer phpunit, but when i use symfony i just stick with lime because its the path of least resistance and sppeds things up. There is/was a php unit plugin for sf but ive never used it - i figured why bother. Now for other non-sf projects i use phpunit when needed simply because its no more difficult than hooking up lime.

prodigitalson
are you using lime's functional tests or selenium for those? why should one use lime's functional tests when selenium is "click and run" and you save a lot of time?
never_had_a_name
in symfony projects i use lime for all functional/unit testing. ive never used selenium but i always got the impression it GUI based tool at least for the initial creation of the tests. Id rather jsut write the code my self. That is faster than clicking through a sequence of events and recording them then outputing them to a language. but maybe im wrong about that..? Also from what i gather its not for use with unit testing (ie testing the entire public interface of a class)... like i said ive never used selenium.
prodigitalson
another thing good about selenium is that it works with javascript. something i guess isn't possible with phpunit/lime. so for Ajax applications its better to use selenium for functional tests and lime/phpunit for unit tests. i guess?
never_had_a_name