bashunit icon indicating copy to clipboard operation
bashunit copied to clipboard

Display total number tests

Open Chemaclass opened this issue 1 year ago • 2 comments
trafficstars

Current

When running ./bashunit, at the end, we know the total of tests and assertions:

Screenshot 2024-07-14 at 00 51 01

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 test in all testing scripts
  • assertions: functions being called that start with assert inside 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
}

Chemaclass avatar Jul 13 '24 22:07 Chemaclass

Calculating assertions count for a test with dataprovider(s) is not possible/easy, I guess?

staabm avatar Jul 20 '24 17:07 staabm

@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.

Chemaclass avatar Jul 21 '24 07:07 Chemaclass

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

Chemaclass avatar Sep 01 '24 09:09 Chemaclass