Synthia
Generic and flexible data structure generator
ca.uqac.lif.synthia.test.Monkey Class Reference

Detailed Description

Performs monkey testing by interacting with a component.

The monkey works as follows:

  1. The monkey starts with a discovery phase. It uses a Picker<Action> as a source of actions to be performed on the component. Actions provided by this picker are executed one by one.
  2. Exceptions that may be thrown resulting from each action are trapped. As soon as an exception is caught, the sequence of actions performed so far is stored.
  3. The monkey then enters in a shrinking phase, where shorter sub-traces of the original are repeatedly generated and tested. Whenever a shorter sequence still throws an exception, this sequence replaces the original, and the shrinking process restarts from this new reference.

What the "component" can be is totally abstract. All the monkey expects is that it implements the Resettable interface. A typical component is a graphical user interface (such as a JFrame),

Author
Sylvain Hallé

Definition at line 54 of file Monkey.java.

Public Member Functions

 Monkey (Resettable object, Picker< Action > actions, Picker< Float > decision, PrintStream ps)
 Creates a new instance of the monkey. More...
 
 Monkey (Resettable object, Picker< Action > actions, Picker< Float > decision)
 Creates a new instance of the monkey. More...
 
boolean check ()
 
Exception getException ()
 
List< ActiongetShrunk ()
 

Protected Member Functions

void print (Object message)
 Prints a message to the print stream. More...
 
void println (Object message)
 Prints a message to the print stream. More...
 

Protected Attributes

Picker< Actionm_actionPicker
 The picker producing the actions to be applied. More...
 
Resettable m_object
 The object on which the actions are applied. More...
 
List< Actionm_bestSequence
 The "best" sequence of actions found by the monkey so far. More...
 
Exception m_lastException
 The exception thrown at the end of the "best" sequence of actions found by the monkey so far. More...
 
Picker< Float > m_decision
 A picker passed to the action picker for the shrinking process. More...
 
PrintStream m_out
 A print stream where the monkey outputs status messages during its execution. More...
 
int m_bestThreshold
 The length of the sequence under which the monkey is allowed to stop searching. More...
 

Static Protected Attributes

static final int s_maxShrinkingPhases = 5
 The maximum number of shrinking phases the monkey will attempt. More...
 
static final int s_maxTries = 5
 The maximum number of attempts at producing a sequence in each shrinking phase. More...
 

Constructor & Destructor Documentation

◆ Monkey() [1/2]

ca.uqac.lif.synthia.test.Monkey.Monkey ( Resettable  object,
Picker< Action actions,
Picker< Float >  decision,
PrintStream  ps 
)

Creates a new instance of the monkey.

Parameters
objectThe object on which the actions are applied
actionsThe picker producing the actions to be applied
decisionA picker passed to the action picker for the shrinking process
psA print stream where the monkey outputs status messages during its execution. Set it to null to disable messages.

Definition at line 114 of file Monkey.java.

◆ Monkey() [2/2]

ca.uqac.lif.synthia.test.Monkey.Monkey ( Resettable  object,
Picker< Action actions,
Picker< Float >  decision 
)

Creates a new instance of the monkey.

Parameters
objectThe object on which the actions are applied
actionsThe picker producing the actions to be applied
decisionA picker passed to the action picker for the shrinking process

Definition at line 133 of file Monkey.java.

Member Function Documentation

◆ check()

boolean ca.uqac.lif.synthia.test.Monkey.check ( )

Definition at line 138 of file Monkey.java.

◆ getException()

Exception ca.uqac.lif.synthia.test.Monkey.getException ( )

Definition at line 216 of file Monkey.java.

◆ getShrunk()

List<Action> ca.uqac.lif.synthia.test.Monkey.getShrunk ( )

Definition at line 221 of file Monkey.java.

◆ print()

void ca.uqac.lif.synthia.test.Monkey.print ( Object  message)
protected

Prints a message to the print stream.

Parameters
messageThe message

Definition at line 230 of file Monkey.java.

◆ println()

void ca.uqac.lif.synthia.test.Monkey.println ( Object  message)
protected

Prints a message to the print stream.

Parameters
messageThe message

Definition at line 242 of file Monkey.java.

Member Data Documentation

◆ m_actionPicker

Picker<Action> ca.uqac.lif.synthia.test.Monkey.m_actionPicker
protected

The picker producing the actions to be applied.

Definition at line 70 of file Monkey.java.

◆ m_bestSequence

List<Action> ca.uqac.lif.synthia.test.Monkey.m_bestSequence
protected

The "best" sequence of actions found by the monkey so far.

Definition at line 80 of file Monkey.java.

◆ m_bestThreshold

int ca.uqac.lif.synthia.test.Monkey.m_bestThreshold
protected

The length of the sequence under which the monkey is allowed to stop searching.

Definition at line 103 of file Monkey.java.

◆ m_decision

Picker<Float> ca.uqac.lif.synthia.test.Monkey.m_decision
protected

A picker passed to the action picker for the shrinking process.

Definition at line 91 of file Monkey.java.

◆ m_lastException

Exception ca.uqac.lif.synthia.test.Monkey.m_lastException
protected

The exception thrown at the end of the "best" sequence of actions found by the monkey so far.

Definition at line 86 of file Monkey.java.

◆ m_object

Resettable ca.uqac.lif.synthia.test.Monkey.m_object
protected

The object on which the actions are applied.

Definition at line 75 of file Monkey.java.

◆ m_out

PrintStream ca.uqac.lif.synthia.test.Monkey.m_out
protected

A print stream where the monkey outputs status messages during its execution.

Definition at line 97 of file Monkey.java.

◆ s_maxShrinkingPhases

final int ca.uqac.lif.synthia.test.Monkey.s_maxShrinkingPhases = 5
staticprotected

The maximum number of shrinking phases the monkey will attempt.

Definition at line 59 of file Monkey.java.

◆ s_maxTries

final int ca.uqac.lif.synthia.test.Monkey.s_maxTries = 5
staticprotected

The maximum number of attempts at producing a sequence in each shrinking phase.

Definition at line 65 of file Monkey.java.


The documentation for this class was generated from the following file: