General

I use unit-testing. What's the point of contracts?

Unit-testing only detect errors for the test-cases that have been written, when they are executed in a controlled test environment. Contracts detect errors also when the code is running live in the wild.

[top]


Why shouldn't I try to catch and recover from a contract violation?

You're doing it wrong if you do. A require violation implies a bug at the calling client side. You should correct the bug at the calling side, thereby preventing the violation to happen in the first place.

An ensure violation implies a bug at the supplier side. The supplier does not live up to their obligations. You should correct the bug at the supplier side. If the supplier can not live up to their promises, throw a recoverable exception instead, that the client can catch and recover from.

[top]

Installation

How do I install valid4j?

This library is available at [Maven Central Repository](http://search.maven.org/). Add this dependency to your `pom.xml`

<dependency> <groupId>org.valid4j</groupId> <artifactId>valid4j</artifactId> <version>0.4.0</version> </dependency>

[top]

Back to top

Reflow Maven skin by Andrius Velykis.