This repository was archived by the owner on Jul 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Writing tests
Joshua Gleitze edited this page Feb 17, 2015
·
5 revisions
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:
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.
Please make sure to stick to our Style Guidelines. It's important that others can read your code easily!
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@Testmethod. -
@BeforeClass,@AfterClass: methods annotated with this will be run before/after the first/last@Testmethod. -
assertThat(String message, T actual, Matcher<T> matcher)asserts a test result.messageshould be a detailed description how the failure was produced.actualis the result you got andmatcherdescribes which result was expected. -
is(T expected),startsWith(T expected): construction methods for aMatcher<T>.
For examples, simply look at existing tests.