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 7944625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:36:28+00:00 2026-06-04T00:36:28+00:00

Methods like verifyText do not report the line number of the failure, making it

  • 0

Methods like verifyText do not report the line number of the failure, making it hard to find the point of failure.

The code created by Selenium IDE PHPUnit export looks like this:

try {
    $this->assertEquals($text, $this->getTitle());
} catch (PHPUnit_Framework_AssertionFailedError $e) {
    array_push($this->verificationErrors, $e->toString());
}

The output for this line looks like line 2 below, which is completely untraceable

Failed asserting that '' matches PCRE pattern "/Harlem/".
Failed asserting that two strings are equal.
Failed asserting that '(Pattern A)' matches PCRE pattern "/\(Pattern B\)/".

I’ve amended the call to include the referenced text which lets me search for the text failure, but in a large test this is not sufficient. How do I get the line number/stacktrace for each verify failure within my code?

public function verifyTitle($text) {
    $title = $this->getTitle();
    try {
        $this->assertEquals($text, $title);
    } catch (PHPUnit_Framework_AssertionFailedError $e) {
        array_push($this->verificationErrors,
             "Title is '$title' but should be '$text'");
    }
}

Note: in order to get stacktraces returning references to my code for asserts, I am using the stacktrace hack

  • 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-06-04T00:36:30+00:00Added an answer on June 4, 2026 at 12:36 am

    Created this verification Method to include (too much) stacktrace:

    public function appendVerification($message,$e) {
            array_push($this->verificationErrors,$message."\n".$this->dumpStack($e));
    }
    

    I also updated the referenced dumpStack method for PHPUnit tests to dumbly strip out framework calls by class name

    protected function dumpStack(Exception $e) {
        $stack = '';
        foreach ($e->getTrace() as $trace) {
            if (isset($trace['file']) &&
                    isset($trace['line'])) {
                if (!isFramework($trace['file']))
                    $stack .= PHP_EOL .
                            $trace['file'] . ':' .
                            $trace['line'] . ' ';
            }
        }
        return $stack;
    }
    
    function isFramework($fileName) {
       $test = ((preg_match("/PHPUnit/i",$fileName) +
               preg_match("/php.phpunit/i",$fileName)) > 0);
       return $test;
    }
    

    End result, clickable in netbeans, free of any PHPUnit framework line numbers

    Failed asserting that 'waitForElementPresent failed for selector: css=input#address.valid' is false.
    C:\dev\Automation_Dev\phpTests\library\SeleniumUtilsTestCase.php:228
    C:\dev\Automation_Dev\phpTests\library\SeleniumUtilsTestCase.php:115
    C:\dev\Automation_Dev\phpTests\library\SeleniumTestCase.php:176
    C:\dev\Automation_Dev\phpTests\usecases\CreateListingTest.php:72
    C:\dev\Automation_Dev\phpTests\usecases\CreateListingTest.php:39
    C:\dev\Automation_Dev\phpTests\usecases\CreateListingTest.php:23
    C:\xampp\php\phpunit:46
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been able to find methods like -[NSString stringWithCString:encoding:] but they do not
Most web browsers support only HTTP methods like GET and POST and do not
I just came across various overloading methods like type of parameter passed, varying number
I'm talking about methods like this: $object->method()->method1('param')->method2('param'); Those are created by returning the object
i can write methods like that public void CompareEmail() { some code } public
Rails models come with certain built-in methods like this: Appointment.new Appointment.find(1) How do I
I have a lot of methods like these in a serviceContract I'm making: TemplateContract
How can I overload the STL implementation for methods like find, erase and insert
Are there any implementations of all the nifty Selenium on Rails methods like wait_for_visible
Many methods like stop() , resume() , suspend() etc are deprecated. So is it

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.