Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple PHP Selenium test doesn't work

I have the following Selenium test in PHP:

<?php

require_once('PHPUnit/Extensions/SeleniumTestCase.php');

class Example extends PHPUnit_Extensions_SeleniumTestCase
{
  protected function setUp()
  {
    $this->setBrowser("*chrome");
    $this->setBrowserUrl("http://change-this-to-the-site-you-are-testing/");
  }

  public function testMyTestCase()
  {
    $this->open("/frontend_dev.php");
    try {
        $this->assertTrue($this->isTextPresent("Local Coupons"));
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors, $e->toString());
    }
  }
}

When I try to run it (by running "php filename.php") I get the error:

PHP Fatal error:  Class 'PHPUnit_Framework_TestCase' not found in /usr/share/php/PHPUnit/Extensions/SeleniumTestCase.php on line 60

Which makes sense because the class isn't defined anywhere, but why not? I installed PHPUnit. It seems a little weird that a class called PHPUnit_Framework_TestCase wouldn't be included with PHPUnit. Any ideas?

like image 782
Jason Swett Avatar asked Mar 30 '26 23:03

Jason Swett


1 Answers

You should read the docs for PHPUnit for the command line test runner. You can also just run 'phpunit --help' from the command line. I believe you'll find that you need to instead run something like

phpunit path/to/filename.php
like image 128
Craig Avatar answered Apr 02 '26 14:04

Craig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!