Skip to content

The file attribute of <testClass> node of XML test list can be wrong #6097

Open
@mondrake

Description

Q A
PHPUnit version 10.5.38
PHP version 8.3
Installation Method Composer

Summary

ListTestsAsXmlCommand builds the file attribute of each <testClass> node by getting the file path of the first test case method found in a class, and using the file path returned by calling $test->valueObjectForEvents()->file().

This is not accurate as this returns the file path of the file where the method is defined, not the file path of the class. The method could be defined in a parent base class, or in a trait, and then the file returned would not be the one where the TestCase class is contained.

Current behavior

See above.

How to reproduce

Make an abstract base TestCase class with test case methods in it, a separate concrete class with no methods extending the abstract, and run phpunit with the --list-tests-xml option. The file attribute of the concrete <testClass> will point to the abstract class file and not to the concrete one.

Expected behavior

The file path should match the class, as the autoloader will map.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions