org.jwalk
Interface Generator

All Known Subinterfaces:
CustomGenerator, MasterGenerator
All Known Implementing Classes:
ArrayGenerator, EnumGenerator, InterfaceGenerator, ObjectGenerator, PlatformGenerator, RedirectInGenerator, StringGenerator, ValueGenerator

public interface Generator

Generator is the interface implemented by every test input generator. A Generator is an object which synthesises test inputs for the methods and constructors of the test class. The order in which inputs are created must be deterministic, to allow for learned prediction of test outcomes. Apart from this constraint, different kinds of Generator may produce their test inputs according to different rules.

The default generation strategy is to create a monotonic sequence of quasi-unique values of each type. However, custom generators may create specific values, or revisit the same values in a controlled iteration. There are two sub-interfaces of Generator: CustomGenerator is the interface which all user-provided custom generators must satisfy. The system-internal generators used by JWalk satisfy the MasterGenerator interface.

Version:
1.0
Author:
Anthony Simons

Method Summary
 boolean canCreate(java.lang.Class<?> type)
          Reports whether this Generator can create values of the requested type.
 java.lang.Object nextValue(java.lang.Class<?> type)
          Creates the next quasi-unique value in sequence for a particular type.
 

Method Detail

nextValue

java.lang.Object nextValue(java.lang.Class<?> type)
                           throws GeneratorException
Creates the next quasi-unique value in sequence for a particular type. According to the deterministic rule of this Generator, creates the next object instance in sequence for the requested type. The result is an object, an array, or a wrapped primitive value.

Parameters:
type - the requested type.
Returns:
the next value of this type.
Throws:
GeneratorException - if no value of this type could be synthesised.

canCreate

boolean canCreate(java.lang.Class<?> type)
Reports whether this Generator can create values of the requested type. This method is called internally when deciding whether to dispatch a request to this Generator.

Parameters:
type - the requested type.
Returns:
true, if this Generator synthesises values of this type.