ColdBox Platform Version 2.6.4

coldbox.system.testing.mockutils
Class MockGenerator

WEB-INF.cftags.component
        extended by coldbox.system.testing.mockutils.MockGenerator

public class MockGenerator
extends WEB-INF.cftags.component

The guy in charge of creating mocks


Constructor Summary
init(MockBox mockBox)
          Constructor
 
Method Summary
private void $include(string templatePath)
          Mix in a template
 string generate(string method, [any returns], boolean preserveReturnType='true', [boolean throwException='false'], [string throwType=''], [string throwDetail=''], [string throwMessage=''], any metadata='', any targetObject, [boolean callLogging='false'])
          Generate a mock method and return the generated path
private MockBox getmockBox()
 boolean removeStub(string genPath)
          Remove a method generator stub
 void writeStub(string genPath, string code)
          Write a method generator stub
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(MockBox mockBox)
Constructor

Parameters:
mockBox
Method Detail

$include

private void $include(string templatePath)
Mix in a template

Parameters:
templatePath

generate

public string generate(string method, [any returns], boolean preserveReturnType='true', [boolean throwException='false'], [string throwType=''], [string throwDetail=''], [string throwMessage=''], any metadata='', any targetObject, [boolean callLogging='false'])
Generate a mock method and return the generated path

Parameters:
method - The method you want to mock or spy on
returns - The results it must return, if not passed it returns void or you will have to do the mockResults() chain
preserveReturnType - If false, the mock will make the returntype of the method equal to ANY
throwException - If you want the method call to throw an exception
throwType - The type of the exception to throw
throwDetail - The detail of the exception to throw
throwMessage - The message of the exception to throw
metadata - The function metadata
targetObject - The target object to mix in
callLogging - Will add the machinery to also log the incoming arguments to each subsequent calls to this method

getmockBox

private MockBox getmockBox()


removeStub

public boolean removeStub(string genPath)
Remove a method generator stub

Parameters:
genPath

writeStub

public void writeStub(string genPath, string code)
Write a method generator stub

Parameters:
genPath
code

ColdBox Platform Version 2.6.4