bashunit
bashunit copied to clipboard
Display total number tests
Current
When running ./bashunit, at the end, we know the total of tests and assertions:
Expected
The task is to calculate these numbers (total of tests and assertions) in advance, and display them at the very beginning to have early feedback of how many of them will be there.
Observation
These numbers are currently calculated on the fly, as we go. There might be a way to search and find by pattern these numbers, let's assume the following:
- tests: are all functions starting with
testin all testing scripts - assertions: functions being called that start with
assertinside each test
HINT
Something like this might help
function helpers::find_test_functions() {
local dir=${1:-tests}
grep -r -E '^\s*function\s+test' "$dir" --include=\*.sh 2>/dev/null \
| wc -l \
| xargs
}
Calculating assertions count for a test with dataprovider(s) is not possible/easy, I guess?
@staabm, good point. I think it would be possible but not as straight forward. We could start having this logic as first PR for the tests only and we will figure out later the assertions.
Related: add a loader bar while runing the tests I found this great example here https://github.com/kndndrj/shload by @kndndrj This might be a great follow up in another task