Closed
Description
I am not sure how a flaky test is determined. It seems like a failed test is run again, and the stack tracebacks are compared. I have a very simple example without any non-determinism which is marked flaky, and the tracebacks look the same.
// property based testing used rapid
func TestAbs6(t *testing.T) {
rapid.Check(t, func(t *rapid.T) {
value := rapid.Int().Draw(t, "value").(int)
result := Abs(value)
if (value * value) != (result * result) {
t.Errorf("square of result not equal to square of input: %d, result %d\n", value, result)
}
})
}
// function to be tested
func Abs(x int) int {
if x < 0 {
return -x
}
if x > 15 {
return x - 1
}
return x - 1
}
abs_test.go:89: [rapid] flaky test, can not reproduce a failure
To try to reproduce, specify -run="TestAbs6" -rapid.seed=1579796179831259001
Traceback (square of result not equal to square of input: 25541, result 25540
):
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:188 in github.com/flyingmutant/rapid.checkOnce
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:142 in github.com/flyingmutant/rapid.doCheck
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:100 in github.com/flyingmutant/rapid.checkTB
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:71 in github.com/flyingmutant/rapid.Check
/Users/allangold/go/src/pbt1/abs_test.go:89 in pbt1.TestAbs6
/usr/local/go/src/testing/testing.go:827 in testing.tRunner
/usr/local/go/src/runtime/asm_amd64.s:1333 in runtime.goexit
Original traceback (square of result not equal to square of input: 25541, result 25540
):
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:188 in github.com/flyingmutant/rapid.checkOnce
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:163 in github.com/flyingmutant/rapid.findBug
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:134 in github.com/flyingmutant/rapid.doCheck
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:100 in github.com/flyingmutant/rapid.checkTB
/Users/allangold/go/src/github.com/flyingmutant/rapid/engine.go:71 in github.com/flyingmutant/rapid.Check
/Users/allangold/go/src/pbt1/abs_test.go:89 in pbt1.TestAbs6
/usr/local/go/src/testing/testing.go:827 in testing.tRunner
/usr/local/go/src/runtime/asm_amd64.s:1333 in runtime.goexit
Failed test output:
abs_test.go:90: [rapid] draw value: 25541
abs_test.go:93: square of result not equal to square of input: 25541, result 25540