Skip to content

File Relativity does not behave as expected #552

Closed

Description

@bobjackman

Given the following files:

/tmp/phpUnitIssues/relativity/IncompleteTest.php:

class IncompleteTest extends PHPUnit_Framework_TestCase
{
    public function testIncomplete( )
    {
        $this->markTestIncomplete( );
    }
}

/tmp/phpUnitIssues/relativity/SkippedTest.php:

class SkippedTest extends PHPUnit_Framework_TestCase
{
    public function testSkipped( )
    {
        $this->markTestSkipped( );
    }
}

/tmp/phpUnitIssues/relativity/configuration.xml:

<phpunit>
  <testsuites>
    <testsuite name="relativity">
        <file>SkippedTest.php</file>
        <file>/tmp/phpUnitIssues/relativity/IncompleteTest.php</file>
    </testsuite>
  </testsuites>
</phpunit>

Running the tests with the following command(s) behaves as expected:

cd /tmp/phpUnitIssues/relativity/;
/usr/bin/phpunit --configuration configuration.xml

Which results in expected test output of
SI

However, running the tests with the following command(s) does not behave as expected:

cd /tmp/phpUnitIssues/;
/usr/bin/phpunit --configuration ./relativity/configuration.xml

Which results in test output of
I

The test "SkippedTest" is never run, because it is not found. The paths supplied in the configuration XML seem to be relative to the CWD rather than to the file itself. This requires a user to be in the appropriate directory before running the tests.

Consider the following:

cd /usr/local/bin/apache/htdocs;
<do some work here. editing, configuring, etc, etc>
/usr/bin/phpunit --configuration /tmp/phpUnitIssues/relativity/configuration.xml

PHPUnit will run, and the configuration file will be found, but the relative paths in the configuration file will break. Now, in order to run the tests, the user must leave the directory he's in for the appropriate testing directory, and then run the tests. If there is a failure, he must then change directories back to where he was, and continue working.

I would suggest that all paths inside the configuration file are treated as relative to the config file itself rather than the CWD.

Activity

  1. edorian commented on Apr 21, 2012

    @edorian
    SponsorContributor

    There have been quite a lot of issues with ,the phpunit.xml.dist and relatives pathes.

    I don't remember the whole story but I will investigate it. I believe the inconsistency is there because of BC reasons but it at least could look up 2 places.

  2. edorian commented on Sep 12, 2012

    @edorian
    SponsorContributor
  3. locked as resolved and limited conversation to collaborators on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions