goog.testing
Namespacegoog.testing.AsyncTestCase
ClassA test case that is capable of running tests the contain asynchronous logic. … more
goog.testing.ContinuationTestCase
ClassConstructs a test case that supports tests with continuations. Test functions may issue "wait" commands that suspend the test temporarily and continue once the wait condition is met. … more
goog.testing.DeferredTestCase
ClassA test case that can asynchronously wait on a Deferred object. … more
goog.testing.ExpectedFailures
ClassHelper class for allowing some unit tests to fail, particularly designed to mark tests that should be fixed on a given browser.
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); } }… more
goog.testing.FunctionCall
ClassStruct for a single function call. … more
.FunctionMock(opt_functionName, opt_strictness)
Class used to mock a function. Useful for mocking closures and anonymous callbacks etc. Creates a function object that extends goog.testing.Mock.
opt_functionName
{string
=}
opt_strictness
{number
=}
goog.testing.MockInterface
}
.GlobalFunctionMock(functionName, opt_strictness)
Mocks a global / top-level function. Creates a goog.testing.MethodMock in the global scope with the name specified by functionName.
functionName
{string
}
opt_strictness
{number
=}
goog.testing.MockInterface
}
goog.testing.JsUnitException
Classgoog.testing.LooseExpectationCollection
ClassThis class is an ordered collection of expectations for one method. Since the loose mock does most of its verification at the time of $verify, this class is necessary to manage the return/throw behavior when the mock is being called. … more
goog.testing.LooseMock
ClassThis is a mock that does not care about the order of method calls. As a result, it won't throw exceptions until verify() is called. The only exception is that if a method is called that has no expectations, then an exception will be thrown. … more
goog.testing.MethodMock
NamespaceMocks an existing function. Creates a goog.testing.FunctionMock and registers it in the given scope with the name specified by functionName. … more
goog.testing.Mock
ClassThe base class for a mock object. … more
goog.testing.MockClassFactory
ClassA factory used to create new mock class instances. It is able to generate both static and loose mocks. The MockClassFactory is a singleton since it tracks the classes that have been mocked internally. … more
goog.testing.MockClassRecord
ClassA record that represents all the data associated with a mock replacement of a given class. … more
goog.testing.MockClock
ClassClass for unit testing code that uses setTimeout and clearTimeout. NOTE: If you are using MockClock to test code that makes use of goog.fx.Animation, then you must either: 1. Install and dispose of the MockClock in setUpPage() and tearDownPage() respectively (rather than setUp()/tearDown()). or 2. Ensure that every test clears the animation queue by calling mockClock.tick(x) at the end of each test function (where `x` is large enough to complete all animations). Otherwise, if any animation is left pending at the time that MockClock.dispose() is called, that will permanently prevent any future animations from playing on the page. … more
goog.testing.MockControl
ClassControls a set of mocks. Controlled mocks are replayed, verified, and cleaned-up at the same time. … more
goog.testing.MockExpectation
ClassThis is a class that represents an expectation. … more
goog.testing.MockInterface
Interfacegoog.testing.MockRandom
ClassClass for unit testing code that uses Math.random. … more
goog.testing.MockRange
ClassLooseMock of goog.dom.AbstractRange. Useful because the mock framework cannot simply create a mock out of an abstract class, and cannot create a mock out of classes that implements __iterator__ because it relies on the default behavior of iterating through all of an object's properties. … more
goog.testing.MockStorage
ClassA JS storage instance, implementing the HMTL5 Storage interface. See http://www.w3.org/TR/webstorage/ for details. … more
goog.testing.MockUserAgent
ClassClass for unit testing code that uses goog.userAgent. … more
goog.testing.MultiTestRunner
ClassA component for running multiple tests within the browser. … more
goog.testing.ObjectPropertyString
ClassObject to pass a property name as a string literal and its containing object when the JSCompiler is rewriting these names. This should only be used in test code. … more
goog.testing.PerformanceTable
ClassA UI widget that runs performance tests and displays the results. … more
goog.testing.PerformanceTimer
ClassCreates a performance timer that runs test functions a number of times to generate timing samples, and provides performance statistics (minimum, maximum, average, and standard deviation). … more
goog.testing.PropertyReplacer
ClassHelper class for stubbing out variables and object properties for unit tests. This class can change the value of some variables before running the test cases, and to reset them in the tearDown phase. See googletest.StubOutForTesting as an analogy in Python: http://protobuf.googlecode.com/svn/trunk/python/stubout.py Example usage:
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:
goog.testing.PseudoRandom
ClassClass for unit testing code that uses Math.random. Generates deterministic random numbers. … more
goog.testing.ShardingTestCase
ClassA test case that runs tests in per-file shards. … more
goog.testing.StrictMock
ClassThis is a mock that verifies that methods are called in the order that they are specified during the recording phase. Since it verifies order, it follows 'fail fast' semantics. If it detects a deviation from the expectations, it will throw an exception and not wait for verify to be called. … more
goog.testing.TestCase
ClassA class representing a JsUnit test case. A TestCase is made up of a number of test functions which can be run. Individual test cases can override the following functions to set up their test environment: - runTests - completely override the test's runner - setUpPage - called before any of the test functions are run - tearDownPage - called after all tests are finished - setUp - called before each of the test functions - tearDown - called after each of the test functions - shouldRunTests - called before a test run, all tests are skipped if it returns false. Can be used to disable tests on browsers where they aren't expected to pass. Use {@link #autoDiscoverTests} … more
goog.testing.TestQueue
ClassGeneric queue for writing unit tests … more
goog.testing.TestRunner
ClassConstruct a test runner. NOTE(user): This is currently pretty weird, I'm essentially trying to create a wrapper that the Selenium test can hook into to query the state of the running test case, while making goog.testing.TestCase general. … more
goog.testing.asserts
Namespacegoog.testing.async
Namespacegoog.testing.benchmark
Namespace.createConstructorMock(scope, constructorName, opt_strictness)
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.
scope
{Object
}
constructorName
{string
}
opt_strictness
{number
=}
goog.testing.MockInterface
}
.createFunctionMock(opt_functionName, opt_strictness)
Convenience method for creating a mock for a function.
opt_functionName
{string
=}
opt_strictness
{number
=}
goog.testing.MockInterface
}
.createGlobalFunctionMock(functionName, opt_strictness)
Convenience method for creating a mocks for a global / top-level function.
functionName
{string
}
opt_strictness
{number
=}
goog.testing.MockInterface
}
.createMethodMock(scope, functionName, opt_strictness)
Convenience method for creating a mock for a method.
scope
{Object
}
functionName
{string
}
opt_strictness
{number
=}
goog.testing.MockInterface
}
goog.testing.dom
Namespacegoog.testing.editor
Namespacegoog.testing.events
Namespacegoog.testing.fs
Namespacegoog.testing.graphics
Namespacegoog.testing.jsunit
Namespacegoog.testing.messaging
Namespacegoog.testing.mockmatchers
Namespacegoog.testing.net
Namespace.recordConstructor(ctor)
Same as {@link 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.
ctor
{!Function
}
Function
}
.recordFunction(opt_f)
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 getCalls} and {@code getLastCall} but won't inherit the original function's prototype and static fields.
opt_f
{!Function
=}
Function
}
goog.testing.singleton
Namespacegoog.testing.stacktrace
Namespacegoog.testing.storage
Namespacegoog.testing.style
Namespacegoog.testing.ui
Namespace