-
Notifications
You must be signed in to change notification settings - Fork 518
Easy way to run just one test #164
Comments
Unfortunately Bats can't do this. Yet! A similar feature, running only tests whose description matches a pattern, has been proposed in #36 and #117. But due to the lack of free time of the maintainer it was never merged. Being able to run tests by their number would be incredibly useful. Especially since the TAP format output ( Manpower has been gathering in #150 to continue development towards 1.0. I've been going through the issue tracker as well as my own list of suggestions and been writing up a list of changes I will suggest for the next release. This feature has been at the top my list already! This feature may take time to bake once development restarts, but thinking of its usefulness I think it will definitely arrive sooner or later. Until then see the workaround below! Stay tuned! WorkaroundSince #!/usr/bin/env bats
run_only_test() {
if [ "$BATS_TEST_NUMBER" -ne "$1" ]; then
skip
fi
}
setup() {
run_only_test 2
}
@test 'test #1' {
true
}
@test 'test #2' {
true
}
@test 'test #3' {
true
} When run, it will only run the second test and skip all others.
Note: |
if [ "$BATS_TEST_NUMBER" -ne "$1" ]; then That is brilliant solution. Accepting this as solution for now. |
@bcv Glad it works for you! One more thing. |
Might be more convenient to use the test description than the number:
|
Hi
Is there a way I can specify just to run one test ?
I have written around 42 tests of which only one is failing. To fix, I have to just run the 41st test. I end up running all other 41 before it.
I can add skip to each and every test to skip them but this is combersome and while checking-in the bats test script into a version control system I have to remove the skip commands
Is there a way to say
bats -t filename testnumber
or something in those lines ?
The text was updated successfully, but these errors were encountered: