Home

# Class goog.testing.Mock

The base class for a mock object.

Instance Method Summary
| `$anyTimes() ⇒ ?goog.testing.Mock` Allows the expectation to be called any number of times.
| `$argumentsAsString(?Array.<*> args) ⇒ string` Render the provided argument array to a string to help clients with debugging tests.
| `$atLeastOnce() ⇒ ?goog.testing.Mock` Allows the expectation to be called any number of times, as long as it's called once.
| `$atMostOnce() ⇒ ?goog.testing.Mock` Allows the expectation to be called 0 or 1 times.
| `$do(?goog.testing.MockExpectation expectation, ?Array args) ⇒ <Any Type>` If this expectation defines a function to be called, it will be called and its result will be returned. Otherwise, if the expectation expects to throw, it will throw. Otherwise, this method will return defined value.
| `$does(?Function func) ⇒ ?goog.testing.Mock` Specifies a function to call for currently pending expectation. Note, that using this method overrides declarations made using $returns() and $throws() methods.
| `$initializeFunctions_(?Object objectToMock)` Initializes the functions on the mock object.
| `$maybeThrow(?goog.testing.MockExpectation expectation)` If the expectation expects to throw, this method will throw.
| `$mockMethod(string name) ⇒ <Any Type>` The function that replaces all methods on the mock object.
| `$recordAndThrow(?Object ex)` Throws an exception and records that an exception was thrown.
| `$recordCall(string name, ?Array args) ⇒ <Any Type>` Records an actual method call, intended to be overridden by a subclass. The subclass must find the pending expectation and return the correct value.
| `$recordExpectation()` Records the currently pending expectation, intended to be overridden by a subclass.
| `$registerArgumentListVerifier(string methodName, ?Function fn) ⇒ ?goog.testing.Mock` Registers a verfifier function to use when verifying method argument lists.
| `$replay()` Switches from recording to replay mode.
| `$reset()` Resets the state of this mock object. This clears all pending expectations without verifying, and puts the mock in recording mode.
| `$returns(<Any Type> val) ⇒ ?goog.testing.Mock` Specifies a return value for the currently pending expectation.
| `$throwCallException(string name, ?Array.<*> args, ?goog.testing.MockExpectation= opt_expectation)` Throw an exception based on an incorrect method call.
| `$throwException(string comment, ?string= opt_message)` Throws an exception and records that an exception was thrown.
| `$throws(<Any Type> val) ⇒ ?goog.testing.Mock` Specifies a value for the currently pending expectation to throw.
| `$times(number times) ⇒ ?goog.testing.Mock` Specifies the number of times the expectation should be called.
| `$verify()` Verify that all of the expectations were met. Should be overridden by subclasses.
| `$verifyCall(?goog.testing.MockExpectation expectation, string name, ?Array.<*> args) ⇒ boolean` Verifies that a method call matches an expectation.