mirror of
https://github.com/stretchr/testify.git
synced 2025-05-31 11:42:44 +00:00
Document chances of false reults on mock asserts
This commit is contained in:
parent
096a13e3a4
commit
3058ec34fb
@ -398,6 +398,7 @@ func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AssertCalled asserts that the method was called.
|
// AssertCalled asserts that the method was called.
|
||||||
|
// It can produce a false result when an arugment is a pointer type and the underyling value changed after calling the mocked method.
|
||||||
func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool {
|
func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool {
|
||||||
if !assert.True(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method should have been called with %d argument(s), but was not.", methodName, len(arguments))) {
|
if !assert.True(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method should have been called with %d argument(s), but was not.", methodName, len(arguments))) {
|
||||||
t.Logf("%v", m.expectedCalls())
|
t.Logf("%v", m.expectedCalls())
|
||||||
@ -407,6 +408,7 @@ func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AssertNotCalled asserts that the method was not called.
|
// AssertNotCalled asserts that the method was not called.
|
||||||
|
// It can produce a false result when an arugment is a pointer type and the underyling value changed after calling the mocked method.
|
||||||
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool {
|
func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool {
|
||||||
if !assert.False(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method was called with %d argument(s), but should NOT have been.", methodName, len(arguments))) {
|
if !assert.False(t, m.methodWasCalled(methodName, arguments), fmt.Sprintf("The \"%s\" method was called with %d argument(s), but should NOT have been.", methodName, len(arguments))) {
|
||||||
t.Logf("%v", m.expectedCalls())
|
t.Logf("%v", m.expectedCalls())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user