bash_test_tools icon indicating copy to clipboard operation
bash_test_tools copied to clipboard

How do I run more then one test file?

Open evan108108 opened this issue 8 years ago • 1 comments

Lets say I have the following directory and test files:

testDir: -- myTestA.sh -- myTestB.sh -- ect...

How do I go about running all the tests? Do I have to run them one at a time?

Thanks. Great Framework!

evan108108 avatar Aug 30 '16 18:08 evan108108

Hi Evan, Thanks for compliment - you may well be the first user besides me, so expect bugs. To answer your question first, in case its not clear in docs... in your test scripts you can define as many tests as you like

function test_foo1 { ... } function test_foo2 { ... } etc...

and they will all run when you execute the script.

Regarding calling tests from other scripts, that is a feature that I have not given thought to.

For now you could do one of three things,

  1. as you said run them all at one time,
$ for x in testDir/*.sh; do ./$x; done
  1. create a master script that runs those other scripts one at a time, inside some run_all_tests.sh execute,
testDir/myTestA.sh
testDir/myTestB.sh
  1. if those other files contain only test functions then you could just source them in your master script,
source bash_test_tools
source myTestA.sh
source myTestB.sh
testrunner

Downside you would need to use same setup and teardown for all the tests, or just skip defining setup and teardown.

Maybe these suggestions are a bit clumsy. I'm sure it would be easy to improve these things. Can you describe your particular use case better?
Is your goal to organize your tests better into separate files? Should those files also be runnable?

thorsteinssonh avatar Aug 31 '16 16:08 thorsteinssonh