dimanche 29 novembre 2015

Should property tests run with unit tests when using the RGR methodology?

Should property tests run with unit tests when using the RGR methodology?

RGR: Red -> Green -> Refactor

I noticed that a unit test that I have executes in 18ms.

However, my property test for the same method takes 215ms.

module Tests.Units

open FsUnit
open NUnit.Framework
open NUnit.Core.Extensibility

open FsCheck.NUnit
open FsCheck.NUnit.Addin
open FsCheck

let add x y = (x + y)

let commutativeProperty x y = 
    let result1 = add x y
    let result2 = add y x // reversed params
    result1 = result2

[<Test>]
let ``When I add two numbers, the result should not depend on parameter order``()=
    Check.Quick commutativeProperty

[<Test>]
let ``add two numbers`` () =
    add 2 3 |> should equal (5)

So my property test takes a quarter of a second to execute.

In addition, this is just one simple property test.

What is an effective method for running property tests?

Just check-ins?

Aucun commentaire:

Enregistrer un commentaire