<p>I am trying to run a SeleniumTestCase with phpunit but I cannot get it to run with the phpunit.bat script. </p>

<p>My goal is to use phpunit with Selenium RC in CruiseControl &amp; phpUnderControl. This is what the test looks like:</p>

<pre><code>require_once 'PHPUnit/Extensions/SeleniumTestCase.php';

class WebTest extends PHPUnit_Extensions_SeleniumTestCase
{
    protected function setUp()
    {
        $this-&gt;setBrowser('*firefox');
        $this-&gt;setBrowserUrl('http://www.example.com/');
    }

    public function testTitle()
    {
        $this-&gt;open('http://www.example.com/');
        $this-&gt;assertTitleEquals('Example Web Page');
    }
}
</code></pre>

<p>I also got PEAR in the include_path and PHPUnit installed with the Selenium extension. I installed these with the pear installer so I guess that's not the problem. </p>

<p>Any help would be very much appreciated. </p>

<p>Thanks, Remy</p>

[{'answer_id': 77955, 'author': 'Ciaran', 'author_id': 5048, 'author_profile': 'https://Stackoverflow.com/users/5048', 'pm_score': 1, 'selected': False, 'text': '<p>Have a look at one of the comments in the require_once entry in the php manual..</p>\n\n<p><a href="http://ie.php.net/manual/en/function.require-once.php#62838" rel="nofollow noreferrer">http://ie.php.net/manual/en/function.require-once.php#62838</a></p>\n\n<p>"require_once (and include_once for that matters) is slow</p>\n\n<p>Furthermore, if you plan on using unit tests and mock objects (i.e. including mock classes before the real ones are included in the class you want to test), it will not work as require() loads a file and not a class."</p>\n'}, {'answer_id': 78065, 'author': 'Remy', 'author_id': 12645, 'author_profile': 'https://Stackoverflow.com/users/12645', 'pm_score': 1, 'selected': False, 'text': '<p>I just renamed the file my test was in to "WebTest.php" (the name of the class it contains) and the test runs fine now.</p>\n'}, {'answer_id': 425050, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Well when I use inline command : if lauching test from PhPunit dir i have the error while whent launching it from test dir I havne't the error ...</p>\n\n<p>but I still haven't any acces to selenium server ... shall I have to launch it before or not.</p>\n\n<p>If Yes it's strange that we havne't to specify any handle to PhPUnit ...</p>\n"}, {'answer_id': 472548, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Here is the deal:</p>\n\n<p>If you have a "Class PHPUnit_Extensions_SeleniumTestCase could not be found in (testcase file name)" problem, you have to do the following two things:</p>\n\n<p><strong><em>1. Rename the file of test case to the name of the class it contains</em></strong>\n<strong><em>2. You should launch phpunit from the folder with your tests.</em></strong></p>\n\n<p>This should fix your problem.</p>\n\n<p>Andrew</p>\n'}, {'answer_id': 590774, 'author': 'scc', 'author_id': 46183, 'author_profile': 'https://Stackoverflow.com/users/46183', 'pm_score': 1, 'selected': False, 'text': "<p>Do not presume that the pear install occurred without problems.</p>\n\n<p>I had installed phpunit through pear but despite it saying the install went fine when I looked inside the folder, I had all these files starting with .tmp, eg PHPUnit/Util/.tmpErrorHandler.php so naturally when i ran a test for the 1st time it gave me the same error as above. After checking that indeed the file wasn't there I did a manual install of PHPUnit to the same folder as pear and alas, all was fine. I'm in Mac/leopard.</p>\n\n<p>About Selenim RC don't forget to start it by running in terminal\njava -jar /path/to/file/selenium-server.jar</p>\n"}, {'answer_id': 2146178, 'author': 'CruiZen', 'author_id': 232647, 'author_profile': 'https://Stackoverflow.com/users/232647', 'pm_score': 1, 'selected': False, 'text': "<p>I found that the following sample from PHPUnit tutorial was working while the same error appeared in the test that I had written.\nThe solution was a surprise. Ensure that your class is inside a <code>&lt;?php .. ?&gt;</code> block and not a <code>&lt;? .. ?&gt;</code> block in the script.</p>\n\n<pre><code>&lt;?php\nrequire_once 'PHPUnit/Framework.php';\n\nclass StackTest extends PHPUnit_Framework_TestCase\n{\n    public function testPushAndPop()\n    {\n        $stack = array();\n        $this-&gt;assertEquals(0, count($stack));\n\n        array_push($stack, 'foo');\n        $this-&gt;assertEquals('foo', $stack[count($stack)-1]);\n        $this-&gt;assertEquals(1, count($stack));\n\n        $this-&gt;assertEquals('foo', array_pop($stack));\n        $this-&gt;assertEquals(0, count($stack));\n    }\n}\n?&gt;\n</code></pre>\n"}, {'answer_id': 4456097, 'author': 'farinspace', 'author_id': 97433, 'author_profile': 'https://Stackoverflow.com/users/97433', 'pm_score': 4, 'selected': False, 'text': '<p>hopefully this is a more definitive answer then the ones given here (which did not solve me problem). If you are getting this error, check your PEAR folder and see if the "SeleniumTestCase.php" file is actually there:</p>\n\n<pre><code>/PEAR/PHPUnit/Extensions/SeleniumTestCase.php\n</code></pre>\n\n<p>If it is NOT, the easiest thing to do is to uninstall and reinstall PHPUnit using PEAR ...</p>\n\n<pre><code>pear uninstall phpunit/PHPUnit\n\npear uninstall phpunit/PHPUnit_Selenium\n\npear install phpunit/PHPUnit\n</code></pre>\n\n<p>After doing the above and doing just the single install, PHPUnit_Selenium was also auto installed, I\'m not sure if this is typical, so some might have to do...</p>\n\n<pre><code>pear install phpunit/PHPUnit_Selenium\n</code></pre>\n\n<p>Also see <a href="http://www.phpunit.de/manual/3.5/en/installation.html" rel="noreferrer">http://www.phpunit.de/manual/3.5/en/installation.html</a> for PEAR channel info if needed...</p>\n'}, {'answer_id': 9059767, 'author': 'mosid', 'author_id': 1023151, 'author_profile': 'https://Stackoverflow.com/users/1023151', 'pm_score': 1, 'selected': False, 'text': '<p>Here is how i solved this problem:</p>\n\n<ol>\n<li>Make sure that curl extension for php is installed,\n e.g for ubuntu <code>sudo apt-get install php5-curl</code></li>\n<li>Enter <code>sudo  pear install phpunit/PHPUnit_Selenium</code></li>\n</ol>\n\n<p>After that you should have the missing file installed</p>\n\n<p>Happy coding...</p>\n'}, {'answer_id': 21568125, 'author': 'JTHouseCat', 'author_id': 3113435, 'author_profile': 'https://Stackoverflow.com/users/3113435', 'pm_score': 0, 'selected': False, 'text': '<p>When it fails it doesn\'t always print out the most verbose error messages. </p>\n\n<p>Always remember to start Selenium too prior to running test.</p>\n\n<p>java -jar selenium-server-standalone-2.39.0.jar</p>\n\n<p>Here is an example of code that was working for myself. <a href="http://www.siteconsortium.com/h/p1.php?id=php002" rel="nofollow">http://www.siteconsortium.com/h/p1.php?id=php002</a>. Obviously there are a lot of different way to write the test suite, and launch the test case but I used the set_class_path to get rid of class issues at first.</p>\n'}, {'answer_id': 26145421, 'author': 'Slava  Nikoolin', 'author_id': 4099507, 'author_profile': 'https://Stackoverflow.com/users/4099507', 'pm_score': 1, 'selected': False, 'text': '<p>Try:</p>\n\n<pre><code>class WebTest extends \\PHPUnit_Extensions_Selenium2TestCase\n</code></pre>\n\n<p>It can be namespace issue, as it was for me.</p>\n'}]
['https://Stackoverflow.com/questions/77835', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12645/']