Class goog.testing.AsyncTestCase
code »goog.testing.TestCase
└ goog.testing.AsyncTestCase
A test case that is capable of running tests the contain asynchronous logic.
Constructor
Parameters |
---|
|
Classes
|
Type Definitions
code »goog.testing.AsyncTestCase.TopStackFuncResult_ : {controlBreakingExceptionThrown: boolean, message: string}
Represents result of top stack function call.
{controlBreakingExceptionThrown: boolean, message: string}
Instance Methods
Defined in goog.testing.AsyncTestCase
Calls the given function, redirecting any exceptions to doAsyncError.
Parameters |
---|
|
Returns |
|
Continue with the next step in the test cycle.
code »cycleTests ( )Starts the tests.
code »doAsyncError ( opt_e )Handles an exception thrown by a test.
Parameters |
---|
|
Throws |
|
Calls the tearDown function, catching any errors, and then moves on to
the next step in the testing cycle.
code »doExecute_ ( )Step 3: Call test.execute().
Step 1: Move to the next test.
Sets up the test page and then waits untill the test case has been marked
as ready before executing the tests.
Step 4: Call tearDown().
code »doTopOfStackAsyncError_ ( opt_e )Wraps doAsyncError() for when we are sure that the test runner has no user
code above it in the stack.
Enables verbose logging of what is happening inside of the AsyncTestCase.
Ends the current test step and queues the next test step to run.
code »getCurrentStepName ( ) ⇒ !string
The current step name.
!string
Returns |
---|
|
Replaces the asserts.js assert_() and fail() functions with a wrappers to
catch the exceptions.
Sets a window.onerror handler for catching exceptions that happen in async
callbacks. Note that as of Safari 3.1, Safari does not support this.
code »setNextStep_ ( func, name )Sets the next function to call in our sequence of async callbacks.
Enables the timeout timer. This timer fires unless continueTesting is
called.
Disables the timeout timer.
code »unhookAll_ ( )Unhooks window.onerror and _assert.
code »waitForAsync ( opt_name )Informs the testcase not to continue to the next step in the test cycle
until continueTesting is called.
Parameters |
---|
|
code »waitForSignals ( times, opt_name )Informs the testcase not to continue to the next step in the test cycle
until signal is called the specified number of times. Within a test, this
function behaves additively if called multiple times; the number of signals
to wait for will be the sum of all expected number of signals this function
was called with.
Defined in goog.testing.TestCase
Adds a new test to the test case.
Parameters |
---|
|
code »addNewTest ( name, ref, opt_scope )Creates and adds a new test.
Convenience function to make syntax less awkward when not using automatic
test discovery.
Adds any functions defined in the global scope that correspond to
lifecycle events for the test case. Overrides setUp, tearDown, setUpPage,
tearDownPage and runTests if they are defined.
Adds any functions defined in the global scope that are prefixed with "test"
to the test case.
code »clearTimeout ( id )Clears a timeout created by this.timeout()
.
this.timeout()
.Parameters |
---|
|
Counts the number of files that were loaded for dependencies that are
required to run the test.
Returns |
---|
|
code »createTestFromAutoDiscoveredFunction ( name, ref ) ⇒ !goog.testing.TestCase.Test
Creates a goog.testing.TestCase.Test
from an auto-discovered
function.
!goog.testing.TestCase.Test
goog.testing.TestCase.Test
from an auto-discovered
function.Parameters |
---|
|
Returns |
|
Handles a test that failed.
Parameters |
---|
|
Handles a test that passed.
Parameters |
---|
|
Returns the number of tests actually run in the test case, i.e. subtracting
any which are skipped.
Returns |
---|
|
Returns |
---|
|
code »getBatchTime ( ) ⇒ number
number
Returns |
---|
|
code »getGlobals ( opt_prefix ) ⇒ !Array
Gets list of objects that potentially contain test cases. For IE 8 and below,
this is the global "this" (for properties set directly on the global this or
window) and the RuntimeObject (for global variables and functions). For all
other browsers, the array simply contains the global this.
!Array
Parameters |
---|
|
Returns |
|
Returns the number of script files that were loaded in order to run the test.
Returns |
---|
|
code »getRunTime ( ) ⇒ number
Returns the amount of time it took for the test to run.
number
Returns |
---|
|
code »getTestResults ( ) ⇒ !Object.<string>
Returns the test results object: a map from test names to a list of test
failures (if any exist).
!Object.<string>
Returns |
---|
|
Gets the tests.
Returns |
---|
|
code »getTimeStamp_ ( ) ⇒ string
Returns the current time.
string
Returns |
---|
|
Returns |
---|
|
code »logError ( name, opt_e ) ⇒ !goog.testing.TestCase.Error
!goog.testing.TestCase.Error
Parameters |
---|
|
Returns |
|
code »maybeFailTestEarly ( testCase ) ⇒ boolean
Checks to see if the test should be marked as failed before it is run.
If there was an error in setUpPage, we treat that as a failure for all tests
and mark them all as having failed.
boolean
Parameters |
---|
|
Returns |
|
Returns the current test and increments the pointer.
Returns |
---|
|
code »orderTests_ ( tests )Reorders the tests depending on the order
field.
order
field.Parameters |
---|
|
code »saveMessage ( message )Saves a message to the result set.
Parameters |
---|
|
code »setBatchTime ( batchTime )
Parameters |
---|
|
code »setCompletedCallback ( fn )Sets the callback function that should be executed when the tests have
completed.
Parameters |
---|
|
Sets the tests.
Parameters |
---|
|
code »shouldRunTests ( ) ⇒ boolean
Can be overridden in test classes to indicate whether the tests in a case
should be run in that particular situation. For example, this could be used
to stop tests running in a particular browser, where browser support for
the class under test was absent.
boolean
Returns |
---|
|
Gets called after all tests have been executed. Can be overridden to tear
down the entire test case.
Instance Properties
Defined in goog.testing.AsyncTestCase
The currently active test.
Marks if the cleanUp() function has been called for the currently running
test.
The stage of the test we are currently on.
The name of the stage of the test we are currently on.
Turn on extra logging to help debug failing async. tests.
Number of signals to wait for before continuing testing when waitForSignals
is used.
A flag to prevent recursive exception handling.
The stage of the test we should run next.
The name of the stage of the test we should run next.
The number of times we have thrown a ControlBreakingException so that we
know not to complain in our window.onerror handler. In Webkit, window.onerror
is not supported, and so this counter will keep going up but we won't care
about it.
A reference to the original window.onerror function.
Number of signals received.
Flag that tells us if there is a function in the call stack that will make
a call to pump_().
How long to wait for a single step of a test to complete in milliseconds.
A step starts when a call to waitForAsync() is made.
How long to wait after a failed test before moving onto the next one.
The purpose of this is to allow any pending async callbacks from the failing
test to finish up and not cause the next test to fail.
The handle to the current setTimeout timer.
Defined in goog.testing.TestCase
Time since the last batch of tests was started, if batchTime exceeds
#maxRunTime
a timeout will be used to stop the tests blocking the
browser and a new batch will be started.
#maxRunTime
a timeout will be used to stop the tests blocking the
browser and a new batch will be started.Pointer to the current test.
Exception object that was detected before a test runs.
Optional callback that will be executed when the test has finalized.
Object used to encapsulate the test results.
Timestamp for when the test was started.
Set of test names and/or indices to execute, or null if all tests should
be executed.
Indices are included to allow automation tools to run a subset of the
tests without knowing the exact contents of the test file.
Indices should only be used with SORTED ordering.
Example valid values:
- [testName]
- [testName1, testName2]
- [2] - will run the 3rd test in the order specified
- [1,3,5]
- [testName1, testName2, 3, 5] - will work
Static Functions
Preferred way of creating an AsyncTestCase. Creates one and initializes it
with the G_testRunner.
Parameters |
---|
|
Returns |
|