Describe Test Ideas Using Pseudo Code

Describe Test Ideas Using Pseudo Code

The following is an excerpt from my book, "Writing Test Plans Made Easy", available in Kindle and paperback format.

https://www.amazon.com/Writing-Test-Plans-Made-Easy/dp/1478333693

Code, Logic and Pseudo code

Sometimes the easiest way to express a test is to use logic or code. Code has the capability of doing a lot, very fast, with very little source text. We can take advantage of this as a means of explaining our tests. Consider the following example:

Test Issue: How well does the application compute a square root?

Methodology: We will take advantage of the fact that the square root of any number, squared, will yield the same number to simplify our testing. Tests will be derived via the following algorithm, giving varying inputs for start, end and interval:

long TestSquareRoot(long start, long end, long interval)
{
  long x = start;
  for(long x=start;x <= end; x = x + interval)
  {
    If (sqrt(x) * sqrt(x) != x)
    {
      LogFail(“sqrt(x) at value “ + x + ”failed with” +sqrt(x));
    }
    Else
    {
      LogPass(“sqrt(x) at value “ + x + “ passed with ” + sqrt(x));
    }
  }
}        

The above example describes a considerably large number of permutations on testing square root calculation in a very compact format. Generally we should assume that several, if not all,the reviewers of a test plan are programming language literate. The other advantage is that via an algorithm you not only imply the specific tests but also get the methodology steps and validation mechanisms covered all in one shot. Rarely does it get more compact and efficient than that.

Algorithmic based test models also combine well with others. For example, the above algorithm could be combined with the following set of inputs to even further clarify the range of tests covered:

Start: {0 – 5,000,000,000}

End: {0 – 5,000,000,000}

Interval: {1,.1,.01, .001, .0001}

To view or add a comment, sign in

More articles by Wayne Roseberry

Explore content categories