Skip to content
Harry Cummings edited this page Jul 13, 2014 · 14 revisions

Tests are a very important communication tool and I wanted a test framework that would allow me to express myself as clearly as possible. I found the RSpec style of testing (which I came to know through the JavaScript test frameworks Jasmine and Mocha) to be particularly flexible and expressive.

Scope

The intent is to keep this library very small. It relies on JUnit for execution and reporting/tooling, and does not attempt to provide its own solution for assertions or test doubles. Users of JarSpec are free to pick whichever libraries they prefer, using standard JUnit or Hamcrest assertions and matchers (which are included by default as a transitive dependency), and/or pulling in whatever other libraries they prefer to use (such as Mockito for test doubles).

Alternatives

There are frameworks for other JVM languages that support this kind of syntax. RSpec itself of course could be used on the JVM thanks to JRuby, and ScalaTest also supports this through its FunSpec class. I don't like to introduce extra languages to a project without good reason though, and I thought Java 8 should be up to the task on its own.

The Gherkin language obviously places human-readability first, and there is a Java implementation of Cucumber. However, I think the use case for these is more business-facing tests and I wouldn't want to use them for my day-to-day unit tests, which should server developers first (both as the people who have to write them and as the audience).