|
ColdBox Platform v3.8.0 | ||||
FRAMES |
WEB-INF.cftags.componentcoldbox.system.testing.BaseSpec
public class BaseSpec
******************************************************************************* Copyright 2005-2009 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.luismajano.com | www.ortussolutions.com ******************************************************************************* This is a base spec object that is used to test XUnit and BDD style specification methods
Method Summary | |
---|---|
any |
addAssertions(any assertions)
Add custom assertions to the $assert object |
any |
addMatchers(any matchers)
Add custom matchers to your expectations |
any |
afterEach(any body)
This function is used for BDD test suites to store the afterEach() function to execute for a test suite group |
any |
assert(any expression, [any message=''])
Assert that the passed expression is true |
any |
beforeEach(any body)
This function is used for BDD test suites to store the beforeEach() function to execute for a test suite group |
any |
clearDebugBuffer()
Clear the debug array buffer |
any |
closureStub()
|
any |
console(any var, [any top='9999'])
Send some information to the console via writedump( output="console" ) |
any |
createEmptyMock([string className], [any object], [boolean callLogging='true'])
Create an empty mock |
any |
createMock([string className], [any object], [boolean clearMethods='false'])
Create a mock with or without clearing implementations, usually not clearing means you want to build object spies |
any |
createStub([boolean callLogging='true'], [string extends=''], [string implements=''])
Create an empty stub object that you can use for mocking |
any |
debug([any var], [boolean deepCopy='false'])
Debug some information into the TestBox debugger array buffer |
any |
describe(string title, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox |
Expectation |
expect([any actual])
Start an expectation expression |
any |
expectedException([any type=''], [any regex='.*'])
Expect an exception from the testing spec |
any |
fail([any message=''])
Fail an assertion |
array |
getDebugBuffer()
Get the debug array buffer from scope |
any |
getMockBox([string generationPath])
Get a reference to the MockBox engine |
private boolean |
isExpectedException(any exception, any specName, any runner)
Check if the incoming exception is expected or not |
any |
it(string title, any body, [any labels='[runtime expression]'], [any skip='false'])
The it() function describes a spec or a test in TestBox |
any |
makePublic(any target, string method, [string newName=''])
Make a private method on a CFC public with or without a new name and returns the target object |
any |
prepareMock([any object], [boolean callLogging='true'])
Prepares an already instantiated object to act as a mock for spying and much more |
any |
print(any message)
Write some output to the ColdFusion output buffer |
any |
println(any message)
Write some output to the ColdFusion output buffer using a attached |
any |
querySim(any queryData)
First line are the query columns separated by commas |
remote any |
runRemote([string testSpecs=''], [string testSuites=''], [boolean debug='false'], [string reporter='simple'])
Run a test remotely, only useful if the spec inherits from this class |
any |
runSpec(any spec, any suite, any testResults, any suiteStats, any runner)
Run a BDD test in this target CFC |
any |
runTestMethod(any spec, any testResults, any suiteStats, any runner)
Runs a xUnit style test method in this target CFC |
any |
xdescribe(string title, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'])
This is a convenience method that makes sure the test suite is skipped from execution |
any |
xit(string title, any body, [any labels='[runtime expression]'])
This is a convenience method that makes sure the test spec is skipped from execution |
Methods inherited from class WEB-INF.cftags.component |
---|
None
|
Method Detail |
---|
public any addAssertions(any assertions)
assertions
- The structure of custom assertion functions to register or a path or instance of a CFC containing all the assertion functions to registerpublic any addMatchers(any matchers)
matchers
- The structure of custom matcher functions to register or a path or instance of a CFC containing all the matcher functions to registerpublic any afterEach(any body)
body
- The closure functionpublic any assert(any expression, [any message=''])
expression
message
public any beforeEach(any body)
body
- The closure functionpublic any clearDebugBuffer()
public any closureStub()
public any console(any var, [any top='9999'])
var
- The data to sendtop
- Apply a top to the dump, by default it does 9999 levelspublic any createEmptyMock([string className], [any object], [boolean callLogging='true'])
className
- The class name of the object to mock. The mock factory will instantiate it for youobject
- The object to mock, already instantiatedcallLogging
- Add method call logging for all mocked methods. Defaults to truepublic any createMock([string className], [any object], [boolean clearMethods='false'])
className
- The class name of the object to mock. The mock factory will instantiate it for youobject
- The object to mock, already instantiatedclearMethods
- If true, all methods in the target mock object will be removed. You can then mock only the methods that you want to mock. Defaults to falsepublic any createStub([boolean callLogging='true'], [string extends=''], [string implements=''])
callLogging
- Add method call logging for all mocked methods. Defaults to trueextends
- Make the stub extend from certain CFCimplements
- Make the stub adhere to an interfacepublic any debug([any var], [boolean deepCopy='false'])
var
- The data to senddeepCopy
- By default we do not duplicate the incoming information, but you can :)public any describe(string title, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
title
- The name of this test suitebody
- The closure that represents the test suitelabels
- The list or array of labels this suite group belongs toasyncAll
- If you want to parallelize the execution of the defined specs in this suite group.skip
- A flag or a closure that tells TestBox to skip this suite group from testing if true. If this is a closure it must return boolean.public Expectation expect([any actual])
actual
- The actual value, it is not required as it can be null.public any expectedException([any type=''], [any regex='.*'])
type
- The type to expectregex
- Optional exception message regular expression to match, by default it matches .*public any fail([any message=''])
message
public array getDebugBuffer()
public any getMockBox([string generationPath])
generationPath
- The path to generate the mocks if passed, else uses default location.private boolean isExpectedException(any exception, any specName, any runner)
exception
specName
runner
public any it(string title, any body, [any labels='[runtime expression]'], [any skip='false'])
title
- The title of this specbody
- The closure that represents the testlabels
- The list or array of labels this spec belongs toskip
- A flag or a closure that tells TestBox to skip this spec test from testing if true. If this is a closure it must return boolean.public any makePublic(any target, string method, [string newName=''])
target
- The target object to expose the methodmethod
- The private method to exposenewName
- If passed, it will expose the method with this name, else just uses the same namepublic any prepareMock([any object], [boolean callLogging='true'])
object
- The object to mock, already instantiatedcallLogging
- Add method call logging for all mocked methods. Defaults to truepublic any print(any message)
message
public any println(any message)
message
public any querySim(any queryData)
queryData
remote any runRemote([string testSpecs=''], [string testSuites=''], [boolean debug='false'], [string reporter='simple'])
testSpecs
- A list or array of test names that are the ones that will be executed ONLY!testSuites
- A list or array of suite names that are the ones that will be executed ONLY!debug
- Show debug output on the reports or notreporter
- The type of reporter to run the test withpublic any runSpec(any spec, any suite, any testResults, any suiteStats, any runner)
spec
- The spec definition to testsuite
- The suite definition this spec belongs totestResults
- The testing results objectsuiteStats
- The suite stats that the incoming spec definition belongs torunner
- The runner calling this BDD testpublic any runTestMethod(any spec, any testResults, any suiteStats, any runner)
spec
- The spec definition to testtestResults
- The testing results objectsuiteStats
- The suite stats that the incoming spec definition belongs torunner
- The runner calling this BDD testpublic any xdescribe(string title, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'])
title
- The name of this test suitebody
- The closure that represents the test suitelabels
- The list or array of labels this suite group belongs toasyncAll
- If you want to parallelize the execution of the defined specs in this suite group.public any xit(string title, any body, [any labels='[runtime expression]'])
title
- The title of this specbody
- The closure that represents the testlabels
- The list or array of labels this spec belongs to
|
ColdBox Platform v3.8.0 | ||||
FRAMES |