# ScalaCheck Property-Based Testing for Scala and Java

> ScalaCheck tests Scala or Java code against generated inputs and executable properties. It suits developers who want broader edge-case coverage than fixed examples provide, with support for sbt, ScalaTest, specs2, and a standalone runner.

**typelevel/scalacheck** — Property-based testing for Scala

- Repository: https://github.com/typelevel/scalacheck
- Website: http://www.scalacheck.org
- Stars: 1,964 · Forks: 392
- Language: Scala
- License: BSD-3-Clause
- Published: 2026-10-16 · Updated: 2026-10-16 · Language: en
- Canonical page: https://hysenlabs.com/projects/typelevel-scalacheck

## ScalaCheck's Property-Based Testing Model

ScalaCheck addresses a specific weakness of example-based tests. A conventional test supplies a fixed input and checks one expected result, so each new case must be written by hand. ScalaCheck instead lets a developer state a property that should hold across many generated inputs. The property can express an invariant, a relationship between input and output, or another condition derived from the behavior under test. This makes the library relevant to Scala and Java developers working with parsers, data transformations, collections, state transitions, and other code whose valid cases are difficult to enumerate manually.

The library originated with inspiration from Haskell's QuickCheck, but the README says it developed an approach of its own. Its audience is not limited to one test framework. The documentation states that ScalaCheck integrates with sbt, ScalaTest, and specs2, and it can also run independently through its built-in test runner. That makes it possible to introduce property-based testing without requiring the whole project to standardize on a particular execution environment.

There is an important boundary in this approach. ScalaCheck does not derive correctness from examples already present in a test suite. Its value depends on whether the developer can write a property that accurately captures the intended behavior. If the property states something too weak, such as merely exercising a function without checking its result, generation provides breadth but little assurance. If it is too broad, unrelated counterexamples may make the test noisy. The adoption decision therefore starts with the quality of the property, not with the framework integration.

## Generated Inputs and Failure Cases

The core mechanism is property execution over generated test data. Unlike a suite containing only literal examples, a ScalaCheck property asks the runner to evaluate a condition across inputs supplied by generators. The README does not document the complete generator API, shrinking behavior, configuration keys, or internal algorithm, so those details should be checked in the project's downloadable documentation and API reference before designing an advanced generator strategy.

For engineers, this changes the shape of a test. Rather than proving that one list containing a duplicate is rejected, a property can state that duplicate elements are rejected for every generated list. Rather than checking a single empty input, a property can cover empty, minimal, and non-empty values when the relevant generator supports them. This can expose cases that fixed examples miss, especially around boundaries and combinations of values.

The counterexample still has to be actionable. The README does not state how ScalaCheck presents or serializes counterexamples, so it would be unsafe to promise a particular console format or replay syntax. It also does not say whether generated cases are deterministic by default or how a developer controls randomness. Those are concrete questions for proof of concept work. Check whether a failure can be reproduced consistently, whether the reported input is small enough to understand, and whether the test runner records enough context to diagnose the failure.

## sbt, ScalaTest, specs2, and Standalone Execution

ScalaCheck offers several integration paths, but the README does not contain installation commands, dependency coordinates, build snippets, or executable example code. It directs users to the official download page for setup information. This review therefore does not invent an sbt library declaration or assume a particular Scala binary version. The installation decision should be based on the current ScalaCheck release documentation rather than an older example copied from another project.

The first useful evaluation can still be defined precisely. Start with one existing Scala or Java test target that currently contains only fixed cases. Select a behavior that can be stated as a universal condition, restrict it to valid generated inputs, and run it through the same runner the project already uses. If the build uses sbt, consult the ScalaCheck download page for its current sbt integration instructions. If the project already uses ScalaTest or specs2, use the corresponding integration documented by that framework or ScalaCheck. For a small standalone evaluation, the README explicitly confirms that the built-in test runner is available.

No first-run command can be reproduced from the repository information available here. That omission is material. Teams that require copy-and-paste setup instructions, a pinned transitive dependency graph, or compatibility with a particular test framework version should verify those details before adding ScalaCheck to a production build. The project lists `examples/simple-sbt/`, but the contents of that directory are not documented in the README, so it would be inappropriate to invent what that example configures.

## Dependency and Cross-Platform Constraints

One clear adoption advantage is the dependency profile. The README states that ScalaCheck has no external dependencies other than the Scala runtime. For Java programs, ScalaCheck is still relevant because the library can test Java code, but a Java build may need to account for the Scala runtime and the chosen ScalaCheck artifact. The README does not document JVM compatibility, module setup, or Java build coordinates, so those points require verification rather than inference.

