rod: Easier way to avoid panic with Must helpers.
Currently all the Must helpers call to utils.E, which panics the test. One option would be to avoid Must methods altogether, however, they are rather convenient.
This is a problem, because with concurrent tests it will stop all the tests rather than just the test that failed.
I propose adding a browser.OnFail which accepts interface { Fatal(args ...interface{}) } and returns a rod.Browser. Instead of calling utils.E the browser would then call the on fail func.
The actual method name can be something entirely different.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- add OnMust for intercepting Must failures This allows tests to use Must calls, and the failure would be invoked by t.Fatal. As an example: func Test(t *testing.T) { b := rod.New().MustConnect().On... — committed to egonelbre/rod by egonelbre 3 years ago
- add Testing for intercepting Must failures Go testing package expects that failures are notified via t.Fatal, this ensures that all other tests keep running and that the error failure is captured int... — committed to egonelbre/rod by egonelbre 3 years ago
- add Testing for intercepting Must failures Go testing package expects that failures are notified via t.Fatal, this ensures that all other tests keep running and that the error failure is captured int... — committed to egonelbre/rod by egonelbre 3 years ago
- add Testing for intercepting Must failures Go testing package expects that failures are notified via t.Fatal, this ensures that all other tests keep running and that the error failure is captured int... — committed to egonelbre/rod by egonelbre 3 years ago
It’s too late tonight. I’ll explain why yours has the same fundermental design issue as #166 tomorrow. You can polish your PR before that.
I think if you can solve the problem, I will be super happy to accept your PR.