testing.ExpectedFailures Extends
Helper 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);
  }
}

Inheritance

Constructor

goog.testing.ExpectedFailures()

Instance Methods

Public Protected Private
expectFailureFor(conditionopt_message)
Register to expect failure for the given condition. Multiple calls to this function act as a boolean OR. The first applicable message will be used.
Arguments:
condition : boolean
Whether to expect failure.
opt_message : string=
Descriptive message of this expected failure.
code »
getExpectationMessage_() string
No description.
Returns: string  A warning describing an expected failure that didn't occur.
code »
handleException(ex)
Handle an exception, suppressing it if it is a unit test failure that we expected.
Arguments:
ex : Error
The exception to handle.
code »
handleTearDown()
Handle the tearDown phase of a test, alerting the user if an expected test was not suppressed.
code »
isExceptionExpected(ex) boolean
Determines if the given exception was expected.
Arguments:
ex : Object
The exception to check.
Returns: boolean  Whether the exception was expected.
code »
reset_()
Reset internal state.
code »
run(funcopt_lenient)
Run the given function, catching any expected failures.
Arguments:
func : Function
The function to run.
opt_lenient : boolean=
Whether to ignore if the expected failures didn't occur. In this case a warning will be logged in handleTearDown.
code »

Instance Properties

expectingFailure_ :
Whether or not we are expecting failure.
Code »
failureMessage_ :
The string to emit upon an expected failure.
Code »
logger_ : goog.debug.Logger
Logger for the expected failures.
Code »
suppressedFailures_ :
An array of suppressed failures.
Code »

Static Methods

goog.testing.ExpectedFailures.setUpConsole_()
Sets up the debug console, if it isn't already set up.
code »

Static Properties

goog.testing.ExpectedFailures.console_ : goog.debug.DivConsole
The lazily created debugging console.
Code »

Package testing

Package Reference