Can't addFile() in SimpleTest Test Suite

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob Wilkerson

    Can't addFile() in SimpleTest Test Suite

    Hey guys -

    I have a test suite that's working when I include a test case via its
    absolute path. For portability, I'd rather include it just using its
    name, but it's failing with a "Failed to Open" error and I can't
    figure out why. Hopefully someone more familiar with SimpleTest can
    point me in the right direction (or point out my stupidity, as the
    case may be).

    Here are the highlights of my config:

    - SimpleTest is installed in a support directory (~/projects/support/
    simpletest) so that the framework can be used for multiple apps.

    - The application is installed in ~/projects/work/myapp and its tests
    are ~/projects/work/myapp/tests

    - ~/projects/work/myapp/tests contains both all_tests.php and
    my_test_case.ph p

    - My include_path includes ~/projects/support/simpletest and "."

    - all_tests.php looks like this:

    <?php
    require_once ( 'autorun.php' );

    class AllTests extends TestSuite {
    public function AllTests() {
    $this->TestSuite ( 'All tests' );
    $this->addFile( 'my_test_case.p hp' );
    }
    }
    ?>

    The error:

    Warning: SimpleFileLoade r::include_once (my_test_case.p hp)
    [function.Simple FileLoader-include-once]: failed to open stream: No
    such file or directory in /home/myusername/projects/support/simpletest/
    test_case.php on line 391

    Warning: SimpleFileLoade r::include_once () [function.includ e]: Failed
    opening 'my_test_case.p hp' for inclusion (include_path=' .:/usr/share/
    php:/home/myusername/projects/work/shared-services/classes:/home/
    myusername/projects/support/simpletest') in /home/myusername/projects/
    support/simpletest/test_case.php on line 391

    Warning: file_get_conten ts(my_test_case .php) [function.file-get-
    contents]: failed to open stream: No such file or directory in /home/
    myusername/projects/support/simpletest/test_case.php on line 428

    Any thoughts would be much appreciated.

    Thanks.

    Rob
  • Rob Wilkerson

    #2
    Re: Can't addFile() in SimpleTest Test Suite

    Woops. Sorry about the duplicate post. And crap. Just realized
    what's probably happening. It's autorun.php that's probably trying to
    do the include and that, of course, is failing. How do most folks
    structure their environment? Clearly I'm doing it all wrong.

    Thanks.

    Comment

    • Jerry Stuckle

      #3
      Re: Can't addFile() in SimpleTest Test Suite

      Rob Wilkerson wrote:
      Woops. Sorry about the duplicate post. And crap. Just realized
      what's probably happening. It's autorun.php that's probably trying to
      do the include and that, of course, is failing. How do most folks
      structure their environment? Clearly I'm doing it all wrong.
      >
      Thanks.
      >
      Use a relative path based off of the website root directory, which can
      be found in $_SERVER['DOCUMENT_ROOT'].

      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Rob Wilkerson

        #4
        Re: Can't addFile() in SimpleTest Test Suite

        On Sep 29, 1:51 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        Use a relative path based off of the website root directory, which can
        be found in $_SERVER['DOCUMENT_ROOT'].
        Thanks, Jerry. That worked of course:

        $this->addFile( $_SERVER['DOCUMENT_ROOT'] . '/my_test_case.ph p' );

        Is this pretty much the "standard" way of including files in a test
        suite?

        Comment

        • Jerry Stuckle

          #5
          Re: Can't addFile() in SimpleTest Test Suite

          Rob Wilkerson wrote:
          On Sep 29, 1:51 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          >Use a relative path based off of the website root directory, which can
          >be found in $_SERVER['DOCUMENT_ROOT'].
          >
          Thanks, Jerry. That worked of course:
          >
          $this->addFile( $_SERVER['DOCUMENT_ROOT'] . '/my_test_case.ph p' );
          >
          Is this pretty much the "standard" way of including files in a test
          suite?
          >
          It's the way I do it - and a lot of other people I know. It makes
          things easier - you can include the file without worrying about what
          directory the including file is in.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Rob Wilkerson

            #6
            Re: Can't addFile() in SimpleTest Test Suite

            On Sep 29, 4:02 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            It's the way I do it - and a lot of other people I know.  It makes
            things easier - you can include the file without worrying about what
            directory the including file is in.
            Fair enough. That works for me. Thanks for your help.

            Comment

            Working...