We need to account for the extra function in the call stack when registering a custom fail handler, otherwise the line numbers that are reported on failures are incorrect, e.g.:
The solution is this:
RegisterFailHandler(func(message string, callerSkip ...int) {
// Your custom logic here...
// Account for this extra function in the call stack.
// Without this all failure messages will show the incorrect line number!
var shiftedCallerSkip []int
for _, i := range callerSkip {
shiftedCallerSkip = append(shiftedCallerSkip, i+1)
}
Fail(message, shiftedCallerSkip...)
})
We need to account for the extra function in the call stack when registering a custom fail handler, otherwise the line numbers that are reported on failures are incorrect, e.g.:![image](https://user-images.githubusercontent.com/16148461/113303658-4f39b680-92cf-11eb-9e47-c6a3af3054f8.png)
The solution is this: