Popularity
3.2
Declining
Activity
0.0
Stable
142
14
22

Description

Spectrum is inspired by the behavior-driven testing frameworks Jasmine and RSpec, bringing their expressive syntax and functional style to Java tests. It is a custom runner for JUnit, so it works with many development and reporting tools out of the box.

Programming language: Java
License: MIT License
Tags: Testing     JUnit     BDD    
Latest version: v1.2.0

Spectrum alternatives and similar libraries

Based on the "Testing" category.
Alternatively, view Spectrum alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of Spectrum or a related project?

Add another 'Testing' Library

README

Spectrum

Build Status Codecov [MIT License](LICENSE) Download Gitter

A colorful BDD-style test runner for Java

Spectrum is inspired by the behavior-driven testing frameworks Jasmine and RSpec, bringing their expressive syntax and functional style to Java tests. It is a custom runner for JUnit, so it works with many development and reporting tools out of the box.

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

<!---freshmark main output = input.replace(/\b\d+.\d+.\d+\b/g, '{{stableVersion}}'); -->

Getting Started

Spectrum 1.2.0 is available as a package on JCenter and Maven Central.

Examples

Spectrum supports Specification-style tests similar to RSpec and Jasmine:

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

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

    List<String> 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:

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

  feature("Lists", () -> {

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

      Variable<List<String>> 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.

Can I Contribute?

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

<!---freshmark /main -->


*Note that all licence references and agreements mentioned in the Spectrum README section above are relevant to that project's source code only.