Specrtrum is a BDD-style test runner for Java 8. It leverages lambda functions to provide a test-writing experience that is familiar to users of BDD tools from other platforms like Ruby and JavaScript. The library is implemented as a custom runner for JUnit 4, allowing Spectrum tests to integrate (mostly) seamlessly with existing IDEs and tooling.
Spectrum provides two ways of writing tests:
- Specification-style test DSL with
describe
/it
/beforeEach
/ etc. - Gherkin-style test DSL with
feature
/scenario
/given
/when
/then
/ etc.
Spectrum also supports:
- Unlimited nesting of suites within suites
- Rigorous error handling and reporting when something unexpected goes wrong
- Compatibility with most existing JUnit tools; no configuration required
- Plugging in familiar JUnit-friendly libraries like
MockitoJUnit
orSpringJUnit
via JUnit@Rule
s handling. - Tagging specs for selective running
- Mixing Spectrum tests and normal JUnit tests in the same project suite
- RSpec-style
aroundEach
andaroundAll
hooks for advanced users and plugin authors
Unlike some BDD-style frameworks, Spectrum is only a test runner. Assertions, expectations, mocks, and matchers are the purview of other libraries such as Hamcrest, AssertJ, Mockito, or plain JUnit.
See the quickstart waklthrough and the docs for writing Specification-style or Gherkin-style tests.