Ruby & # 8594; Haskell block and automated acceptance testing

I am a background programmer in many languages, but have recently focused on Ruby / Rails and are interested in learning some of Haskell. I also played a little in Closure (although pretty simple stuff).

My current preferred approach to developing a new Ruby application is to start with high-level tests in the business value language using something like Gherkin / Cucumber, and then develop smaller components using something like RSpec or Minitest. What is (currently) the most common such toolkit and strategy for developing a new Haskell application?

Defendants: be patient, expect an answer from me and get an answer. I will need to do some work in Haskell to make any estimates. Thanks.

+4
source share
3 answers

Typically, a source of truth in a Haskell application is a type system. You use quickcheck and hspec to increase the confidence that your code is doing what you think, but it is just help.

+7
source

For history-based automated acceptance testing in Haskell, you have two main options:

  • chuchu (incomplete implementation of cucumber / cucumber in Haskell itself, Hackage page )
  • Ruby Test Cucumber Using Ruby Test

Of course, HSpec fills the role of acceptance testing based on the specification.

You get better results by using property-based testing instead of TDD with libraries like QuickCheck and Smallcheck .

+2
source

As I know, there is no cucumber analogue for Haskell. Closest to what you are looking for is probably HSpec, which is RSpec-ish.

Here is an example, verbatim from the HSpec website :

import Test.Hspec import Test.QuickCheck import Control.Exception (evaluate) main :: IO () main = hspec $ do describe "Prelude.head" $ do it "returns the first element of a list" $ do head [23 ..] `shouldBe` (23 :: Int) it "returns the first element of an *arbitrary* list" $ property $ \x xs -> head (x:xs) == (x :: Int) it "throws an exception if used with an empty list" $ do evaluate (head []) `shouldThrow` anyException 

What produces

 Prelude.head - returns the first element of a list - returns the first element of an *arbitrary* list - throws an exception if used with an empty list 
+1
source

Source: https://habr.com/ru/post/1497652/