test-tube.TestContext
A class used to maintain state across tests in the test-suite. An instance of this class will be created for each top-level call to run a test-suite and can be used to hold user state (e.g., fixtures generated in setup
) in addition to maintaining internal state to test-tube itself.
Instance Properties
-
__testtube |
Object
|
Required |
|
Description |
xxx |
-
_tt |
Object
|
Required |
|
Description |
undefined |
-
global |
Object
|
Required |
|
Description |
A free form object used to store state across all tests executing as part of a test-suite |
-
httpHistory |
|
Required |
|
Description |
The current HTTP request and response history. This can be used by sub-tests of an HttpTest |
-
local |
Object
|
Required |
|
Description |
A free form object used to store state during the execution of a single test in the test-suite. This state will be stashed during the execution of any sub-tests and restored upon their completion. |
Methods
-
_init |
|
Return type |
undefined |
Description |
Initialize the context object |
-
restore |
|
Returns |
The new value of {@link test-tube.TestContext.local |
Return type |
Object |
Description |
Sets local to the last value that was stashed and removes it from the stack |
-
stash |
|
Arguments |
- state (Object) – undefined
|
Returns |
The new value of local |
Return type |
Object |
Description |
The new value of local |
Typedef: InternalTestContext
Properties
-
options |
Object
|
Required |
|
Description |
The parsed command line options used to execute the test-suite |
-
global |
Object
|
Required |
|
Description |
An object that can be accessed by all tests in the test-suite to store or pass state during a test-suite run. When a property is set on this object, it will remain until the test-suite completes, unless it is deleted during the course of test-suite execution. This is accessed by tests using the global property. |
-
local |
Object
|
Required |
|
Description |
An object that can be accessed by all tests in the test-suite to store or pass state during a single test run. If the test that is being executed contains sub-tests, this object will be stashed before running those tests and restored after they complete, restricting the accessibilty of this object’s contents to a single test. This can be accessed by tests using the local property. |
-
localStateStack |
Object[]
|
Required |
|
Description |
An array used to manage individual local state objects between individual test executions. This is not accessible to individual tests. |
-
httpHistory |
|
Required |
|
Description |
The current http history object used to track http requests and responses sent and received during the execution of an HttpTest suite. This can be accessed by tests using the httpHistory property. |
-
path |
string
|
Required |
|
Description |
The depth-first “path” for the test currently being executed. This is generated by joining the names of all tests seen in the traversal using the “/” character. This is not accessible to individual tests. |