Skip to content

[4.x] Add dependsExternal (depend on tests in external test files)#1678

Open
Ajility97 wants to merge 8 commits intopestphp:4.xfrom
Ajility97:feat/cross-file-test-dependencies
Open

[4.x] Add dependsExternal (depend on tests in external test files)#1678
Ajility97 wants to merge 8 commits intopestphp:4.xfrom
Ajility97:feat/cross-file-test-dependencies

Conversation

@Ajility97
Copy link
Copy Markdown

@Ajility97 Ajility97 commented Apr 16, 2026

What

  • Bug Fix
  • New Feature

Description

The existing depends() method does not support dependencies across test files. In larger test suites, it can be useful to reuse values returned by tests defined in other test cases.

This PR introduces a chainable dependsExternal() method, which allows a test to depend on tests defined in another test file. It accepts the target test file as the first argument, followed by one or more dependency test names as variadic arguments.

Example usage:

test('depends on tests in an external file', function (string $first, string $second) {
    expect($first)->toBe('first');
    expect($second)->toBe('second');
})->dependsExternal('Tests\\Features\\Depends', 'first', 'second');

Related:

#969
#1059
#1054

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant