-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
If you set up a test with something like defer myval.AssertExpectations(t) and then later skip the test (t.Skip()), the AssertExpectations check can still fail your test. I propose that AssertExpectations should check whether the test has already been marked as "skipped" and, if so, return nil (success). Here's the change I'm envisioning:
type tSkipped interface {
Skipped() bool
}
// AssertExpectations asserts that everything specified with On and Return was
// in fact called as expected. Calls may have occurred in any order.
func (m *Mock) AssertExpectations(t TestingT) bool {
if s, ok := t.(tSkipped); ok { // <--- START OF PROPOSED NEW CODE
if s.Skipped() {
return true
}
} // <--- END OF PROPOSED NEW CODE
if h, ok := t.(tHelper); ok {
h.Helper()
}
m.mutex.Lock()
defer m.mutex.Unlock()
[...]
}If y'all are in agreement with this, I'm very happy to create a PR.
Reactions are currently unavailable