Spectrum

A colorful BDD-style test runner for Java

License

License

GroupId

GroupId

com.greghaskins
ArtifactId

ArtifactId

spectrum
Last Version

Last Version

1.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

Spectrum
A colorful BDD-style test runner for Java
Project URL

Project URL

https://github.com/greghaskins/spectrum
Source Code Management

Source Code Management

https://github.com/greghaskins/spectrum/tree/master

Download spectrum

How to add to project

<!-- https://jarcasting.com/artifacts/com.greghaskins/spectrum/ -->
<dependency>
    <groupId>com.greghaskins</groupId>
    <artifactId>spectrum</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.greghaskins/spectrum/
implementation 'com.greghaskins:spectrum:1.2.0'
// https://jarcasting.com/artifacts/com.greghaskins/spectrum/
implementation ("com.greghaskins:spectrum:1.2.0")
'com.greghaskins:spectrum:jar:1.2.0'
<dependency org="com.greghaskins" name="spectrum" rev="1.2.0">
  <artifact name="spectrum" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.greghaskins', module='spectrum', version='1.2.0')
)
libraryDependencies += "com.greghaskins" % "spectrum" % "1.2.0"
[com.greghaskins/spectrum "1.2.0"]

Dependencies

compile (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Spectrum

Build Status Codecov MIT 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

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.

Versions

Version
1.2.0
1.1.1
1.1.0
1.0.2