public abstract class AbstractGenerator
extends java.lang.Object
The main generation loop is defined in method createAndClassifySequences(), 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.
ForwardGenerator| Modifier and Type | Field and Description |
|---|---|
protected TestCheckGenerator |
checkGenerator
Visitor to generate checks for a sequence.
|
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
If true, dump each sequence to the log file as it is generated.
|
protected ExecutionVisitor |
executionVisitor
Container for execution visitors used during execution of sequences.
|
int |
invalidSequenceCount
Number of invalid sequences generated.
|
GenInputsAbstract.Limits |
limits
Limits for generation, after which the generator will stop.
|
int |
null_steps
Number of steps that returned null.
|
int |
num_failed_output_test
Number of sequences that failed the output test.
|
int |
num_failing_sequences
Number of failing sequences generated.
|
int |
num_sequences_generated
Number of sequences generated.
|
int |
num_steps
Number of generation steps (each an attempt to generate and execute a new, distinct sequence).
|
protected OperationHistoryLogInterface |
operationHistory |
protected java.util.List<TypedOperation> |
operations
The list of statement kinds (methods, constructors, primitive value declarations, etc.) used to
generate sequences.
|
java.util.List<ExecutableSequence> |
outErrorSeqs
The list of error test sequences to be output as JUnit tests.
|
java.util.function.Predicate<ExecutableSequence> |
outputTest
A filter to determine whether a sequence should be added to the output sequence lists.
|
java.util.List<ExecutableSequence> |
outRegressionSeqs
The list of regression sequences to be output as JUnit tests.
|
private ProgressDisplay |
progressDisplay
Updates the progress display message printed to the console.
|
private long |
startTime
When the generator started (millisecond-based system timestamp).
|
private IStopper |
stopper
Customizable stopping criterion in addition to time and sequence limits.
|
protected java.util.Set<Sequence> |
subsumed_sequences
Sequences that are used in other sequences (and are thus redundant).
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractGenerator(java.util.List<TypedOperation> operations,
GenInputsAbstract.Limits limits,
ComponentManager componentManager,
IStopper stopper)
Constructs a generator with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
createAndClassifySequences()
Creates and executes new sequences until stopping criteria is met.
|
private long |
elapsedTime()
Elapsed time since the generator started.
|
abstract java.util.Set<Sequence> |
getAllSequences()
Return all sequences generated by this object.
|
java.util.List<ExecutableSequence> |
getErrorTestSequences()
Returns the generated error-revealing test sequences for output.
|
OperationHistoryLogInterface |
getOperationHistory()
Return the operation history logger for this generator.
|
java.util.List<ExecutableSequence> |
getRegressionSequences()
Returns the generated regression test sequences for output.
|
abstract void |
newRegressionTestHook(Sequence sequence)
Take action based on the given
Sequence that was classified as a regression test, i.e.,
normal behavior. |
int |
numAttemptedSequences()
Returns the count of attempts to generate a sequence so far.
|
private int |
numErrorSequences()
Returns the count of generated error-revealing sequences.
|
abstract int |
numGeneratedSequences()
Returns the count of sequences generated so far by the generator.
|
int |
numOutputSequences()
Returns the count of generated sequence currently for output.
|
int |
outputSequenceCount()
Returns the total number of test sequences generated to output, including both regression tests
and error-revealing tests.
|
(package private) void |
setCurrentSequence(Sequence s)
Sets the current sequence during exploration.
|
void |
setExecutionVisitor(ExecutionVisitor executionVisitor)
Registers a visitor with this object for use while executing each generated sequence.
|
void |
setExecutionVisitor(java.util.List<ExecutionVisitor> visitors)
Registers a MultiVisitor of all the given visitors with this object for use while executing
each generated sequence.
|
void |
setOperationHistoryLogger(OperationHistoryLogInterface logger)
Sets the operation history logger for this generator.
|
void |
setTestCheckGenerator(TestCheckGenerator checkGenerator)
Registers a visitor with this object to generate checks following execution of each generated
test sequence.
|
void |
setTestPredicate(java.util.function.Predicate<ExecutableSequence> outputTest)
Registers test predicate with this generator for use while filtering generated tests for
output.
|
protected boolean |
shouldStop()
Tests stopping criteria.
|
abstract @Nullable ExecutableSequence |
step()
Attempt to generate a test (a sequence).
|
public static boolean dump_sequences
public int num_steps
public int null_steps
public int num_sequences_generated
public int num_failing_sequences
public int invalidSequenceCount
public int num_failed_output_test
private long startTime
protected java.util.Set<Sequence> subsumed_sequences
public final GenInputsAbstract.Limits limits
protected final java.util.List<TypedOperation> operations
protected ExecutionVisitor executionVisitor
public ComponentManager componentManager
private IStopper stopper
private ProgressDisplay progressDisplay
public static Sequence currSeq
public java.util.List<ExecutableSequence> outErrorSeqs
public java.util.List<ExecutableSequence> outRegressionSeqs
public java.util.function.Predicate<ExecutableSequence> outputTest
protected TestCheckGenerator checkGenerator
protected OperationHistoryLogInterface operationHistory
protected AbstractGenerator(java.util.List<TypedOperation> operations, GenInputsAbstract.Limits limits, ComponentManager componentManager, IStopper stopper)
operations - statements (e.g. methods and constructors) used to create sequences. Cannot
be null.limits - maximum time and number of sequences to generate/outputcomponentManager - the 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.private long elapsedTime()
public void setTestPredicate(java.util.function.Predicate<ExecutableSequence> outputTest)
outputTest - the predicate to be added to objectpublic void setExecutionVisitor(ExecutionVisitor executionVisitor)
executionVisitor - the visitorpublic void setExecutionVisitor(java.util.List<ExecutionVisitor> visitors)
visitors - the list of visitorspublic void setTestCheckGenerator(TestCheckGenerator checkGenerator)
checkGenerator - the check generating visitorprotected boolean shouldStop()
public abstract @Nullable ExecutableSequence step()
public int numAttemptedSequences()
public abstract int numGeneratedSequences()
public int numOutputSequences()
private int numErrorSequences()
public void createAndClassifySequences()
shouldStop(),
step()public abstract java.util.Set<Sequence> getAllSequences()
public java.util.List<ExecutableSequence> getRegressionSequences()
public java.util.List<ExecutableSequence> getErrorTestSequences()
public int outputSequenceCount()
void setCurrentSequence(Sequence s)
s - the current sequencepublic void setOperationHistoryLogger(OperationHistoryLogInterface logger)
logger - the operation history logger to use for this generatorpublic OperationHistoryLogInterface getOperationHistory()