org.unitils.mock.report.impl
Class SuggestedAssertsReport

java.lang.Object
  extended by org.unitils.mock.report.impl.SuggestedAssertsReport

public class SuggestedAssertsReport
extends java.lang.Object

A view that will return a list of suggested assert statements that one can use in a test for the given scenario.

Author:
Kenny Claes, Filip Neven, Tim Ducheyne

Constructor Summary
SuggestedAssertsReport()
           
 
Method Summary
 java.lang.String createReport(java.lang.Object testObject, java.util.List<ObservedInvocation> observedInvocations)
          Creates a string representation of the given scenario.
protected  java.lang.String getFieldName(java.lang.Object testObject, java.lang.Object value)
          Checks whether the given argument value is a value of a field in the test object and, if so, returns the name of that field.
protected  java.lang.String getSuggestedArgument(java.lang.Object argument)
          Creates an appropriate value so that the assert statement will be able to match the given argument value that was observed in the scenario.
protected  java.lang.String getSuggestedAssertStatement(java.lang.Object testObject, ObservedInvocation observedInvocation)
          Creates an assert statement for the given method invocation and arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SuggestedAssertsReport

public SuggestedAssertsReport()
Method Detail

createReport

public java.lang.String createReport(java.lang.Object testObject,
                                     java.util.List<ObservedInvocation> observedInvocations)
Creates a string representation of the given scenario.

Parameters:
testObject -
scenario - The sceneario, not null
Returns:
The string representation, not null

getSuggestedAssertStatement

protected java.lang.String getSuggestedAssertStatement(java.lang.Object testObject,
                                                       ObservedInvocation observedInvocation)
Creates an assert statement for the given method invocation and arguments.

Parameters:
testObject - The test instance, null if there is no test object
observedInvocation - The invocation, not null
Returns:
The string representation of the assert statement, not null

getSuggestedArgument

protected java.lang.String getSuggestedArgument(java.lang.Object argument)
Creates an appropriate value so that the assert statement will be able to match the given argument value that was observed in the scenario.

Parameters:
argument - The actual argument value, not null
Returns:
The string representation of the value to use in the assert statement, not null

getFieldName

protected java.lang.String getFieldName(java.lang.Object testObject,
                                        java.lang.Object value)
Checks whether the given argument value is a value of a field in the test object and, if so, returns the name of that field.

Parameters:
testObject - The test instance, null if there is no test object
value - The value to look for, not null
Returns:
The field name, null if no field was found for the value


Copyright © 2009. All Rights Reserved.