Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/greghaskins/spectrum

A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.
https://github.com/greghaskins/spectrum

bdd gherkin jasmine java java-8 junit rspec test-runner testing unit-testing

Last synced: 5 days ago
JSON representation

A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.

Awesome Lists containing this project

README

        

Spectrum
========

[![Build Status](https://img.shields.io/travis/greghaskins/spectrum.svg)](https://travis-ci.org/greghaskins/spectrum) [![Codecov](https://img.shields.io/codecov/c/github/greghaskins/spectrum.svg)](https://codecov.io/gh/greghaskins/spectrum) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![Download](https://api.bintray.com/packages/greghaskins/maven/Spectrum/images/download.svg) ](https://bintray.com/greghaskins/maven/Spectrum/_latestVersion) [![Gitter](https://img.shields.io/gitter/room/greghaskins/spectrum.svg)](https://gitter.im/greghaskins/spectrum)

*A colorful BDD-style test runner for Java*

[Spectrum](https://github.com/greghaskins/spectrum) is inspired by the behavior-driven testing frameworks [Jasmine](https://jasmine.github.io/) and [RSpec](http://rspec.info/), bringing their expressive syntax and functional style to Java tests. It is a custom runner for [JUnit](http://junit.org/), so it works with many development and reporting tools out of the box.

![Spectrum with Eclipse via JUnit](docs/junit-screenshot.png)

## Getting Started

Spectrum 1.2.0 is available as a package on [JCenter](https://bintray.com/greghaskins/maven/Spectrum/view) and [Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.greghaskins%22%20AND%20a%3A%22spectrum%22).

- [Quickstart Guide](https://github.com/greghaskins/spectrum/tree/1.2.0/docs/QuickstartWalkthrough.md)
- [Documentation](https://github.com/greghaskins/spectrum/tree/1.2.0/docs)
- [Release Notes](https://github.com/greghaskins/spectrum/releases)
- [Source Code](https://github.com/greghaskins/spectrum/tree/1.2.0)

## Examples

Spectrum supports Specification-style tests similar to [RSpec](http://rspec.info/) and [Jasmine](https://jasmine.github.io/):

```java
@RunWith(Spectrum.class)
public class Specs {{

describe("A list", () -> {

List list = new ArrayList<>();

afterEach(list::clear);

it("should be empty by default", () -> {
assertThat(list.size(), is(0));
});

it("should be able to add items", () -> {
list.add("foo");
list.add("bar");

assertThat(list, contains("foo", "bar"));
});

});
}}
```

And also Gherkin-style tests similar to [Cucumber](https://cucumber.io/docs/reference):

```java
@RunWith(Spectrum.class)
public class Features {{

feature("Lists", () -> {

scenario("adding items", () -> {

Variable> list = new Variable<>();

given("an empty list", () -> {
list.set(new ArrayList<>());
});

when("you add the item 'foo'", () -> {
list.get().add("foo");
});

and("you add the item 'bar'", () -> {
list.get().add("bar");
});

then("it contains both foo and bar", () -> {
assertThat(list.get(), contains("foo", "bar"));
});

});

});
}}
```

For more details and examples, see the [documentation](https://github.com/greghaskins/spectrum/tree/1.2.0/docs).

## Can I Contribute?

Yes please! See [CONTRIBUTING.md](./CONTRIBUTING.md).