Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Writing tests

Joshua Gleitze edited this page Feb 17, 2015 · 5 revisions

Writing test

If you want to start writing tests, it's best to look at existing tests. Don't be afraid, just write something and commit a pull request.

Nevertheless, we'll discuss some important things:

Documentation

You'll find the rendered Javadoc of the project here on our GitHub page, (and as well in the repository). This should be your main source of information to write tests.

Style

Please make sure to stick to our Style Guidelines. It's important that others can read your code easily!

JUnit

We won't talk about JUnit too much here. This article is a very good read for a well written, brief introduction. We will just show the most important elements:

  • @Test: methods annotated with this will be run in a test run.
  • @Before, @After: methods annotated with this will be run before/after each @Test method.
  • @BeforeClass, @AfterClass: methods annotated with this will be run before/after the first/last @Test method.
  • assertThat(String message, T actual, Matcher<T> matcher) asserts a test result. message should be a detailed description how the failure was produced. actual is the result you got and matcher describes which result was expected.
  • is(T expected), startsWith(T expected): construction methods for a Matcher<T>.

Examples

For examples, simply look at existing tests.

Clone this wiki locally