Cuppa is a testing framework for Java 8. It makes writing tests productive and fun.
- Be descriptive: Use strings – not identifiers – to clearly describe the behaviour you are testing. Test reports produced by Cuppa read like good documentation.
- Group tests together: Create structure in your test files to reduce repetition and improve readability. Groups of tests can share setup and teardown steps.
- Define tests at runtime: Cuppa makes it trivial to write parameterised tests. It's as simple as a
for
loop. Cuppa is also easy to extend - there's no need to write annotations.
@Test
public class ListTest {
{
describe("List", () -> {
describe("#indexOf", () -> {
it("returns -1 when the value is not present", () -> {
List<Integer> list = Arrays.asList(1, 2, 3);
assertThat(list.indexOf(5)).isEqualTo(-1);
});
});
});
}
}
Check out the website for more examples.
For full details see the getting started guide on the website.
Add a test dependency for Cuppa in your project's POM:
<dependency>
<groupId>org.forgerock.cuppa</groupId>
<artifactId>cuppa</artifactId>
<version>1.3.1</version>
<scope>test</scope>
</dependency>
See the Maven integration guide for details on how to get Maven to run the tests automatically.
Alternatively, you can download binaries for the latest release.
To run your Cuppa tests, use the Cuppa API:
public class EntryPoint {
public static void main(String[] args) {
Runner runner = new Runner();
TestBlock rootBlock = runner.defineTests(Collections.singletonList(MyTestClass.class));
runner.run(rootBlock, new DefaultReporter());
}
}
You'll need JDK 8 installed and available on the path.
Cuppa is built using Gradle:
$ cd cuppa
$ ./gradlew build
Run ./gradlew tasks
to see a list of all available tasks.
Cuppa is licensed under an Apache 2.0 license. The documentation is licensed under a Creative Commons license.
Cuppa is inspired by the wonderful Mocha, a testing framework for JavaScript.