jeudi 7 mai 2015

What's the preferred way to implement Data Driven Testing using Elixir/ExUnit?

I'd like to reuse the same code of a test case for several handcrafted combinations of input data and expected outcomes, but without copypasting the code for each set. Frameworks in other languages support it in different ways, for example in Groovy/Spock:

def "maximum of two numbers"(int a, int b, int c) {
        expect:
        Math.max(a, b) == c

        where:
        a | b | c
        1 | 3 | 3
        7 | 4 | 4
        0 | 0 | 0
}

What's the preferred way to do this in ExUnit? Maybe ExUnit is not the best framework to this?

Aucun commentaire:

Enregistrer un commentaire