Merge pull request #1331 from ianrose14/ianrose/assertexpectations-skipped

Ensure AssertExpectations does not fail in skipped tests
pull/1537/head
Bracken 2024-02-17 17:50:13 +00:00 committed by GitHub
commit c719de3088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -594,6 +594,9 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) 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.(interface{ Skipped() bool }); ok && s.Skipped() {
return true
}
if h, ok := t.(tHelper); ok {
h.Helper()
}

View File

@ -1493,6 +1493,16 @@ func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) {
}
func Test_Mock_AssertExpectations_Skipped_Test(t *testing.T) {
var mockedService = new(TestExampleImplementation)
mockedService.On("Test_Mock_AssertExpectations_Skipped_Test", 1, 2, 3).Return(5, 6, 7)
defer mockedService.AssertExpectations(t)
t.Skip("skipping test to ensure AssertExpectations does not fail")
}
func Test_Mock_TwoCallsWithDifferentArguments(t *testing.T) {
var mockedService = new(TestExampleImplementation)