The repository also includes examples for Scala.js and command-oriented projects involving LevelDB, Nix, and Redis. The README says ScalaCheck is supported by the Gradle plugin for Scala.js and Scala Native. These entries show repository attention to non-JVM and example scenarios, but they do not establish that every example uses identical APIs or setup. Cross-platform evaluation should therefore verify the target-specific build path and generator behavior directly.

ScalaCheck is not the right tool for every test suite. Fixed examples remain appropriate when an incident has already identified one exact regression input that must remain in the suite. Properties are also a poor fit when requirements cannot be separated from manually judged outputs, when the only available oracle is a second production implementation, or when arbitrary generation would create more invalid states than useful cases. The project solves repetitive input coverage, not unclear specifications. A team that cannot define the expected invariant should resolve that specification problem before adopting it.

## ScalaCheck Compared with QuickCheck and Conventional Tests

ScalaCheck's stated origin is Haskell QuickCheck, and both approaches place generated data at the center of property-based testing. The README does not provide a feature-by-feature comparison, so differences in generator APIs, shrinking, runner design, or language integration cannot be claimed. For Scala projects, the practical alternative is often ordinary example-based testing rather than another Scala property-testing library.

The distinction is in test generation. Fixed tests ask whether specific inputs produce specific outputs. ScalaCheck asks whether a property holds for many generated inputs. These approaches are complementary rather than interchangeable. A project may retain a small fixed example for a known bug, then add properties for broader behavioral coverage. It should not replace clear regression assertions with a property if that removes the concrete case that documents the original failure.

A separate option is to implement generated tests manually in the existing framework. That avoids adding ScalaCheck, but it leaves the project to build generation, failure reporting, and reproduction behavior itself. ScalaCheck supplies a Scala-oriented library with a built-in runner and established framework integrations. Whether that is preferable depends on build compatibility and the value of reusing an existing property-testing model. The repository names Scala projects that use ScalaCheck, but it does not document the outcomes or scope of those uses, so that statement is not evidence of performance or suitability.

## ScalaCheck Maintenance and BSD-3-Clause Upgrade Cost

The repository is not archived, and its last push was on 2026-10-05. The recent release list includes v1.20.0 on 2026-08-27, v1.19.0 on 2025-09-06, and v1.18.1 on 2024-09-15. These dates show recent repository activity and multiple releases across more than one year. They do not, by themselves, define the work required to upgrade an individual Scala project.

ScalaCheck is distributed under the BSD-3-Clause license. The repository includes a `LICENSE` file, which should be reviewed for the exact obligations and notices applicable to a distribution. This is a practical licensing check, not legal advice. Upgrade planning must also account for the target Scala version, test framework, Scala.js or Scala Native setup where applicable, and any changes called out in `CHANGELOG.markdown`. The README does not summarize migration steps for a particular release.

A contained upgrade trial should begin with the version selected by the official setup documentation and the project's existing test suite. Run the smallest representative set of properties before changing all tests. Review `CHANGELOG.markdown`, inspect generated-case failures, and confirm that the build still resolves only the intended runtime dependency. The repository's `.scala-steward.conf` and `.scalafmt.conf` indicate build and formatting configuration in the repository, but their contents are not shown, and they should not be inferred as consumer configuration.

## Conclusion

ScalaCheck is appropriate for Scala or Java developers who can express expected behavior as properties and want generated inputs to exercise their code. It is less suitable for workflows limited to fixed examples, properties that do not represent real requirements, or teams unable to reproduce generated inputs. Evaluate the executable property first, then confirm that generation covers relevant data shapes and that failures are reproducible under the project and runner selected for the build.

## FAQ

### What is ScalaCheck used for?

ScalaCheck is a Scala library for automated property-based testing of Scala or Java programs. It evaluates properties against generated inputs rather than relying only on fixed examples.

### Does ScalaCheck work with sbt and standard Scala test frameworks?

The README says ScalaCheck works with sbt and is integrated with ScalaTest and specs2. It can also be used standalone with its built-in test runner.

### What dependencies does ScalaCheck require?

The README states that ScalaCheck has no external dependencies other than the Scala runtime. Its license is BSD-3-Clause, and the repository includes a `LICENSE` file.

## Sources

- [License: BSD-3-Clause](https://github.com/typelevel/scalacheck/blob/main/LICENSE)
- [Project website](http://www.scalacheck.org)
- [README](https://github.com/typelevel/scalacheck/blob/main/README.md)
- [Releases](https://github.com/typelevel/scalacheck/releases)
- [typelevel/scalacheck on GitHub](https://github.com/typelevel/scalacheck)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/typelevel-scalacheck
