Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
The unit test function, responsible for performing one or more Test Assertions... |
Syntax
Warning | ||
---|---|---|
| ||
The scope of unit test functions is manipulated before a test runs, so you cannot reference variables defined in the function's scope chain (closures will not work either). If you want to reference variables external to the Unit Test function, pass them in via a settings object defined in the associated Test() invocation. |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
function(settings) { // code and assertions } |
Parameters
Parameter | Type | Notes | API Version |
---|---|---|---|
settings | Variant | The settings data passed in to Test(), if applicable. | 1.0 |
Return value
The return value is not processed.
Notes
Within the unit test, the following additional variables and properties are also available:
Property / Variable | Type | Test.APPEND( ) mode | Any other mode | API Version |
---|---|---|---|---|
_global | Object | A reference to the global object (not scope). This variable is defined by Test API and is thus safer to use within tests than the equivalent global defined by Util API. | 1.0 | |
modulePath | String | The modulePath that the test is running in – see Test.module() for more information. | 1.1 | |
moduleSettings | Object Undefined | The moduleSettings for the modulePath, if specified. If the module doesn't have settings, the variable will have a value of | 1.1 | |
this.settings | Variant | The settings associated with the Test.ASYNCH( ) that initiated the current asynchronous test session. | The settings associated with your unit test (also available via the settings parameter on the unit test function) | 1.0 |
testSettings | Variant | The settings associated with your unit test. | 1.0 | |
testName | String | The name of your unit test. | 1.0 | |
testMode | Object | An object describing the test mode, with the following properties:
| An object describing the test mode, with the following mandatory properties:
There may be several other properties depending on the test mode – For more information see Test API - Dev Notes. | 1.0 |
Example
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var mySettings = {bar: "fish"}; Test("Foo", Test.ANY( ), function(settings) { comment( "My first unit test!" ); equal( "fish", settings.bar, "settings.bar == 'fish'?" ); }, mySettings); |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Test APITopics:
|