Skip to content

@Parameters method is executed before @ClassRule initialization. Could it be the way around? #671

Closed as not planned
@javornikolov

Description

@javornikolov

I have the following problem (using junit 4.11):

    @ClassRule
    public static TemporaryFolder tmp = new TemporaryFolder();
    ...
    @Parameters
    public static Collection<Object[]> data() throws Exception {
        return java.util.Arrays.asList(new Object[][] {
            {0, tmp.getRoot().getPath()}
        });
    }

This results in initializationError

java.lang.IllegalStateException: the temporary folder has not yet been created
    at org.junit.rules.TemporaryFolder.getRoot(TemporaryFolder.java:127)

So seems the @parameters method is executed before the ClassRule initialization phase which makes scenarios like above one a bit complicated.

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