<!DOCTYPE html><meta charset="UTF-8"><meta http-equiv="Content-Language" content="en" /><title>goog.testing</title><link href="dossier.css" rel="stylesheet" type="text/css"><div id="main-wrapper"><input type="checkbox" id="sidenav-toggle" /><main><header><h1>Namespace goog.testing</h1><a class="source" href="source/lib/goog/testing/stacktrace.js.src.html#l20">code »</a></header><section></section><section><h2>Interfaces</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a><dd>No Description.</dl></table></div></section><section><h2>Classes</h2><div class="type-summary"><table><tbody><tr><td><dl><dt><a href="class_goog_testing_AsyncTestCase.html">goog.testing.AsyncTestCase</a><dd>A test case that is capable of running tests the contain asynchronous logic.<dt><a href="class_goog_testing_FunctionCall.html">goog.testing.FunctionCall</a><dd>Struct for a single function call.<dt><a href="class_goog_testing_JsUnitException.html">goog.testing.JsUnitException</a><dd>No Description.<dt><a href="class_goog_testing_LooseExpectationCollection.html">goog.testing.LooseExpectationCollection</a><dd>This class is an ordered collection of expectations for one method.<dt><a href="class_goog_testing_LooseMock.html">goog.testing.LooseMock</a><dd>This is a mock that does not care about the order of method calls.<dt><a href="class_goog_testing_Mock.html">goog.testing.Mock</a><dd>The base class for a mock object.<dt><a href="class_goog_testing_MockClock.html">goog.testing.MockClock</a><dd>Class for unit testing code that uses setTimeout and clearTimeout.<dt><a href="class_goog_testing_MockControl.html">goog.testing.MockControl</a><dd>Controls a set of mocks.<dt><a href="class_goog_testing_MockExpectation.html">goog.testing.MockExpectation</a><dd>This is a class that represents an expectation.<dt><a href="class_goog_testing_ObjectPropertyString.html">goog.testing.ObjectPropertyString</a><dd>Object to pass a property name as a string literal and its containing object when the JSCompiler is rewriting these names.<dt><a href="class_goog_testing_PropertyReplacer.html">goog.testing.PropertyReplacer</a><dd>Helper class for stubbing out variables and object properties for unit tests.<dt><a href="class_goog_testing_StrictMock.html">goog.testing.StrictMock</a><dd>This is a mock that verifies that methods are called in the order that they are specified during the recording phase.<dt><a href="class_goog_testing_TestCase.html">goog.testing.TestCase</a><dd>A class representing a JsUnit test case.<dt><a href="class_goog_testing_TestRunner.html">goog.testing.TestRunner</a><dd>Construct a test runner.</dl></table></div></section><div id="visibility-controls"><b>Show:</b><label for="show-public"><span><input type="checkbox" id="show-public" checked/></span>Public</label><label for="show-protected"><span><input type="checkbox" id="show-protected"/></span>Protected</label><label for="show-private"><span><input type="checkbox" id="show-private"/></span>Private</label></div><section id="static-functions"><h2>Global Functions</h2><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l46">code »</a><span class="member"><a name="goog.testing.FunctionMock">goog.testing.FunctionMock</a> <span class="args">( opt_functionName, opt_strictness )</span> ⇒ <code class="type"><a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Class used to mock a function. Useful for mocking closures and anonymous callbacks etc. Creates a function object that extends goog.testing.Mock.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The optional name of the function to mock. Set to '[anonymous mocked function]' if not passed in.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l101">code »</a><span class="member"><a name="goog.testing.GlobalFunctionMock">goog.testing.GlobalFunctionMock</a> <span class="args">( functionName, opt_strictness )</span> ⇒ <code class="type">!<a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Mocks a global / top-level function. Creates a goog.testing.MethodMock in the global scope with the name specified by functionName.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the function we're going to mock.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked global function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l69">code »</a><span class="member"><a name="goog.testing.MethodMock">goog.testing.MethodMock</a> <span class="args">( scope, functionName, opt_strictness )</span> ⇒ <code class="type">!<a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Mocks an existing function. Creates a goog.testing.FunctionMock and registers it in the given scope with the name specified by functionName.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The scope of the method to be mocked out.<dt>functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the function we're going to mock.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked method.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l147">code »</a><span class="member"><a name="goog.testing.createConstructorMock">goog.testing.createConstructorMock</a> <span class="args">( scope, constructorName, opt_strictness )</span> ⇒ <code class="type">!<a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Convenience method for creating a mock for a constructor. Copies class members to the mock. <p>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.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The scope of the constructor to be mocked out.<dt>constructorName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the constructor we're going to mock.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked constructor.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l114">code »</a><span class="member"><a name="goog.testing.createFunctionMock">goog.testing.createFunctionMock</a> <span class="args">( opt_functionName, opt_strictness )</span> ⇒ <code class="type"><a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Convenience method for creating a mock for a function.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a>=</code><dd>The optional name of the function to mock set to '[anonymous mocked function]' if not passed in.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l175">code »</a><span class="member"><a name="goog.testing.createGlobalFunctionMock">goog.testing.createGlobalFunctionMock</a> <span class="args">( functionName, opt_strictness )</span> ⇒ <code class="type"><a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Convenience method for creating a mocks for a global / top-level function.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the function we're going to mock.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked global function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/functionmock.js.src.html#l127">code »</a><span class="member"><a name="goog.testing.createMethodMock">goog.testing.createMethodMock</a> <span class="args">( scope, functionName, opt_strictness )</span> ⇒ <code class="type">!<a href="interface_goog_testing_MockInterface.html">goog.testing.MockInterface</a></code></span></div><p>Convenience method for creating a mock for a method.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>scope: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></code><dd>The scope of the method to be mocked out.<dt>functionName: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></code><dd>The name of the function we're going to mock.<dt>opt_strictness: <code class="type"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a>=</code><dd>One of goog.testing.Mock.LOOSE or goog.testing.Mock.STRICT. The default is STRICT.</dl><tr><th>Returns<tr><td><dl>The mocked global function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/recordfunction.js.src.html#l140">code »</a><span class="member"><a name="goog.testing.recordConstructor">goog.testing.recordConstructor</a> <span class="args">( ctor )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Same as <code class="type"><a href="namespace_goog_testing_recordFunction.html">goog.testing.recordFunction</a></code> but the recorded function will have the same prototype and static fields as the original one. It can be used with constructors.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>ctor: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code><dd>The function to wrap and record.</dl><tr><th>Returns<tr><td><dl>The wrapped function.</dl></table></div></details></div></div><div class="wrap-details public"><div><details class="function"><summary><div><a class="source" href="source/lib/goog/testing/recordfunction.js.src.html#l61">code »</a><span class="member"><a name="goog.testing.recordFunction">goog.testing.recordFunction</a> <span class="args">( opt_f )</span> ⇒ <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a></code></span></div><p>Wraps the function into another one which calls the inner function and records its calls. The recorded function will have 3 static methods: <code >getCallCount</code>, <code >getCalls</code> and <code >getLastCall</code> but won't inherit the original function's prototype and static fields.</summary><div class="info"><table><tbody><tr><th>Parameters<tr><td><dl><dt>opt_f: <code class="type">!<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">Function</a>=</code><dd>The function to wrap and record. Defaults to <code class="type"><a href="namespace_goog.html#goog.nullFunction">goog.nullFunction</a></code>.</dl><tr><th>Returns<tr><td><dl>The wrapped function.</dl></table></div></details></div></div></section></main><nav id="topnav"><div><div id="menubutton"><label for="sidenav-toggle">Menu</label></div><form id="searchbox"><div><input type="search" placeholder="Search" tabindex="1"></div></form></div></nav><nav id="sidenav"><input type="checkbox" id="sidenav-types-ctrl" /><input type="checkbox" id="sidenav-files-ctrl" /><input type="checkbox" id="sidenav-modules-ctrl" /><a id="sidenav-overview"><div><h4>Overview</h4></div></a><div id="sidenav-types"><label for="sidenav-types-ctrl"><h4>Types</h4></label><i>Loading</i></div><div id="sidenav-modules"><label for="sidenav-modules-ctrl"><h4>Modules</h4></label><i>Loading</i></div><div id="sidenav-files"><label for="sidenav-files-ctrl"><h4>Files</h4></label><i>Loading</i></div><a href="license.html"><div><h4>License</h4></div></a></nav><div id="push-footer"></div></div><footer><a href="https://github.com/jleyba/js-dossier">Generated by dossier</a></footer><script src="types.js"></script><script src="dossier.js"></script>