vendredi 27 septembre 2019

How to test a program in bash? (functional testing)

For example I have a program gcd that return the greatest common divisor that I call with:

$ ./gcd 42 36
6

I could test these input with:

#!/bin/bash 

[[ $(./a.out 42 36) == "6" ]] || exit 1
[[ $(./a.out 42 11) == "1" ]] || exit 1

Unfortunately with this I do not have any summary such as

ran 11 tests, 0 failures, 11 successful tests

Is there any very simple template/framework to do such testing at program level (not unit testing)?

Aucun commentaire:

Enregistrer un commentaire