Questions tagged [hspec]

hspec is a behavior-driven Development for Haskell. It is a testing framework for Haskell.

Hspec is a testing framework for Haskell. It is roughly based on the Ruby library RSpec. Some of Hspec's distinctive features are:

  • A friendly DSL for defining tests
  • integration with QuickCheck, SmallCheck, and HUnit
  • parallel test execution
  • automatic discovery of test files

For more details click here

77 questions
1
vote
2 answers

Is it possible to skip tests in HSpec test suite?

In most programming languages it is easy to skip a test in some circumstances. Is there a proper way to do that in haskell HSpec based test suite?
palik
  • 2,425
  • 23
  • 31
1
vote
0 answers

Hspec unable to load interface for Spec file

I am trying to run hspec but getting error as "Failed to load interface for Spec file". I tried similar example from github, got same error. Please suggest where I am going wrong...(PS: I am able to run this with stack). Example from github…
Manvi
  • 1,136
  • 2
  • 18
  • 41
1
vote
2 answers

Haskell Pipes and testing with HSpec

I have written a program for a project that uses Pipes, which I love! I'm struggling to unit test my code however. I have a series of functions of type Pipe In Out IO () (for example) that I wish to test with HSpec. How can I go about this? For…
Alex
  • 8,093
  • 6
  • 49
  • 79
1
vote
1 answer

How to division operator scenario when denominator is zero , or both numerator and denominator are zero?

I am trying to do TDD in haskell using HSpec. So while writing special case scenario for division operator for example: 3 / 0 => Infinity 0 / 0 => Nan How to test the above cases using Hspec ?
phoenix
  • 81
  • 1
  • 9
1
vote
1 answer

How to test with hspec whether the readerError function was executed

I'm new to Haskell. I have written the following piece of code which will parse the arguments sent to a script; module Billing.Options ( GlobalOpts(..) , globalOptsParser , parseDb ) where import Options.Applicative import…
1
vote
1 answer

Setting up a test suite in HSpec

How do I specify test suites in HSpec? I'm going to have multiple *.hs test files for each of my modules and I want to just run stack test and for all of the tests to run. How do I set that up? I tried to list the test modules like this in my cabal…
user3248346
1
vote
1 answer

Scotty with Persistent and Hspec-wai

Problem trying to unit test routes. Scotty, Persistent, and Hspec-WAI. Unlike Yesod or Spock, Scotty doesn't have a nice place to store database handlers. I've got it working by having one massive "do" that starts up the database, keeps the database…
Chad Brewbaker
  • 2,523
  • 2
  • 19
  • 26
1
vote
3 answers

Testing custom data types which do not implement Eq

Lets say I have the following custom data type: data Animal = Characteristics [Char] (Set.Set [Char]) and some function checkAnimalType :: [Char] -> Animal -> [Animal] now I'm trying to write hspec tests for this like so: describe…
Abraham P
  • 15,029
  • 13
  • 58
  • 126
1
vote
2 answers

hspec failing to import (private) code dependency despite CPP override

Let's say I have a src file like so: {-# LANGUAGE CPP #-} module Alphabet ( #ifdef TEST alphabet #endif ) where alphabet :: [Char] alphabet = "abcdefghijklmnopqrstuvwxyz" a .cabal file like so: name: Alphabet version: …
Abraham P
  • 15,029
  • 13
  • 58
  • 126
1
vote
0 answers

How to get quickcheck failure details from hspec being run with cabal test

I am using hspec with quickcheck, as per http://hspec.github.io/quickcheck.html however, on failures, I simply get that a failure happened in a spec, no details about the data used by quickcheck so I can start diagnosing the failure. How do I get…
Michael Neale
  • 19,248
  • 19
  • 77
  • 109
1
vote
1 answer

How to tell HSpec where to look for the source files to be tested

I'm new to Haskell and I wanted to add tests to my first project. I chose HSpec for this. My only spec file doesn't contain anything special so far. I just copied the example from the HSpec website and added import statements for my own modules to…
rausch
  • 3,148
  • 2
  • 18
  • 27
1
vote
0 answers

Passing more values into hspec tests cases with Yesod

I'm trying to enhance my current test fixtures with passing more than just foundation (of type App) into hspec test cases. In the example below I'm passing an additional Text value inside of a tuple (as IO (App, Text) ) as opposed to directly…
Alexandr Kurilin
  • 7,685
  • 6
  • 48
  • 76
0
votes
0 answers

How to emulate post-mortem debugging mode in HSpec/Tasty

Haskell debugger does support post-mortem debugging (setting breakpoints on raised exception). So it should be possible to drop into debugger on testing failtures, as pytest --pdb does it. In principle you should load test runner in ghci/ghcid with…
uhbif19
  • 3,139
  • 3
  • 26
  • 48
0
votes
1 answer

How to test specific hSpec property using `--match` and cabal

I have a bunch of test modules and I can run a specific one using cabal test. cabal test Module.Name.Here The module contains many tests and one of them fails and it gives the following message. To rerun use: --match…
twitu
  • 553
  • 6
  • 12
0
votes
1 answer

How to use Hspec/Yesod.Test with Sqlite?

I have a basic Yesod server that uses an Sqlite db, and I'm trying to add tests to it. I'm very new to Haskell, so I'm even struggling to find the right terminology, so bare with me. I have this code to run the server: runShortblitoWebServer ::…
The Oddler
  • 6,314
  • 7
  • 51
  • 94