TheSeamau5 / elm-check

Property Based Testing in Elm
70 stars 20 forks source link

Add elm-test support #4

Closed TheSeamau5 closed 9 years ago

TheSeamau5 commented 9 years ago

This feature is coming around very nicely currently and will appear in the next version of elm-check.

This simple code:

test_list_length_positive =
  test "Length of a list is always greater than 1"
    (\ls -> List.length ls > 1)
    (always True)
    (list int)
    100 (Random.initialSeed 12309)

test_reverse_append =
  test2 "Append then reverse is equivalent to reversing then appending"
    (\xs ys -> List.reverse (xs ++ ys))
    (\xs ys -> List.reverse ys ++ List.reverse xs)
    (list int)
    (list int)
    100 (Random.initialSeed 1)

tests =
  Test.suite "List Tests"
    [ test_list_length_positive
    , test_reverse_append
    ]

main = runDisplay tests

is able to generate around 200 elm-test unit tests.

screen shot 2015-05-02 at 9 37 35 pm

Shrinking is also supported as you may see from the screenshot. In the case of a failing unit test, a shrunk test case will be provided and will appear as the first unit test in the suite.

TheSeamau5 commented 9 years ago

Note to self: Generating 100,000 unit tests is about as much as is feasible on my laptop.

screen shot 2015-05-02 at 10 09 21 pm