Friday 21 October 2011

Specification based testing

Chapter 4 in the book relates to black box testing or specification based testing.  Imagine that we are unit testing a method that returns a classification from a grade. What ways could we devise test data to make sure the boundaries are being tested.

Design test cases to put the specification under stress or duress, picking a random set of results to test would be useless,  the boundaries of the classification need testing.

Need to use test data that will throw an exception.
We should also not test the same case more than once.

Given marks in the range 55 - 64 there is little point in testing 57, 58, 59, 60, 61...

Equivalence Partioning allows us to divide the test cases into partitions.

The theory is that if a value within a partition passes the partition passes. If a value within the partition fails similarly the partition fails.

Theory on partitions ;
A particular parameter may be considered for partitioning and its domain split into blocks,  this can be difficult where the split is not easily identified.

Domain D gets split blocks.
B. Where bi. intersect bj.  Returns an empty set. This is called pairwise disjoint.

And where union of all blocks returns domain. This means that the partitions cover the whole domain.

Input domain modelling :
Interface based
Given the method header Sqr(int x)  what can we decide on as valid partitions?

3 partitions. Less than zero,  zero, more than zero.

This is problematic as without the knowledge of the function we cannot reliably predict the outcomes.

Alternatively we could argue that if we knew it should return an integer squared we could divide the domain up based around known values.  We could use zero and the square of the maximum int.

Another approach is to model the output so knowing that a return value is an int squared there's little point in expecting a negative number.  Despite this overflow of a maximum int can return a negative number?

The function should throw exception if it returns a negative better yet the method call should. But that's a different matter.

Boundary value analysis.

Breaking the domain into partitions ; whatever partitions are used need to justify the choice of the partitions.

No comments:

Post a Comment