Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:36:02+00:00 2026-05-30T21:36:02+00:00

I have Selenium server working with PHPUnit on a MAMP local server. When an

  • 0

I have Selenium server working with PHPUnit on a MAMP local server.

When an Assert fail, the failed number line is not showing, instead I see a phpunit number line.

When I execute a “phpunit only” test I can see the number line of the failed assert.

PHPUnit only test

$ cd '/Applications/MAMP/htdocs/my-client/tests' && phpunit -c 'phpunit.xml'  '/Applications/MAMP/htdocs/my-client/tests/controllers/homeTest.php'
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /Applications/MAMP/htdocs/my-client/tests/phpunit.xml

.

Time: 0 seconds, Memory: 8.00Mb

There was 1 failure:

1) HomeTest::test_get_sections
Failed asserting that Array (
    blah, blah, blah
    )
) is identical to Array (blah, blah, blah2
    )
).

/Applications/MAMP/htdocs/my-client/tests/controllers/homeTest.php:56
/Applications/MAMP/bin/php/php5.3.6/bin/phpunit:46

FAILURES!
Tests: 2, Assertions: 3, Failures: 1.

PHPUnit Selenium test

$ cd '/Applications/MAMP/htdocs/my-client/tests' && phpunit -c 'phpunit.xml'  

'/Applications/MAMP/htdocs/my-client/tests/views/af_web_Test.php'
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /Applications/MAMP/htdocs/my-client/tests/phpunit.xml

E

Time: 2 seconds, Memory: 8.75Mb

There was 1 error:

1) af_web_Test::test_crear_una_af_nueva_y_validar_el_valor_por_defecto_de_los_campos
Current URL: http://localhost:8888/my-client/index.php/home/view

Failed asserting that '' matches PCRE pattern "/0/".

/Applications/MAMP/bin/php/php5.3.6/bin/phpunit:46

FAILURES!
Tests: 1, Assertions: 6, Errors: 1.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:36:03+00:00Added an answer on May 30, 2026 at 9:36 pm

    I’ve had the same problem (albeit on a LAMP server), as I quite rely on these line numbers along with screenshots to figure out exactly what’s going wrong in my tests. The bug, which I assume this is, is apparently reported. See https://github.com/sebastianbergmann/phpunit-selenium/issues/81 for reference.

    As a temporary workaround I’ve forced the line number into the error message in the exception that is being thrown (because the line number can of course be found in the trace). As a side-effect, most exceptions are rethrown and I am only throwing PHPUnit_Framework_Error, but at least I get the line number in the output. As a temporary workaround until this is fixed, this works for me.

    To achieve this, I extend PHPUnit_Extensions_SeleniumTestCase with my own SeleniumTestCase, and put these functions in it:

    Very slightly modified version of this function for my own use: https://stackoverflow.com/a/6608751

    protected function dumpStack(Exception $e) {
        $stack = '';
        foreach ($e->getTrace() as $trace) {
            if (isset($trace['file'])        &&
                isset($trace['line'])        &&
                isset($trace['class'])       &&
                isset($trace['function']))
            {
                $stack .= PHP_EOL .
                    $trace['file']     . ':' .
                    $trace['line']     . ' ' .
                    $trace['class']    . '::' .
                    $trace['function'];
            }
        }
        return $stack;
    }
    

    I override onNotSuccessfulTest from PHPUnit_Extensions_SeleniumTestCase:

    protected function onNotSuccessfulTest(Exception $e) {
        try {
            parent::onNotSuccessfulTest($e);
        }
        catch (PHPUnit_Framework_IncompleteTestError $e) {
            // Don't do anything with the incomplete test exception
            throw $e;
        }
        catch (PHPUnit_Framework_SkippedTestError $e) {
            // Don't do anything with the skipped test exception
            throw $e;
        }
        catch (Exception $e_parent) {
            // Include line number for specific test file in error
            $error_msg = chr(10).chr(10).$this->dumpStack($e);
    
            throw new PHPUnit_Framework_Error($e_parent->getMessage().$error_msg, $e_parent->getCode(), $e_parent->getFile(), $e_parent->getLine(), $e_parent->getTrace());
         }
    }
    

    I don’t like this hack, so if anyone has a better solution, I’d be happy to hear it!

    UPDATE:
    I forgot to mention this initially: You of course have to make the tests extend your own custom SeleniumTestCase, and not the PHPUnit_Extensions_SeleniumTestCase.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[FAILURE: Could not contact Selenium Server; have you started it on 'localhost:4444' ? Read
I am trying to use PHPUnit with selenium I start the server java -jar
We want to run selenium backed jwebunit tests from our hudson server. We have
I have selenium grid 2 hub running on one server. I start up another
I have quite a fundamental problem that none of my selenium phpunit tests pass
I exported a working Selenium test case to Java, running it via selenium-rc's selenium-server.jar
We have Capybara working with the selenium driver but when I try to use
I have written an Ant target that starts Selenium server, runs my test code,
I am currently running Selenium commands through PHPUnit to a remote server. I've run
Does anybody have any idea why Selenium RC server takes a long time to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.