Skip to content
reusable tests library
Java Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.

Having comprehensive collection of tests is something every TDD practitioner aims for. But often writing tests gets tedious and we cut corners due to practical reasons.

  • Do you test all getters and setters of every bean?
  • Do you test equals and hashCode of every value object you write?
  • Do you test every corner case when implementing List or Set?

Quackery lets you write those tests once and reuse them in different contexts.

Reusable test can be something simple, like trivial assertion.

import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.quackery.Case.newCase;
import static org.quackery.Suite.suite;
import static;

import org.junit.runner.RunWith;
import org.quackery.Quackery;
import org.quackery.Test;
import org.quackery.junit.QuackeryRunner;

public class StringTest {
  public static Test string_is_equal_to_itself() {
    return suite("string is equal to itself")
        .add("three", StringTest::isEqualToItself)
        .addAll(asList("four", "five", "six"), StringTest::isEqualToItself);

  private static Test isEqualToItself(Object value) {
    return newCase(
        format("%s is equal to itself", value),
        () -> assertTrue(value.equals(value)));


But it can be something big, like a customizable contract for testing whole class. For example, quackery has built-in contract for testing that given Class implements Collection contract.

public class ArrayListTest {
  public static Test test() {
    return quacksLike(Collection.class)


See documentation for all features.

You can’t perform that action at this time.