News-210929

29 SEP 2021

Test cases play a central role in the automatic generation of software using Zoea. While test cases are conceptually simple, Zoea uses a number of variants so it is useful to understand their different characteristics and the relationships between them.


Test cases are widely used in software development to describe and verify the behaviour of code. Typically each piece of software will have an associated set of test cases with each individual case specifying the expected output for a given input.


From a user perspective test cases in Zoea come in two varieties. There are the text-based test cases that make up the bulk of Zoea Specification Language (ZSL) and also the graphical case diagrams of Zoea Visual. Both of these notations describe the same thing, that is a set of test cases for the program being specified. However Zoea Visual also provides a number of additional features including dependencies and subsidiary test cases that make describing larger programs easier and more efficient.


A ZSL program can contain any number of test cases, each of which normally includes both input and output values. Between the input and output values the user can also specify any number of derived values. Derived values represent internal states of the data during processing. This allows the user to describe how the algorithm should behave internally in more detail.


When a ZSL program is compiled Zoea transforms the ZSL test cases into internal test cases which comprise only input and output values. In doing so a set of internal test cases are created for each derived and output value. For example, the ZSL test case [input:a derive:b output:c] becomes two internal test cases [input:a output:b] and [input:b output:c]. The internal test cases are effectively back-to-back.


All reasoning carried out by Zoea is in relation to internal test cases. Each internal test case consists of a single input and a single output value. If multiple values are needed then they are simply combined into a suitable compound data structure.


During compilation Zoea knowledge sources also create synthetic test cases. These are simply internal test cases that are created by Zoea rather than directly from ZSL. Synthetic test cases are used to track different hypotheses about the required code and they will often have different values and even different numbers of cases. Having all of the test cases that Zoea uses internally in the same format makes processing within Zoea simpler and more consistent.


Zoea Visual is built on top of ZSL and during compilation it produces ZSL code that it sends to the Zoea compiler. Every value in each derive or output column corresponds to a fragment of the solution code. These values may also be the target for a set of dependencies. Zoea Visual generates a separate ZSL program for each derive and output column value - unless it has been defined as a subsidiary test case.


A subsidiary test case is in fact a completely separate Zoea Visual program that is associated with a dependency target. When a Zoea Visual program is compiled any subsidiary test cases it includes are also compiled. Ultimately all Zoea Visual test cases are transformed into many smaller ZSL programs that are fed in turn into the Zoea compiler. The resulting code is then weaved together to form the complete solution.


In summary:

  • ZSL test cases consist of input, derive and output values;
  • Internal test cases are created for each ZSL derive and output value;
  • Internal test cases only have an input and an output value;
  • Zoea knowledge sources transform internal test cases into many synthetic test cases;
  • Synthetic test cases are simply internal test cases that Zoea has produced;
  • Zoea Visual programs express test cases as case diagrams;
  • Zoea Visual case diagrams consist of dependencies and subsidiary test cases;
  • Subsidiary test cases are simply other Zoea Visual programs;
  • Zoea Visual dependencies are turned into ZSL for compilation.


Fundamentally Zoea is built on a simple model of test cases that consist of an input and an output. ZSL and Zoea Visual in turn build on this model to provide higher level and more powerful constructs.