RSpec (or Jasmine/Mocha) style tests for native Java 8
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
LICENSE
README.md
infinitest.filters
pom.xml

README.md

JarSpec

What?

RSpec (or Jasmine/Mocha) style tests for native Java 8, a bit like the following:

@RunWith(JarSpecJUnitRunner.class)
public class MinimalSpec implements Specification {
    @Override
    public SpecificationNode root() {
        return describe("This specification",
            it("contains a statement with a test", () -> assertTrue(true))
        );
    }
}

Why?

Allows for more expressive test names without very_long_underscore_ridden_test_method_names, and for more flexible test structure. Java 8 features such as lambda expressions make this possible with less boilerplate. See wiki/Motivation for more.

How?

  1. Add JarSpec to your project dependencies. See below for Maven and the dependency info page for other build tools.

  2. Start writing specs! See wiki/Implementing Specifications for more details, or the project's own tests for examples.

Using Maven Maven Central

Add the dependency to your pom:

    <dependencies>
        ....
        <dependency>
            <groupId>io.hgc</groupId>
            <artifactId>jarspec</artifactId>
            <version>2.0.0</version>
            <scope>test</scope>
        </dependency>
        ....
    </dependencies>

Configure SureFire to pick up classes named *Spec (although you can stick with the default *Test convention if you prefer):

    <build>
        <plugins>
            ...
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <includes>
                        <include>**/*Spec.java</include>
                    </includes>
                </configuration>
            </plugin>
            ...
        </plugins>
    </build>

When?

The current release on Maven Central is stable. See open milestones for further planned features. Releases numbers follow the Semantic Versioning specification for backwards compatibility.


Developer resources: Test results Build status Coverage report Coverage Status Task board