junit-quickcheck

Property-based testing, JUnit-style

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.pholser
ArtifactId

ArtifactId

junit-quickcheck
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

pom
Description

Description

junit-quickcheck
Property-based testing, JUnit-style
Project URL

Project URL

http://github.com/pholser/junit-quickcheck
Source Code Management

Source Code Management

http://github.com/pholser/junit-quickcheck

Download junit-quickcheck

Filename Size
junit-quickcheck-1.0.pom 20 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.pholser/junit-quickcheck/ -->
<dependency>
    <groupId>com.pholser</groupId>
    <artifactId>junit-quickcheck</artifactId>
    <version>1.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.pholser/junit-quickcheck/
implementation 'com.pholser:junit-quickcheck:1.0'
// https://jarcasting.com/artifacts/com.pholser/junit-quickcheck/
implementation ("com.pholser:junit-quickcheck:1.0")
'com.pholser:junit-quickcheck:pom:1.0'
<dependency org="com.pholser" name="junit-quickcheck" rev="1.0">
  <artifact name="junit-quickcheck" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.pholser', module='junit-quickcheck', version='1.0')
)
libraryDependencies += "com.pholser" % "junit-quickcheck" % "1.0"
[com.pholser/junit-quickcheck "1.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • core
  • generators
  • guava
  • examples

Build Status Code Quality: Java Total Alerts

Software Quality Award 2016

junit-quickcheck: Property-based testing, JUnit-style

junit-quickcheck is a library that supports writing and running property-based tests in JUnit, inspired by QuickCheck for Haskell.

Property-based tests capture characteristics, or "properties", of the output of code that should be true given arbitrary inputs that meet certain criteria. For example, imagine a function that produces a list of the prime factors of a positive integer n greater than 1. Regardless of the specific value of n, the function must give a list whose members are all primes, must equal n when all multiplied together, and must be different from the factorization of a positive integer m greater than 1 and not equal to n.

Rather than testing such properties for all possible inputs, junit-quickcheck and other QuickCheck kin generate some number of random inputs, and verify that the properties hold at least for the generated inputs. This gives us some reasonable assurance upon repeated test runs that the properties hold true for any valid inputs.

Documentation

Documentation for the current stable version

Basic example

    import com.pholser.junit.quickcheck.Property;
    import com.pholser.junit.quickcheck.runner.JUnitQuickcheck;
    import org.junit.runner.RunWith;

    import static org.junit.Assert.*;

    @RunWith(JUnitQuickcheck.class)
    public class StringProperties {
        @Property public void concatenationLength(String s1, String s2) {
            assertEquals(s1.length() + s2.length(), (s1 + s2).length());
        }
    }

Other examples

After browsing the documentation, have a look at some examples in module junit-quickcheck-examples. These are built with junit-quickcheck.

Versions

Version
1.0
0.9.5
0.9.4
0.9.3
0.9.2
0.9.1
0.9
0.8.2
0.8.1
0.8
0.8-beta-2
0.8-beta-1
0.8-alpha-8
0.8-alpha-7
0.8-alpha-6
0.8-alpha-5
0.8-alpha-4
0.8-alpha-3
0.8-alpha-2
0.8-alpha-1
0.7
0.7-beta-2
0.7-beta-1
0.7-alpha-2
0.7-alpha-1
0.6.1
0.6
0.6-beta-1
0.6-alpha-3
0.6-alpha-2
0.6-alpha-1
0.5
0.5-beta-1
0.5-alpha-4
0.5-alpha-3
0.5-alpha-2
0.5-alpha-1
0.4
0.4-beta-3
0.4-beta-2
0.4-beta-1
0.3
0.2
0.1