Skip to content

Language Elm

kazk edited this page Nov 11, 2018 · 6 revisions

Versions

0.19

Test Frameworks

elm test

Example

The name of the solution module can be anything. Extra module can be provided in preloaded section.

module Example exposing (..)

add : Int -> Int -> Int
add x y = x + y
module ExampleTest exposing (..)

import Expect exposing (Expectation)
import Test exposing (..)

import Example

suite : Test
suite =
    describe "Example"
        [ test "add" <|
            \_ ->
                Example.add 1 1
                    |> Expect.equal 2
        ]

Fuzz can be used for property based testing:

module ExampleTest exposing (..)

import Expect exposing (Expectation)
import Test exposing (..)
import Fuzz

import Example

suite : Test
suite =
    describe "Example"
        [ fuzz2 Fuzz.int Fuzz.int "add" <|
            \a b ->
                Example.add a b
                    |> Expect.equal (a + b)
        ]

Timeout

12 seconds

Packages

  • elm/core
  • elm-explorations/test

Services

None

Clone this wiki locally