Professional Documents
Culture Documents
Lecture23 - Testing Part 2
Lecture23 - Testing Part 2
1
What is a Test Oracle?
– Disadvantages:
1) lack of auditing accuracy if output is too complex
2) Slow and costly for large test suites
Non-Human Oracles
Some oracles assume the availability of a set of pre-
computed input/output pairs, which is rarely the case…
– What if such set is available and covers the input space?
Eiffel (by Bertrand Meyers) was the first language to offer design
by contract
Other languages now have it, e.g., Java in the form of Java
Modeling Language (JML), C# (see next slide)
A variety of testing tools provide functionality based on JML
annotations
– E.g., generates JUnit test code from JML annotations.
public static int BinarySearch(int[]! a, int key) // C#
requires forall{int i in (0: a.Length), int j in (i: a.Length); a[i] <= a[j]};
ensures 0 <= result ==> a[result] == key;
ensures result < 0 ==> forall{int i in (0: a.Length); a[i] != key};
{
int low = 0;
int high = a.Length - 1;
Human Oracles √
Implicit/Null Oracles √
Pseudo-oracles √
Regression Test Suites √
Metamorphic Testing
Metamorphic Testing
Metamorphic testing can be used to test “non-
testable programs”