How to run a test in PHPUnit + Selenium?

I have everything installed, and I can create and run tests in NetBeans mode by right-clicking the test in the project menu and selecting Run. The problem is that the browser windows opened to close the test immediately after the test starts - this means that the only reporting I have is what NetBeans provides, and this is not enough. I don’t think I want to use the command line, plus I have not had much success in the past anyway.

Is it possible to simply specify the browser in the test.php file? When I try to do this, I get this error:

Fatal error: class 'PHPUnit_Framework_TestCase' not found in C: \ xampp \ php \ PEAR \ PHPUnit \ Extensions \ SeleniumTestCase.php on line 275

Can't I run these tests from another machine? those. PC1 is my dedicated test box for selenium, and I want to tell him to run test.php from PC2 remotely.

Where should my test files go?

How to configure report / output from test script?

0
source share
2 answers

I found out how to run my test files remotely - I just created a script that would execute phpunit from the command line:

<?php exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output); echo "<pre>". var_export($output,TRUE)."</pre>"; exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output); echo "<pre>". var_export($output,TRUE)."</pre>"; ?> 

then I can just click the URL of this script to run it - it works fine, but I still think there should be a better / easier way ...

0
source

You can add sleep(60) at the end of your test :) This will prevent PHPUnit from closing the Selenium session.

Alternatively, save selenium tests as html files compatible with the Selenium IDE Firefox extension and let the test just run in your browser.

0
source

All Articles