Skip to content

Execution order of dynamically registered tests #860

@jandubois

Description

@jandubois

I just found out that dynamically registered tests have now been implemented (#349), and they are awesome! Thank you so much for implementing this!

I have one question though: could the dynamically registered tests be executed after the statically defined tests from the file? Right now they are executed first:

$ cat test.bats
@test 'First test' {
    true
}

second_test() {
    true
}

bats_test_function --description 'Second test' -- second_test

$ ./bats-core/bin/bats test.bats
test.bats
 ✓ Second test
 ✓ First test

2 tests, 0 failures

It is of course possible to force the order by dynamically registering all the tests in a file, but that feels a bit clumsy.

Maybe it is a lack of my imagination, but I don't see when I would ever want to run the static tests last. If I have a mix of static and dynamic tests, then the static tests may provide some initial setup that is being utilized by the dynamic test matrix later.

I know there is setup_file, but I may want to run the setup in @test functions because it is part of the functionality being tested, and may fail at various points too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Bash CodeEverything regarding the bash codePriority: HighBroken behavior in specific environments like in parallel mode or only on some operating systemsType: Enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions