Can anyone help me to get this working, please?
I have installed netbeans v6.8, phpunit v3.5 and netbeans’ plugin “Selenium Module for PHP” v1.0. I started with an empty webapp created by yiic, then created a new netbeans project with existing source.
Setting up the test directory was the first trouble: for some reason, I can’t do that in the project properties (text field takes no input). So I tried to generate a test case for the LoginForm model. This drives netbeans to ask for a test folder, which I set to protected/tests. The generation of the unit test fails, because PHPUnit doesn’t find the class CFormModel. But the project explorer now shows a folder “Test Files” below “Source Files”. Guess that is okay…
Now I thought it was time to check if unit testing works, so I put a dummy test for LoginForm into tests/unit:
class LoginFormTest extends CTestCase
public function testRules()
$loginForm = new LoginForm();
// just wanna know if PHPUnit works
$this->assertTrue( count($loginForm->rules()) === 3 );
When I tried to run that test, PHPUnit again complained that it didn’t know CTestCase, so I configured it to use tests/bootstrap.php as bootstrap file. Now the single test passes, but I can’t figure out how I would run all my unit tests?
Pressing <Alt> + <F6> took a while, and resulted in some errors. Something about IE could not been started (sure, I’m on Ubuntu right now) and that a connection to selenium rc could not be established. Until this point, I only wanted to do some unit testing, so I don’t know why netbeans tried to start functional tests. Maybe because of the “functional” folder within the “Test Files”? I can only guess, that netbeans tries to start every file within this folder if you just say “test”…
Okay, moving on. Trying to get functional tests working…
I reviewed WebTestCase.php (changing the TEST_BASE_URL), bootstrap.php (seems okay) and phpunit.xml (removing the browser entry for IE). I also configured PHPUnit to use the phpunit.xml file as XML configuration and disabled the bootstrap checkbox, since the xml seems to configure it already.
Single unit test still works, <Alt> + <F6> still fails. Some Details: LoginFormTest passes, SiteTest is skipped (no valid test cases found), SiteTest (Firefox) fails (could not connect to selenium rc server). So SiteTest seems to be executed twice, first as unit test, second as functional test. Not what I intended to do…
Trying to run only functional tests, I came across the problem, that the menu entry wasn’t enabled. I told netbeans to create a new “Selenium Test Case for PHP”, which again brought up a dialog that allowed me to specify a test folder. A chose protected/tests again, then canceled the dialog. Now I was able to select “Run selenium tests” from the project folder. The output was exactly the same as when I pressed <Alt> + <F6>. Still no connection to selenium rc server, plus unit tests I didn’t intend to run.
Last try: select different folders for unit testing and functional testing. Since die IDE doesn’t provide a possibility to configure these settings once they are set, I edited nbproject/project.properties. I set test.src.dir to protected/tests/unit and selenium.src.dir to protected/tests/functional. This gave me a new folder in the project explorer: Besides “Source Files” and “Test Files”, there were now a folder called “Selenium Test Files”.
Result: Single Test still worked. <Alt> + <F6> still tries to do everything (isn’t it possible to only do unit tests?!), “Run Selenium Tests” also tries to do everything. Pretty annoying.
I also tried to configure the selenium plugin to use chrome instead of firefox, but without luck, same result (can’t connect to selenium rc server). I’m pretty sure it is running, since I can’t start it manually from the console (downloaded it before I realized the plugin comes with its own copy). If I exit netbeans, I can start it manually.
Is there anyting I’ve missed? Something I haven’t yet though of? More configuration files that need to be ajusted? I’m really running out of ideas here…