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: 3 months ago 
        JSON representation
    
A BDD-style test runner for Java 8. Inspired by Jasmine, RSpec, and Cucumber.
- Host: GitHub
 - URL: https://github.com/greghaskins/spectrum
 - Owner: greghaskins
 - License: mit
 - Created: 2014-11-07T09:13:12.000Z (almost 11 years ago)
 - Default Branch: master
 - Last Pushed: 2018-03-26T18:18:26.000Z (over 7 years ago)
 - Last Synced: 2024-12-09T09:11:08.222Z (11 months ago)
 - Topics: bdd, gherkin, jasmine, java, java-8, junit, rspec, test-runner, testing, unit-testing
 - Language: Java
 - Homepage:
 - Size: 1.06 MB
 - Stars: 145
 - Watchers: 17
 - Forks: 23
 - Open Issues: 24
 - 
            Metadata Files:
            
- Readme: README.md
 - Contributing: CONTRIBUTING.md
 - License: LICENSE
 
 
Awesome Lists containing this project
- awesome-java - Spectrum
 
README
          Spectrum
========
[](https://travis-ci.org/greghaskins/spectrum) [](https://codecov.io/gh/greghaskins/spectrum) [](LICENSE) [ ](https://bintray.com/greghaskins/maven/Spectrum/_latestVersion) [](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.

## 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).