Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow recursive test directories #74

Closed
skuzzle opened this issue Feb 22, 2023 · 0 comments
Closed

Allow recursive test directories #74

skuzzle opened this issue Feb 22, 2023 · 0 comments
Milestone

Comments

@skuzzle
Copy link
Owner

skuzzle commented Feb 22, 2023

The @FilesFrom annotation already has a flag to enable recursive scanning for test input. We could support the same for @DirectoriesFrom.
When recursively iterating directories, we need a way to determine which directory will be actually used as test input and which directory just represents an intermediate level for structuring the tests.

Suggested API:

This test will only use leave directories (those that don't contain any other directories) as input:

    @ParameterizedTest
    @DirectoriesFrom(testResourcesDirectory = "test-directories-recursive", recursive = true)
    void testDirectoriesRecursivelyDefaultFilter(TestDirectory directory, Snapshot snapshot) throws IOException {
        // ...
    }

This test uses a TestDirectoryFilter for selecting the directories that are used as actual test input

    @DirectoriesFrom(testResourcesDirectory = "test-directories-recursive", recursive = true,
            filter = SampleTestDirectoryFilter.class)
    void testDirectoriesRecursivelyCustomFilter(TestDirectory directory, Snapshot snapshot) throws IOException {
        // ...
    }

    static class SampleTestDirectoryFilter implements TestDirectoryFilter {

        @Override
        public boolean include(TestDirectory testDirectory, boolean recursive) throws IOException {
            return testDirectory.containsFile("input.txt");
        }

    }
@skuzzle skuzzle added this to the 1.9.0 milestone Feb 22, 2023
@skuzzle skuzzle closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant