It is important to get familiar with TestBox before adventuring into ColdBox testing. Therefore, we suggest you reference the TestBox Docs () or the TestBox API Docs (). Below you can see a few of the common methods available to you.
We highly encourage you to use expectations instead of assertions in order to use more human and fluent syntax:
As we have seen that our BaseTestCase inherits from the BaseSpec you get all the goodness of TestBox. However, the BaseTestCase also has a wealth of methods to assist in your testing adventures:
Here are some useful methods:
announce(any state, [struct data='[runtime expression]'], [boolean async='false'], [boolean asyncAll='false'], [boolean asyncAllJoin='true'], [any asyncPriority='NORMAL'], [numeric asyncJoinTimeout='0'])
// Getters
getCache(any cacheName='default')
getCacheBox()
getController()
getFlashScope()
getHandlerResults()
getInstance([any name], [struct initArguments='[runtime expression]'], [any dsl])
getInterceptor(any interceptorName)
getLogBox()
getRenderData()
getRenderedContent()
getRequestContext()
getStatusCode()
getUtil()
getWireBox()
// Get Mocking Objects
getMockController()
getMockModel(any name, [boolean clearMethods='false'])
getMockRequestContext([boolean clearMethods='false'], [any decorator])
//Reset the persistence of the unit test coldbox app, basically removes the controller from application scope.
reset([boolean clearMethods='false'], [any decorator])
// Prepare a ColdBox request
setup()
ColdBox TestBox Matchers
toHaveStatus()
Checks if the ColdBox response object has a matched status code.