lucee.Componenttestbox.system.BaseSpec
Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com --- This is a base spec object that is used to test XUnit and BDD style specification methods
Constructor Summary | |
---|---|
remote
|
init()
Constructor. |
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, [struct data='[runtime expression]'])
This function is used for BDD test suites to store the afterEach() function to execute for a test suite group. |
any
|
aroundEach(any body, [struct data='[runtime expression]'])
This is used to surround a spec with your own closure code to provide a nice around decoration advice. |
any
|
aroundStub([any spec])
|
any
|
assert(any expression, [any message=''])
Assert that the passed expression is true. |
any
|
beforeEach(any body, [struct data='[runtime expression]'])
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], [string label=''], [boolean deepCopy='false'], [numeric top='999'])
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. |
CollectionExpectation
|
expectAll(any actual)
Start a collection expectation expression. |
any
|
expectedException([any type=''], [any regex='.*'])
Expect an exception from the testing spec. |
any
|
fail([any message=''])
Fail an assertion. |
any
|
feature(string feature, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox. |
any
|
generateAroundEachClosuresStack([array closures], any suite, any spec)
Generates a specs stack for executions. |
array
|
getDebugBuffer()
Get the debug array buffer from scope. |
any
|
getMockBox([string generationPath])
Get a reference to the MockBox engine. |
any
|
getProperty(any target, any name, [any scope='variables'], [any defaultValue])
Get a private property. |
any
|
given(string given, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox. |
boolean
|
hasExpectedException(any specName, any runner)
Check if an expected exception is defined. |
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'], [struct data='[runtime expression]'])
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. |
BaseSpec
|
runAfterEachClosures(any suite, any spec)
Execute the after each closures in order for a suite and spec. |
BaseSpec
|
runAroundEachClosures(any suite, any spec)
Execute the around each closures in order for a suite and spec. |
BaseSpec
|
runBeforeEachClosures(any suite, any spec)
Execute the before each closures in order for a suite and spec. |
remote any
|
runRemote([string testSpecs=''], [string testSuites=''], [string reporter='simple'], [string labels=''])
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
|
scenario(string scenario, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox. |
private any
|
sliceTagContext(any tagContext)
removes the TestBox tag contexts from the beginning of the Failure Origin. |
any
|
story(string story, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox. |
any
|
then(string then, any body, [any labels='[runtime expression]'], [any skip='false'], [struct data='[runtime expression]'])
The then() function describes a spec or a test in TestBox and is an alias for it. |
any
|
when(string when, any body, [any labels='[runtime expression]'], [boolean asyncAll='false'], [any skip='false'])
The way to describe BDD test suites in TestBox. |
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]'], [struct data='[runtime expression]'])
This is a convenience method that makes sure the test spec is skipped from execution. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Constructor
Method Detail |
---|
Add custom assertions to the $assert object
assertions
- The structure of custom assertion functions to register or a path or instance of a CFC containing all the assertion functions to registerAdd custom matchers to your expectations
matchers
- The structure of custom matcher functions to register or a path or instance of a CFC containing all the matcher functions to registerThis function is used for BDD test suites to store the afterEach() function to execute for a test suite group
body
- The closure functiondata
- Data bindingsThis is used to surround a spec with your own closure code to provide a nice around decoration advice
body
- The closure functiondata
- Data bindingsspec
Assert that the passed expression is true
expression
message
This function is used for BDD test suites to store the beforeEach() function to execute for a test suite group
body
- The closure functiondata
- Data bindingsClear the debug array buffer
Send some information to the console via writedump( output="console" )
var
- The data to sendtop
- Apply a top to the dump, by default it does 9999 levelsCreate an empty mock
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 trueCreate a mock with or without clearing implementations, usually not clearing means you want to build object spies
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 falseCreate an empty stub object that you can use for mocking
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 interfaceDebug some information into the TestBox debugger array buffer
var
- The data to debuglabel
- The label to add to the debug entrydeepCopy
- By default we do not duplicate the incoming information, but you can :)top
- The top numeric number to dump on the screen in the report, defaults to 999The way to describe BDD test suites in TestBox. The title is usually what you are testing or grouping of tests. The body is the function that implements the suite.
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.Start an expectation expression. This returns an instance of Expectation so you can work with its matchers.
actual
- The actual value, it is not required as it can be null.Start a collection expectation expression. This returns an instance of CollectionExpection so you can work with its collection-unrolling matches (delegating to Expection).
actual
- The actual value, it should be an array or a struct.Expect an exception from the testing spec
type
- The type to expectregex
- Optional exception message regular expression to match, by default it matches .*Fail an assertion
message
The way to describe BDD test suites in TestBox. The feature is an alias for describe usually use when you are writing in a Given-When-Then style The body is the function that implements the suite.
feature
- 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.Generates a specs stack for executions
closures
- The array of closures data to buildsuite
- The target suitespec
- The target specGet the debug array buffer from scope
Get a reference to the MockBox engine
generationPath
- The path to generate the mocks if passed, else uses default location.Get a private property
target
- The target to get a property fromname
- The name of the property to retrievescope
- The scope to get it from, defaults to 'variables' scopedefaultValue
- A default value if the property does not existThe way to describe BDD test suites in TestBox. The given is an alias for describe usually use when you are writing in a Given-When-Then style The body is the function that implements the suite.
given
body
- 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.Check if an expected exception is defined
specName
runner
Check if the incoming exception is expected or not.
exception
specName
runner
The it() function describes a spec or a test in TestBox. The body argument is the closure that implements the test which usually contains one or more expectations that test the state of the code under test.
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.data
- A struct of data you would like to bind into the spec so it can be later passed into the executing body functionMake a private method on a CFC public with or without a new name and returns the target object
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 namePrepares an already instantiated object to act as a mock for spying and much more
object
- The object to mock, already instantiatedcallLogging
- Add method call logging for all mocked methods. Defaults to trueWrite some output to the ColdFusion output buffer
message
Write some output to the ColdFusion output buffer using a
attached
message
First line are the query columns separated by commas. Then do a consecuent rows separated by line breaks separated by | to denote columns.
queryData
Execute the after each closures in order for a suite and spec
suite
- The suite definitionspec
- The spec definitionExecute the around each closures in order for a suite and spec
suite
- The suite definitionspec
- The spec definitionExecute the before each closures in order for a suite and spec
suite
- The suite definitionspec
- The spec definitionRun a test remotely, only useful if the spec inherits from this class. Useful for remote executions.
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!reporter
- The type of reporter to run the test withlabels
- A list or array of labels to apply to the testing.Run a BDD test in this target CFC
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 testRuns a xUnit style test method in this target CFC
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 testThe way to describe BDD test suites in TestBox. The scenario is an alias for describe usually use when you are writing in a Given-When-Then style The body is the function that implements the suite.
scenario
body
- 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.removes the TestBox tag contexts from the beginning of the Failure Origin
tagContext
- The tag contextThe way to describe BDD test suites in TestBox. The story is an alias for describe usually use when you are writing using Gherkin-esque language The body is the function that implements the suite.
story
- 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.The then() function describes a spec or a test in TestBox and is an alias for it. The body argument is the closure that implements the test which usually contains one or more expectations that test the state of the code under test.
then
- 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.data
- A struct of data you would like to bind into the spec so it can be later passed into the executing body functionThe way to describe BDD test suites in TestBox. The when is an alias for scenario usually use when you are writing in a Given-When-Then style The body is the function that implements the suite.
when
body
- 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.This is a convenience method that makes sure the test suite is skipped from execution
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.This is a convenience method that makes sure the test spec is skipped from execution
title
- The title of this specbody
- The closure that represents the testlabels
- The list or array of labels this spec belongs todata
- A struct of data you would like to bind into the spec so it can be later passed into the executing body function