var expectedFailures = new goog.testing.ExpectedFailures(); function tearDown() { expectedFailures.handleTearDown(); } function testSomethingThatBreaksInWebKit() { expectedFailures.expectFailureFor(goog.userAgent.WEBKIT); try { ... assert(somethingThatFailsInWebKit); ... } catch (e) { expectedFailures.handleException(e); } }
var stubs = new goog.testing.PropertyReplacer(); function setUp() { // Mock functions used in all test cases. stubs.set(Math, 'random', function() { return 4; // Chosen by fair dice roll. Guaranteed to be random. }); } function tearDown() { stubs.reset(); } function testThreeDice() { // Mock a constant used only in this test case. stubs.set(goog.global, 'DICE_COUNT', 3); assertEquals(12, rollAllDice()); }Constraints on altered objects:
#autoDiscoverLifecycle
and #autoDiscoverTests
Class used to mock a function. Useful for mocking closures and anonymous
callbacks etc. Creates a function object that extends goog.testing.Mock.
Arguments:
Returns: goog.testing.MockInterface
The mocked function.
|
code » | ||||
Mocks a global / top-level function. Creates a goog.testing.MethodMock
in the global scope with the name specified by functionName.
Arguments:
Returns: !goog.testing.MockInterface
The mocked global function.
|
code » | ||||
Mocks an existing function. Creates a goog.testing.FunctionMock
and registers it in the given scope with the name specified by functionName.
Arguments:
Returns: !goog.testing.MockInterface
The mocked method.
|
code » | ||||
![]()
Convenience method for creating a mock for a constructor. Copies class
members to the mock.
When mocking a constructor to return a mocked instance, remember to create the instance mock before mocking the constructor. If you mock the constructor first, then the mock framework will be unable to examine the prototype chain when creating the mock instance.
Arguments:
Returns: !goog.testing.MockInterface
The mocked constructor.
|
code » | ||||
Convenience method for creating a mock for a function.
Arguments:
Returns: goog.testing.MockInterface
The mocked function.
|
code » | ||||
Convenience method for creating a mocks for a global / top-level function.
Arguments:
Returns: goog.testing.MockInterface
The mocked global function.
|
code » | ||||
Convenience method for creating a mock for a method.
Arguments:
Returns: !goog.testing.MockInterface
The mocked global function.
|
code » | ||||
Same as
goog.testing.recordFunction but the recorded function will
have the same prototype and static fields as the original one. It can be
used with constructors.
|
code » | ||||
Wraps the function into another one which calls the inner function and
records its calls. The recorded function will have 3 static methods:
getCallCount , getCalls and getLastCall but won't
inherit the original function's prototype and static fields.
Arguments:
Returns: !Function
The wrapped function.
|
code » |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
No description.
|
Code » |