Skip to content
atp-miptPublic

About

A JUnit Platform test engine for comparison testing. Run Jupiter tests against multiple implementations and see each implementation's result for every input.

Topics

Resources

Stars

13 stars

Watchers

0 watching

Forks

Repository files navigation

Elara — comparison testing for JUnit Jupiter

Maven Central

Elara runs the same JUnit Jupiter tests against multiple implementations of a contract. It gives each implementation a named result in the test tree so you can see which one failed and rerun it directly.

Use Elara to compare a reference implementation with a replacement, test several backends, or check an optimized implementation against the same inputs and assertions.

The user guide explains the motivation, the API, lifecycle, extension compatibility, and reruns. The Javadoc is the API reference.

Quick start

Elara runs on Java 17 or later with JUnit 6. Add it as a test dependency from Maven Central. Use the JUnit BOM to keep the Jupiter and Platform modules on 6.1.3, the version Elara is built and verified against.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.junit</groupId>
            <artifactId>junit-bom</artifactId>
            <version>6.1.3</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.atp-fivt</groupId>
        <artifactId>elara</artifactId>
        <version>1.0.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

Place your comparison class under src/test/java and run mvn test with Maven Surefire. Elara is discovered automatically on the test classpath.

The multiplication example runs two input rows against the GOOD and BUGGY variants returned by CalcSource. MulTest.java · CalcSource.java

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.atpfivt.elara.api.ComparisonArguments;
import org.atpfivt.elara.api.ComparisonTest;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

@ComparisonTest(source = CalcSource.class)
class MulTest {
    @ParameterizedTest(quoteTextArguments = false)
    @ComparisonArguments(3)
    @CsvSource({ "2, 3, 6", "4, 5, 20" })
    void mul(int a, int b, int expected, Calc calc) {
        assertEquals(expected, calc.mul(a, b));
    }
}

Each input row has a separate result for each implementation. The example deliberately fails on the second row for Buggy.

mul(int, int, int, Calc)
├── [1] 2, 3, 6
│   ├── Good  ✓
│   └── Buggy ✓
└── [2] 4, 5, 20
    ├── Good  ✓
    └── Buggy ✗ expected: <20> but was: <21>

The user guide covers the rest: declaring variants and the source that supplies them, parameter order, skipping a variant, repeated tests, resource lifecycle, Jupiter extensions, reruns, and how the engine works.

Contributing

The engine module contains the API and the JUnit Platform engine; its Javadoc is the API reference. The examples module demonstrates behavior, and verification checks test trees, lifecycle, extension compatibility, and reruns through the Launcher API. The doc module builds the user guide with Asciidoctor and unpacks the Javadoc jar of engine next to it: mvn -pl doc -am -DskipTests verify writes the site to doc/target/generated-docs (index.html and apidocs/); the docs workflow builds it for every pull request and publishes it to GitHub Pages on every push to main.

Building Elara needs JDK 21 and Maven 3.9 or later: the test sources use newer language features, and the build checks that the library and its dependencies stay compatible with Java 17. Run mvn clean verify before submitting a change. The build runs Checkstyle on all sources and SpotBugs on all classes, and every Java file must start with the license header. Every package needs a package-info.java, and every public or protected type and member needs a Javadoc comment with its @param and @return tags: Checkstyle checks the comments, and the Javadoc build fails on any doclint warning. The documentation sources (*.adoc, *.md) are spellchecked with aspell: run spellcheck and add project-specific words to allowed_spelling_words. For a bug report, include the JDK and JUnit versions, the runner, and a minimal test that reproduces the behavior. GitHub Issues

License

Elara is released under the Apache License, Version 2.0.

About

A JUnit Platform test engine for comparison testing. Run Jupiter tests against multiple implementations and see each implementation's result for every input.

Topics

Resources

Stars

13 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages