Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

We like tests. We use JUnit and Mockito (and, sometimes, reluctantly, PowerMockito.) HTTP Integration tests use grizzly. 

Writing tests

Each module has unit tests in the src/test/java/org/fcrepo/ directory and integration tests in the src/test/java/org/fcrepo/integration/ directory.

The unit tests often use mock objects to create surrogates for the Modeshape and webapp machinery that much of the Fedora code interacts with.  Some good examples of mock object usage are in the fcrepo-http-api module (e.g., FedoraNodesTest.java) and in the fcrepo-jms-indexer-core module (e.g. IndexerGroupTest.java).

Integration tests use embedded Modeshape, servlet engine, etc. to run real requests against the code.  The web-based tests typically use HttpClient to make requests.  Non-web tests, use injection to have the repository and service objects made accessible to the tests (the embedded repository and injection are configured in the src/test/resources directory).  Some good examples are in the fcrepo-http-api module (e.g. FedoraNodesIT.java) and fcrepo-kernel module (e.g., FedoraResourceImplIT.java).

Running the tests

...

Code Block
$ mvn test verify

...