Skip to content
reusable tests library
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
.settings updated eclipse settings to new version Feb 27, 2018
main added junit anchor in documentation Aug 31, 2018
test clarified error message in assert exception and added missing tests Aug 31, 2018
.gitignore extracted SINK constant in scripts Mar 29, 2015
.project renamed project testanza->quackery Mar 14, 2015

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.