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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:32:48+00:00 2026-06-09T12:32:48+00:00

Currently, I have a PHPUnit test case that extends PHPUnit_Extensions_SeleniumTestCase. Each function that starts

  • 0

Currently, I have a PHPUnit test case that extends PHPUnit_Extensions_SeleniumTestCase. Each function that starts requires a $this->setBrowserUrl() and defaults to starting a new Firefox browser window with each function call.

I want to have a test case that launches the browser for specific functions, but not launch the browser for other functions, as to save the resources and time it takes in opening and closing the browser. Is it possible for me to have such a file?

  • 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-09T12:32:49+00:00Added an answer on June 9, 2026 at 12:32 pm

    Figured out a custom solution using PHPUnit annotations (and wrote a blog post about it!)

    http://blog.behance.net/dev/custom-phpunit-annotations

    EDIT: Adding some code here, as to make my answer more complete 🙂

    In short, use custom annotations. In your setUp(), parse the doc block to grab annotations, and tag tests with different qualities. This would allow you to tag certain tests to run with a browser, and certain tests to run without.

    protected function setUp() {
    
      $class      = get_class( $this );
      $method     = $this->getName();
      $reflection = new ReflectionMethod( $class, $method );
      $doc_block  = $reflection->getDocComment();
    
      // Use regex to parse the doc_block for a specific annotation
      $browser = self::parseDocBlock( $doc_block, '@browser' );
    
      if ( !self::isBrowser( $browser )
        return false;
    
      // Start Selenium with the specified browser
    
    } // setup
    
    private static function parseDocBlock( $doc_block, $tag ) {
    
     $matches = array();
    
      if ( empty( $doc_block ) )
        return $matches;
    
      $regex = "/{$tag} (.*)(\\r\\n|\\r|\\n)/U";
      preg_match_all( $regex, $doc_block, $matches );
    
      if ( empty( $matches[1] ) )
        return array();
    
      // Removed extra index
      $matches = $matches[1];
    
      // Trim the results, array item by array item
      foreach ( $matches as $ix => $match )
        $matches[ $ix ] = trim( $match );
    
      return $matches;
    
    } // parseDocBlock
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHPUnit test suite that is currently causing a fatal error due
i currently have a list of classes every class starts a scheduler like this:
i have this simple rule: .PHONY: test test: src/*Test.php $(PHPUNIT) $?;\ it will look
Currently have a drop down menu that is activated on a hover (from display:none
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have one project that currently contains multiple packages. These packages make up
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
Currently have this code defining getter/setter for an object's selectedID property. The object is
Currently have this to get a value from the registry in TSQL. However, I
Currently I have the following code for a project that represents some probability trees

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.