test

panicใฎใƒ†ใ‚นใƒˆ - golang

2020-05-28
golang, test

Goใงใƒ‘ใƒ‹ใƒƒใ‚ฏใŒ็™บ็”Ÿใ™ใ‚‹ใ‹ใฉใ†ใ‹ใฎใƒ†ใ‚นใƒˆใงใ™ใ€‚ // Testing if testFunc calls panic. // e.g. // IsTestCallPanic(func(){ // <place test target here.> // }) func IsTestCallPanic(testFunc func()) (ok bool) { defer func() { if err := recover(); err == nil { ok = false } }() ok = true testFunc() return } // Test for test. func TestIsTestCallPanic(t *testing.T) { isCalled := IsTestCallPanic(func() { ...