org.unitils.mock.report.impl
Class SuggestedAssertsReport

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

public class SuggestedAssertsReport
extends 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
 String createReport(Object testObject, List<ObservedInvocation> observedInvocations)
          Creates a string representation of the given invocations.
protected  String formatMockName(ObservedInvocation observedInvocation)
           
protected  String getFieldName(Object testObject, 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  String getSuggestedArgument(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  String getSuggestedAssertStatement(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 String createReport(Object testObject,
                           List<ObservedInvocation> observedInvocations)
Creates a string representation of the given invocations.

Parameters:
testObject - The test instance, not null
observedInvocations - The invocations, not null
Returns:
The string representation, not null

getSuggestedAssertStatement

protected String getSuggestedAssertStatement(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 String getSuggestedArgument(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 String getFieldName(Object testObject,
                              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

formatMockName

protected String formatMockName(ObservedInvocation observedInvocation)


Copyright © 2011. All Rights Reserved.