sstephenson/bats

exit on first failure?

Opened this issue · 5 comments

I haven't been able to find documentation on this yet (hopefully I just overlooked it) but I'd like to have bats exit on first failure when being invoked as bats /path/to/tests/*.bats.

Is this possible?

Bats can't do this yet. Though, adding the option would be certainly useful.

This really blows that bats can't do this. I'm willing to do the work if someone could point me in the right direction.

Here is a workaround:

#!/usr/bin/env bats

setup() {
    [ ! -f ${BATS_PARENT_TMPNAME}.skip ] || skip "skip remaining tests"
}

@test "foo" {
    true
}

@test "foo2" {
    false
}

@test "foo3" {
    true
}

teardown() {
    [ -n "$BATS_TEST_COMPLETED" ] || touch ${BATS_PARENT_TMPNAME}.skip
}

Excellent! Thank you.

Wow; what a simple solution. Here I was killing the parent process and having a tough time of it.

Thank you!