Some people like their unit tests to fail on failure
This page represents the current plan; for discussion please check the tracker link above.
OnlineTestCase provides infrastructure for configuring online test case fixtures. The current behaviour disables the test if an exception is thrown in the connect() method. It is proposed that an optional key be added to the test fixture property file to change this behaviour to failing if connect() fails.
From the javadoc (proposed code):
The default behaviour of this class is that if
connect() throws an exception, the test
suite is disabled, causing each test to pass without being run. In addition, exceptions thrown by
disconnect() are ignored. This behaviour allows tests to be robust against transient
outages of online resources, but also means that local software failures in
disconnect() will be silent.
To have exceptions thrown by
disconnect() cause tests to fail,
skip.on.failure=false in the fixture property file. This restores the
traditional behaviour of unit tests, that is, that exceptions cause unit tests to fail.
Announcement of this proposal, and following discussion:
This proposal has been accepted. The implementation is complete.
- Update implementation (patch attached to Jira issue above).
- Commit changes to subversion.
- Update documentation.
The optional key
skip.on.failure may be added to an
OnlineTestCase fixture property file. For example:
skip.on.failure = false
If this key is absent or set to
true, the original behaviour is retained.
A note will be added to the testing page to record this optional behaviour: