Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

exit on first failure? #135

Open
michaelshobbs opened this issue Dec 17, 2015 · 5 comments
Open

exit on first failure? #135

michaelshobbs opened this issue Dec 17, 2015 · 5 comments

Comments

@michaelshobbs
Copy link

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?

@ztombol
Copy link

ztombol commented Dec 18, 2015

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

@michaelshobbs
Copy link
Author

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.

@vincentbernat
Copy link

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
}

@michaelshobbs
Copy link
Author

Excellent! Thank you.

@carlosonunez
Copy link

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

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants