Index of Current Test Case

$BATS_TEST_NUMBER is the (1-based) index of the current test case in the test file.

$BATS_SUITE_TEST_NUMBER is similar, but for the complete suite.

Examples

Print current test index :

1
2
3
@test "Example" {
  echo "Index: $BATS_TEST_NUMBER" >&3
}
BashSupport Pro is a Bash IDE with support for $BATS_TEST_NUMBER – try it now!
© 2020–2022 Joachim Ansorg
Imprint
Privacy Policy
Legal