Blog

More TCs, Vicar? (Hiccupps)

On December 4, 2015, in Syndicated, by Association for Software Testing
0

Several times in recent months I’ve found myself being asked how many test cases there are in automated suites at Linguamatics. On each occasion I have had to admit that I don’t know and, in fact, I’m not particularly motivated to calculate that particular metric.

Depending on how the conversations went, I’ve asked in return what my questioner thinks we can understand about the quality, coverage, relevance, value and so on of testing by knowing the number of cases. (And let’s leave vocabulary aside for now.)

Are you a counter? Try this scenario: you wrote sum, a program that adds two numbers, and have asked me to test it…

Sure! I can test that for you. To do it, I’ll write a test case generator. Here it is:

#!/bin/bash

echo "#!/bin/bash"
for i in `seq 1 $1`
do
s=$(($i + $i))
echo "r=`./sum $i $i`; if [ $r -eq $s ]; then echo "OK"; else echo "NO"; fi"
done

A somewhat rudimentary framework? Absolutely, but it’ll do for this exercise. Let’s have it make three test cases:

$ sh checker.sh 3 > run.sh
$ more run.sh
#!/bin/bash
r=`./sum 1 1`; if [ $r -eq 2 ]; then echo "OK"; else echo "NO"; fi
r=`./sum 2 2`; if [ $r -eq 4 ]; then echo "OK"; else echo "NO"; fi
r=`./sum 3 3`; if [ $r -eq 6 ]; then echo "OK"; else echo "NO"; fi

And run them:

$ sh run.sh
OK
OK
OK

Yeah, it passes! #GoDev!

What’s that? You say there’s loads of numbers in the world and three isn’t very big in comparison. Well, pray tell, how many cases do you want? Ten? A hundred? A thousand? A round thousand, yeah!

$ sh checker.sh 1000 > run.sh
$ sh run.sh
OK
...
OK

Now we’re really sure your program works, right? Right?

Perhaps you feel uncomfortable about something I did? Say why into the comments. #GoTesting!
Image: https://flic.kr/p/amnCN7
Syntax highlighting: http://markup.su/highlighter

 

Comments are closed.


Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!