Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


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

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.