onlinetestcase support for failure on failed connection - STEMLab/geotools GitHub Wiki
-
Motivation: Some people like their unit tests to fail on failure
-
Contact: Ben Caradoc-Davies
-
Tagline: OnlineTestCase support for failure on failed connection
Description
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.
Discussion
- http://n2.nabble.com/Prevent-silent-failures-of-online-tests-td1954287.html
- http://n2.nabble.com/Proposal%3A-support-test-fixtures-that-fail-on-failed-connection--GEOT-1951--td1958345.html
Announcement of this proposal, and following discussion:
Status
This proposal has been accepted. The implementation is complete.
Voting was:
- Andrea Aime: +1
- Ian Turton
- Justin Deoliveira
- Jody Garnett: +1
- Martin Desruisseaux
- Simone Giannecchini
Tasks
| :white_check_mark: | :no_entry: | :warning: | :negative_squared_cross_mark: |
------------|--------------------|------------|-------------------------|-------------------------------| no progress | done | impeded | lack mandate/funds/time | volunteer needed |
- :white_check_mark: Update implementation (patch attached to Jira issue above).
- :white_check_mark: Commit changes to subversion.
- :white_check_mark: 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: