I’m a big fan of a roughly tabular test format that uses elm-test as building 
blocks. For example:


   describe "minutes"
     [ rejects "a+"             "the usual non-numeric values are rejected"
     , rejects "5.3"            "rejects floats"

     , when "59" (Just 59)      "upper boundary"
     , rejects "60"             "too big"

     , when "0" (Just 0)        "0 is allowed"
     , rejects "-1"             "negative numbers are disallowed"

     , when " 35 " (Just 35)    "spaces are allowed"
     ]      

… or:

      [ describe "discovering the Sign"
          [ check   "1" <| Just (Positive, [1], Nothing)
          , check  "12" <| Just (Positive, [1], Just 2)
          , check "-23" <| Just (Negative, [2], Just 3)
          , check "+34" <| Just (Positive, [3], Just 4)

          , check ""  Nothing
          , check "-" Nothing
          , check "+" Nothing
          ]

I've found such a style really useful. It's easier to grasp what a set of tests 
is all about, or to compare similar tests to see what cases might be missing. I 
have a motto: "every word in the test should be about the purpose of that test."

Would love to talk about such tests at ElmConf. Here’s a start at a 
test-builder library that supports them: 
https://github.com/marick/static-fp/blob/master/elm/tests/TestBuilders.elm The 
comments talk more about the “why” of a tabular format.

P.S. I’m writing a book called /An Outsider’s Guide to Statically Typed 
Functional Programming/ https://leanpub.com/outsidefp — conference special: 
talk to me at ElmConf and I’ll give you a copy. I look like my twitter profile 
picture: https://twitter.com/marick

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to