Open 030 opened 7 years ago
In general you must use an external tool to do this. A tool specific to generate a code coverage report from the test execution.
I am about to try integrate some tool for code coverage into my own test, perhaps bashcov or kcov.
It seems like a discussion on code coverage is ongoing in the new repo for Bats.
Not sure if this is the right place to ask, but does anyone have an example (command and index.html output) of kcov working with bats??? Problem: When the following command is run (kcov being fed bats bash file with arguments): kcov [outputdir]/coverage/ bats [bats_test_path]/test_AFF_Simple.bats the OUTPUT is 0% code coverage for the "bats" only with 20 lines instrumented and 0 hit. This is the file output:
Coverage Report
Command:batsLine numberDate:2018-06-13 19:44:55Instrumented lines:20HitsCode covered:0.0%Executed lines:0Order | Command: | bats | Line number | Date: | 2018-06-13 19:44:55 | Instrumented lines: | 20 | Hits | Code covered: | 0.0% | Executed lines: | 0 | Order Command: | bats | Line number Date: | 2018-06-13 19:44:55 | Instrumented lines: | 20 | Hits Code covered: | 0.0% | Executed lines: | 0 | Order
2 30 set -e 4 50 export BATS_READLINK='true' 60 if command -v 'greadlink' >/dev/null; then 70 BATS_READLINK='greadlink' 80 elif command -v 'readlink' >/dev/null; then 90 BATS_READLINK='readlink' 10 fi 11 12 bats_resolve_link() { 130 if ! "$BATS_READLINK" "$1"; then 140 return 0 15 fi 16 } 17 18 bats_absolute_path() { 190 local cwd="$PWD" 200 local path="$1" 210 local result="$2" 22 230 while [[ -n "$path" ]]; do 240 cd "${path%/}" 250 path="$(bats_resolve_link "${path##/}")" 26 done 27 280 printf -v "$result" -- '%s' "$PWD" 290 cd "$cwd" 30 } 31 320 export BATS_ROOT 330 bats_absolute_path "$0" 'BATS_ROOT' 340 BATS_ROOT="${BATS_ROOT%/*}" 350 exec "$BATS_ROOT/libexec/bats" "$@"
Any and ALL help is appreciated. Note: I managed to get code coverage for PYTHON files; but NOT for BAT files....
Thanks, -Alex
Is there any updates about the bats coverage?
@sunwei There isn't going to be any updates in this repo. I would advise you to move over to https://github.com/bats-core/bats-core, as that is where active development has moved after the call for maintainers in issue #150
Is it possible to show the code coverage when bats has been run?