-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
同一个函数在目标被测函数中多次调用(会有不同结果)该如何mock? #21
Comments
连续调用目前没有限制,但是就和实际效果一致,单条约定中设置多个返回后续的不会生效,可以考虑以下方案: will(returnObjectList(10, 6, 666)) 方案二,用 will(invoke(mock_func)) 在 方案三,写成多条约定 EMOCK(xxx).expects(once()).will(returnValue(10));
EMOCK(xxx).expects(once()).will(returnValue(6));
EMOCK(xxx).expects(once()).will(returnVaule(666)); |
感谢大佬回复。我试试看 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如何在同一个用例中mock同一个函数多次,并且期望的行为每次都不同?
例如下面的示例:
mockcpp中有类似的语法:
.stubs().will(returnValue(10)).then(returnValue(6)).then(returnVaule(666));
emock也支持类似的语法,但是实测then没效果,每次返回的都是will中设定的10.
系统:Linux x86_64,编译器:g++
The text was updated successfully, but these errors were encountered: