jquery/qunit — Issue #200: Missing fail() and fail(msg) for behaviour-based testing
Author: rdingwall
Created: 2012-02-22 11:08:45+00:00
State: open

As as well as `ok()` and `equal()` on the Qunit API, it would be great to have a `fail()` and `fail(msg)` function to immediately fail the test. Most mature test frameworks have such a method (see below for examples). They are useful for asserting based on behaviour (i.e., function should not have been called) rather than based on state (object.xyz must = x).

```javascript
eventBus.bind("searchFailed", function (results) {
fail("this should not have been called!");
});
```

They can also be useful for marking tests that have not been written yet.

```javascript
test('It should render the search results dialog', function () {
fail("not implemented yet");
});
```

Examples in other test frameworks:

- NUnit's Assert.Fail(message) - http://www.nunit.org/index.php?p=utilityAsserts&r=2.2.7
- JUnit's Assert.fail(message) - : http://www.junit.org/apidocs/org/junit/Assert.html#fail(java.lang.String)
- Boost Test's BOOST_FAIL - http://www.boost.org/doc/libs/1_34_1/libs/test/doc/components/test_tools/reference/BOOST_FAIL.html