FREEDOM251

Freedom251 › Unit Testing

Hspec

Free plan Linux

Visit Hspec Alternatives Pricing

Hspec's own site

What Hspec is

Hspec is a free testing framework for Haskell that organizes tests as specifications. Its domain-specific language groups examples in nested `describe` and `it` blocks, with expectations for equality, predicates, and exceptions. Hspec can run QuickCheck properties as test examples and integrates with QuickCheck, SmallCheck, and HUnit. Existing HUnit test suites can run alongside Hspec specs, and HUnit assertions can be used within specs. The `hspec-discover` preprocessor scans spec files and generates test-driver boilerplate; automatic discovery expects filenames ending in `Spec.hs` and a top-level `spec` binding. Runner options include filtering or skipping examples, randomizing order, failing fast, rerunning failures, and choosing a formatter. Options can come from user or project configuration files, environment variables, or command-line arguments, with command-line settings taking precedence. The manual documents use through Cabal, Stack, and GHCi. Specs marked for parallel execution can run across multiple CPUs with the documented threaded setup. Hspec is listed under the MIT license, and its Cabal source package is available on Hackage.

Who it suits

Hspec suits Haskell developers who want structured example-based tests, property checks, or a way to run existing HUnit suites. Its discovery and runner options may also help teams standardize test setup and execution.

What it does well

  • Free Haskell testing framework
  • Expectations cover equality, predicates, and exceptions
  • Integrates with QuickCheck, SmallCheck, and HUnit
  • Can generate test-driver boilerplate
  • Runner supports filtering and rerunning failures

What to know first

  • Supported language is Haskell
  • Automatic discovery expects `Spec.hs` files and a top-level `spec` binding
  • Parallel execution requires a threaded runtime setup

Plans

PlanBilled and limitsPrice
HspecHaskell testing framework · source package available on HackageFree

As hspec.github.io lists them, read 9 Oct 2026. The maker's own page has the final word.

Getting started

  1. Install the Cabal source package from Hackage
  2. Create Hspec specifications with nested `describe` and `it` blocks
  3. Use `hspec-discover` with `Spec.hs` files exporting `spec`
  4. Pass runner options through Cabal, Stack, GHCi, configuration files, or the command line

Verdict

Hspec brings specification-style examples together with property checks and HUnit compatibility. Its discovery convention and threaded setup are worth accounting for when configuring a project.

Questions

What does Hspec cost?

Hspec is free, with a free plan priced at $0.

Which language and platform does it support?

Hspec supports Haskell and is listed for Linux.

Can Hspec run property tests?

Yes. QuickCheck properties can run as Hspec test examples.

Does it work with HUnit?

Hspec can run existing HUnit suites, and HUnit assertions can be used in Hspec specs.

What is hspec-discover?

It scans specification files and generates test-driver boilerplate. Discovery expects `Spec.hs` filenames and a top-level `spec` binding.

Facts from Hspec's own pages

Configuration
Hspec can read options from `~/.hspec`, a project `.hspec` file, environment variables, or command-line arguments, with command-line options taking highest precedence. · hspec.github.io, 9 Oct 2026
Discovery
The `hspec-discover` tool can generate a test driver for automatically discovered spec files. · hspec.github.io, 9 Oct 2026
Discovery convention
Hspec's automatic discovery expects spec files to end in `Spec.hs` and export a top-level `spec` binding. · hspec.github.io, 8 Oct 2026
Distribution
The Hspec package is available as a Cabal source package from Hackage. · hackage.haskell.org, 9 Oct 2026
Expectations
Hspec includes combinators for equality, predicates, and expected exceptions. · hspec.github.io, 9 Oct 2026
HUnit compatibility
Hspec can run existing HUnit test suites, and HUnit assertions can be used in Hspec specs. · hspec.github.io, 8 Oct 2026
Integrations
Hspec integrates with QuickCheck, SmallCheck, and HUnit. · hspec.github.io, 8 Oct 2026
Legacy tests
Hspec can run existing HUnit tests alongside ordinary spec items through `fromHUnitTest` from `hspec-contrib`. · hspec.github.io, 9 Oct 2026
License
The GitHub repository identifies the project license as MIT. · github.com, 9 Oct 2026
Maker and headquarters
The opened Hspec pages identify Hspec as a project but do not state a maker organization or headquarters. · hspec.github.io, 9 Oct 2026
Parallel execution
Specs can be marked for parallel execution to use multiple CPUs; the documented example links with `-threaded` and runs with `+RTS -N -RTS`. · hspec.github.io, 9 Oct 2026
Property testing
Hspec can run QuickCheck properties as test examples. · hspec.github.io, 8 Oct 2026
Purpose
Hspec is a testing framework for Haskell. · hspec.github.io, 9 Oct 2026
Supported build tools
The manual documents passing Hspec options through Cabal, Stack, and GHCi. · hspec.github.io, 9 Oct 2026
Test controls
Runner options include matching or skipping examples, randomizing execution order, failing fast, rerunning failures, and choosing a formatter. · hspec.github.io, 9 Oct 2026
Test descriptions
Hspec provides a domain-specific language for organizing tests with nested `describe` and `it` blocks. · hspec.github.io, 8 Oct 2026
Test discovery
The `hspec-discover` preprocessor scans for spec files and generates test driver boilerplate. · hspec.github.io, 8 Oct 2026
Test DSL
Hspec provides a friendly DSL for defining and organizing tests with `describe` and `it`. · hspec.github.io, 9 Oct 2026
Test integrations
Hspec integrates with QuickCheck, SmallCheck, and HUnit. · hspec.github.io, 9 Oct 2026

Where Hspec stands on Freedom251

Look at these too