easytest

Simple, expressive testing library https://github.com/joelburget/easytest

Version on this page:0.2.1
LTS Haskell 13.23:0.2.1
Stackage Nightly 2019-05-27:0.2.1
Latest on Hackage:0.3

See all snapshots easytest appears in

MIT licensed by Joel Burget, Paul Chiusano
Maintained by Joel Burget

Module documentation for 0.2.1

There are no documented modules for this package.

EasyTest is a simple testing toolkit for unit- and property-testing. It's based on the hedgehog property-testing system. Here's an example usage:

module Main where

import           EasyTest
import qualified Hedgehog.Gen   as Gen
import qualified Hedgehog.Range as Range

suite :: Test
suite = tests
  [ scope "addition.ex1" $ unitTest $ 1 + 1 === 2
  , scope "addition.ex2" $ unitTest $ 2 + 3 === 5
  , scope "list.reversal" $ property $ do
      ns <- forAll $
        Gen.list (Range.singleton 10) (Gen.int Range.constantBounded)
      reverse (reverse ns) === ns
  -- equivalent to `scope "addition.ex3"`
  , scope "addition" . scope "ex3" $ unitTest $ 3 + 3 === 6
  , scope "always passes" $ unitTest success -- record a success result
  , scope "failing test" $ crash "oh noes!!"
  ]

-- NB: `run suite` would run all tests, but we only run
-- tests whose scopes are prefixed by "addition"
main :: IO Summary
main = runOnly "addition" suite

This generates the output:

━━━ runOnly "addition" ━━━
  ✓ addition.ex1 passed 1 test.
  ✓ addition.ex2 passed 1 test.
  ⚐ list.reversal gave up after 1 discard, passed 0 tests.
  ✓ addition.ex3 passed 1 test.
  ⚐ always passes gave up after 1 discard, passed 0 tests.
  ⚐ failing test gave up after 1 discard, passed 0 tests.
  ⚐ 3 gave up, 3 succeeded.

We write tests with ordinary Haskell code, with control flow explicit and under programmer control.

Changes

0.3.0 (3/6/2019)

  • Switch backend of the library to build on the hedgehog library
  • Change Test from kind * -> * to kind *. See my note for motivation. In short, this fixes a lot of bugs and we now support property testing.

Upgrading:

Test now has kind *. It’s no longer a functor, applicative, monad, etc.

  • You can build an atomic test with unitTest (/ example) or propertyTest.
  • Also see bracket, bracket_, and finally for tests with setup / teardown.
  • tests and scope work as before. I mention them here because they’re the other way to build tests.

Removed:

  • expect b -> assert b
  • expectEq a b -> a === b
  • expectJust -> matches _Just
  • expectRight -> matches _Right
  • expectRightNoShow -> matches _Right
  • expectLeft -> matches _Left
  • expectLeftNoShow -> matches _Left

0.2.1 (10/24/2018)

0.2 (3/27/2018)

0.1.1 (3/25/2018)

0.1 (3/6/2018)

Initial release.

Used by 2 packages:
comments powered byDisqus