how to write expected failures?

cocoa, ocunit, testing, unit-testing, xcode

Solution

An "unexpected failure" is a thrown and unhandled exception. As opposed to a possibly expected failure, which is checked by an assertion.

OCUnit does not provide a way to mark tests as "do not run." Either comment them out (which leaves the risk of the test no longer compiling) or change the method name so it doesn't have a "test" prefix. For example, rename testSomething to XXXtestSomething. (This leaves the risk that you'll forget to change it back.)

Problem

In Xcode, at the end of my unit tests I get a result like this: Test Suite 'All tests' finished at 2012-12-06 10:23:38 +0000 Executed 195 tests, with 0 failures (0 unexpected) in 4.314 (4.485) seconds I would love to find out how can I define tests with expected failures. Normally with other test frameworks I like being able to just define incomplete unit tests as reminders of future work that must be done. These tests should be logged only as warnings, but still yield a "Success" final result if everything else is OK Looking at the output of Xcode, I assume there is a way to achieve the same. However I am having problems finding the right macro to mark incomplete/TODO tests. Furthermore it seems strange to me that normal failures are reported as: Executed 95 tests, with 1 failure (0 unexpected) in 2.314 (2.334) seconds Hence, any test assertion failure seem to be expected. In that case I am even confused with the meaning of (0 unexpected) failures. Could anyone explain the meaning of that part of the log results?, how can it be used? how can I mark incomplete tests?

Original source