randoop
Class AbstractGenerator

Object
  extended by AbstractGenerator
Direct Known Subclasses:
ForwardGenerator, RandomWalkGenerator

public abstract class AbstractGenerator
extends Object

Algorithm template for implementing a test generator. The main generation loop is defined in method explore(), which repeatedly generates a new sequence, determines if it a failing sequence, and stops the process when the time or sequence limit expires. The process of generating a new sequences is left abstract.

See Also:
ForwardGenerator

Field Summary
Modifier and Type Field and Description
 ComponentManager componentManager
          Component manager responsible for storing previously-generated sequences.
static Sequence currSeq
          This field is set by Randoop to point to the sequence currently being executed.
static boolean dump_sequences
           
 MultiVisitor executionVisitor
          Container for execution visitors used during execution of sequences.
 RandoopListenerManager listenerMgr
          Manages notifications for listeners.
 int maxSequences
          Sequence limit for generation.
 long maxTimeMillis
          Time limit for generation.
 int num_failing_sequences
           
 int num_sequences_generated
           
 int num_steps
           
 List<ITestFilter> outputTestFilters
          A list of filters that can be installed to help determine if a sequence should be added to the final sequence list outSeqs.
 List<ExecutableSequence> outSeqs
          The list of final sequences that are printed out as JUnit tests (i.e.
 List<StatementKind> statements
          The list of statement kinds (methods, constructors, primitive value declarations, etc.) used to generate sequences.
 Timer timer
          The timer used to determine how much time has elapsed since the start of generator and whether generation should stop.
 
Constructor Summary
Constructor and Description
AbstractGenerator(List<StatementKind> statements, long timeMillis, int maxSequences, ComponentManager componentManager, IStopper stopper, RandoopListenerManager listenerManager, List<ITestFilter> testfilters)
          Constructs a generator with the given parameters.
 
Method Summary
Modifier and Type Method and Description
 void explore()
          Creates and executes new sequences in a loop.
abstract  int numSequences()
           
abstract  ExecutableSequence step()
           
protected  boolean stop()
           
 Set<Sequence> subsumed_sequences()
          Returns the set of sequences that are used as inputs in other sequences (and can thus be thought of as subsumed by another sequence).
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dump_sequences

public static boolean dump_sequences

num_steps

public int num_steps

num_sequences_generated

public int num_sequences_generated

num_failing_sequences

public int num_failing_sequences

timer

public final Timer timer
The timer used to determine how much time has elapsed since the start of generator and whether generation should stop.


maxTimeMillis

public final long maxTimeMillis
Time limit for generation. If generation reaches the specified time limit (in milliseconds), the generator stops generating sequences.


maxSequences

public final int maxSequences
Sequence limit for generation. If generation reaches the specified sequence limit, the generator stops generating sequences.


statements

public List<StatementKind> statements
The list of statement kinds (methods, constructors, primitive value declarations, etc.) used to generate sequences. In other words, statements specifies the universe of operations from which sequences are generated.


executionVisitor

public final MultiVisitor executionVisitor
Container for execution visitors used during execution of sequences.


componentManager

public ComponentManager componentManager
Component manager responsible for storing previously-generated sequences.


listenerMgr

public RandoopListenerManager listenerMgr
Manages notifications for listeners.

See Also:
IEventListener

currSeq

public static Sequence currSeq
This field is set by Randoop to point to the sequence currently being executed. In the event that Randoop appears to hang, this sequence is printed out to console to help the user debug the cause of the hanging behavior.


outSeqs

public List<ExecutableSequence> outSeqs
The list of final sequences that are printed out as JUnit tests (i.e. Randoop's output).


outputTestFilters

public List<ITestFilter> outputTestFilters
A list of filters that can be installed to help determine if a sequence should be added to the final sequence list outSeqs.

Constructor Detail

AbstractGenerator

public AbstractGenerator(List<StatementKind> statements,
                         long timeMillis,
                         int maxSequences,
                         ComponentManager componentManager,
                         IStopper stopper,
                         RandoopListenerManager listenerManager,
                         List<ITestFilter> testfilters)
Constructs a generator with the given parameters.

Parameters:
statements - Statements (e.g. methods and constructors) used to create sequences. Cannot be null.
timeMillis - maximum time to spend in generation. Must be non-negative.
maxSequences - maximum number of sequences to generate. Must be non-negative.
componentManager - component manager to use to store sequences during component-based generation. Can be null, in which case the generator's component manager is initialized as new ComponentManager().
stopper - Optional, additional stopping criterion for the generator. Can be null.
listenerManager - Manager that stores and calls any listeners to use during generation. Can be null.
testfilters - List of filters to determine which sequences to output. Can be null or empty.
Method Detail

stop

protected boolean stop()

step

public abstract ExecutableSequence step()

numSequences

public abstract int numSequences()

explore

public void explore()
Creates and executes new sequences in a loop.


subsumed_sequences

public Set<Sequence> subsumed_sequences()
Returns the set of sequences that are used as inputs in other sequences (and can thus be thought of as subsumed by another sequence). This should only be called for subclasses that support this.