GeoTools : OnlineTestCase support for failure on failed connection


Some people like their unit tests to fail on failure


Ben Caradoc-Davies



OnlineTestCase support for failure on failed connection

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 connect() or
disconnect() will be silent.

To have exceptions thrown by connect() and disconnect() cause tests to fail,
set 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.

Voting was:


  • (tick) Update implementation (patch attached to Jira issue above).
  • (tick) Commit changes to subversion.
  • (tick) Update documentation.

Implementation Changes

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.

Documentation Changes

A note will be added to the testing page to record this optional behaviour: