Java contract test helpers
chas66 edited this page Sep 5, 2012
·
3 revisions
Pages 21
- Home
- Aggregating tests in suites
- Assertions
- Assumptions with assume
- Categories
- Continuous testing
- Exception testing
- Getting started
- Ignoring tests
- Java contract test helpers
- Maintainer documentation
- Matchers and assertthat
- Multithreaded code and concurrency
- Parameterized tests
- Releasing Snapshots
- Rules
- Test fixtures
- Test runners
- Theories
- Timeout for tests
- Use with maven
- Show 6 more pages…
Clone this wiki locally
Certain code you override or implement is expected to adhere to contracts laid out in the Java SDK. Examples of these are:
- equals method: http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
- hashcode method: http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
- Comparable interface: http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html
- Serializable interface: http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html
A project called junit-addons on SourceForge has test superclasses that enable compliance testing of objects to these java contracts
Although these test helper classes work without issue, they are designed for pre-generic java, and JUnit 3.x and could be confusing to developers used to JUnit 4.x annotations style of test implementation.
An modernized JUnit4 version of these test helpers, with examples, is at https://github.com/chas66/TestHelpers