org.jwalk.out
Class CycleReport

java.lang.Object
  extended by org.jwalk.out.Report
      extended by org.jwalk.out.ProtocolReport
          extended by org.jwalk.out.StatisticalReport
              extended by org.jwalk.out.CycleReport

public class CycleReport
extends StatisticalReport

CycleReport is a test report generated after executing one test cycle. A CycleReport is responsible for formatting the test result data after one test cycle is complete. A test cycle contains TestSequences of a given length (and optionally for a specified starting state). The TestSequences may be accessed and displayed in various ways. This CycleReport also offers direct access to the test cycle number, the optional starting state and the list of TestSequences that were exercised.

By default, each TestSequence in the cycle is listed, followed by a judgement whether the result was NORMAL or an EXCEPTION. If an Oracle was used to validate the test result, the judgement is whether the test PASSED or FAILED. Further notes may appear, depending on what the JWalker was able to discover. A note may be added to show that the test object's state was found to be unchanged, or reentrant (returning to a previously visited state). A note may be added to validated test results to highlight if they were manually confirmed or rejected.

Client programs may take control of how test results are displayed. A CycleReport grants direct access to the list of TestSequence results, and offers the option to format a sequence with, or without the judgement of the outcome appended as text. This allows client programs to choose to highlight a normal, terminating, passing or failing TestSequence in a different way, for example by using colour highlighting, or graphical symbols. If this is desired, then the client program should query the TestSequence directly to discover the outcome of the test.

The API of CycleReport also allows client programs to count the number of test sequences which executed, which terminated normally, which terminated with an exception, which were manually confirmed or rejected and which were automatically passed or failed. It also allows client programs to count the number of pruned test sequences, which were deemed redundant, and also the number of abandoned sequences that were not eventually tested, if the tester chose to quit interactive validation.

Version:
1.0
Author:
Anthony Simons

Field Summary
 
Fields inherited from class org.jwalk.out.StatisticalReport
confirmed, failed, passed, rejected, succeeded, terminated
 
Fields inherited from class org.jwalk.out.Report
edition, walker
 
Constructor Summary
CycleReport(ClassInspector inspector, java.util.List<TestSequence> results, int cycle)
          Creates a CycleReport for the current test cycle.
CycleReport(ClassInspector inspector, java.util.List<TestSequence> results, java.lang.String state, int cycle)
          Creates a CycleReport for a given state and test cycle.
 
Method Summary
 java.lang.String banner()
          Returns a suitable one-line banner for the current test cycle.
 int countAbandoned()
          Counts the number of tests that were abandoned.
 int countPruned()
          Counts the number of tests that were pruned in this test cycle.
 java.lang.String getContent()
          Returns the content of this CycleReport as formatted text.
 java.lang.String getStartingState()
          Returns the name of the starting state, or null.
 int getTestCycle()
          Returns the number of the current test cycle.
 java.util.List<TestSequence> getTestResults()
          Returns the list of test results for the current cycle.
 java.lang.String toString(TestSequence sequence, boolean outcome)
          Returns a formatted version of a TestSequence and its outcome.
 
Methods inherited from class org.jwalk.out.StatisticalReport
countConfirmed, countCorrect, countExecuted, countFailed, countIncorrect, countPassed, countRejected, countSucceeded, countTerminated, tallyResults
 
Methods inherited from class org.jwalk.out.ProtocolReport
getConstants, getConstructors, getJWalker, getMethods, getTestClass, isAbstract, toString, toString, toString
 
Methods inherited from class org.jwalk.out.Report
getEdition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CycleReport

public CycleReport(ClassInspector inspector,
                   java.util.List<TestSequence> results,
                   int cycle)
Creates a CycleReport for the current test cycle. Extracts all the report data from the list of test results.

Parameters:
inspector - the ClassInspector that inspected the test class.
results - the set of results for the current test cycle.
cycle - the current test cycle number.

CycleReport

public CycleReport(ClassInspector inspector,
                   java.util.List<TestSequence> results,
                   java.lang.String state,
                   int cycle)
Creates a CycleReport for a given state and test cycle. Extracts all the report data from the list of test results.

Parameters:
inspector - the ClassInspector that inspected the test class.
results - the set of results for the current test cycle.
state - the name of the tested object's starting state.
cycle - the current test cycle number.
Method Detail

getTestCycle

public int getTestCycle()
Returns the number of the current test cycle. This is the same as the length of method sequences tested during the current cycle.

Returns:
the test cycle number.

getStartingState

public java.lang.String getStartingState()
Returns the name of the starting state, or null. If this CycleReport was generated by a StateSpaceExplorer, returns the name of the starting state for this test cycle. Otherwise, returns null, since the notion of a starting state is not applicable.

Returns:
the name of the starting state, or null.

getTestResults

public java.util.List<TestSequence> getTestResults()
Returns the list of test results for the current cycle. Allows client programs to access individual TestSequences after testing. Note that holding on to such resources may affect memory capacity; and it is a good idea to release the list, when it is no longer required. Individual sequences can be formatted later using toString(TestSequence, boolean).

Returns:
the list of test results.

getContent

public java.lang.String getContent()
Returns the content of this CycleReport as formatted text. The returned text has a banner announcing the test class and cycle number, then following this, a formatted version of each TestSequence and its outcome. Each item is separated by a blank line; and the report ends with an extra blank line. This method implements toString() for CycleReport.

Overrides:
getContent in class ProtocolReport
Returns:
a formatted textual report.

banner

public java.lang.String banner()
Returns a suitable one-line banner for the current test cycle.

Overrides:
banner in class ProtocolReport
Returns:
a banner announcing the test cycle.

toString

public java.lang.String toString(TestSequence sequence,
                                 boolean outcome)
Returns a formatted version of a TestSequence and its outcome. Converts the sequence into formatted text, representing the program instructions in the sequence, using sequence.toString(). Optionally, adds extra explanatory text to the test result-line, highlighting the judgement made on the test outcome. Client programs may choose to show this judgement textually, which is the default setting, or by some other means (such as by use of colour, or symbols in the GUI). If the outcome parameter is true, the textual judgement will be appended; otherwise no judgement will be appended to the test result-line.

Parameters:
sequence - the TestSequence to format.
outcome - true, to display the outcome judgement.
Returns:
a formatted version of the TestSequence.

countAbandoned

public int countAbandoned()
Counts the number of tests that were abandoned. This is usually zero, but will be greater than zero, if interactive testing was abandoned halfway through a test cycle.

Returns:
the number of tests that were abandoned in this cycle.

countPruned

public int countPruned()
Counts the number of tests that were pruned in this test cycle. This is the difference between the expected number of tests for this cycle, minus the actual number. Pruning measures how effective the test strategy was in removing redundant tests.

Returns:
the number of tests that were pruned in this test cycle.