-
Notifications
You must be signed in to change notification settings - Fork 57
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
Introduce "expect (...) ON x" to be used instead of "expect (...) TO x" on mock objects #220
Conversation
…x" on mock objects
if (c.settings.contains("mockito-print-expect")) { | ||
val pos = s"${c.enclosingPosition.source.file.name}:${c.enclosingPosition.line}" | ||
println(pos + " " + show(r.tree)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this, we should extract a function and use it everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a separate PR: #221
The two PRs will conflict with each other once merged, I'll resolve whichever comes last
q"""if (!_root_.org.mockito.MockitoSugar.mockingDetails($obj).isMock) | ||
throw new _root_.org.mockito.exceptions.misusing.MissingMethodInvocationException(Seq( | ||
"'expect no calls to <?>' requires an argument which is 'a method call on a mock',", | ||
" but [" + $calledPattern + "] is a mock object.", | ||
"", | ||
"The following would be correct (note the usage of 'calls to' vs 'calls on'):", | ||
" expect no calls to " + $calledPattern + ".bar(*)", | ||
" expect no calls on " + $calledPattern, | ||
"" | ||
).mkString("\n")) | ||
else ${transformInvocation(c)(q"$obj.$methodOrField", order, q"${c.prefix}.mode")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, the postfix verification currently uses the standard mockito exception, but I like this one with more info, should be extracted
exception.getMessage shouldBe | ||
"""'expect no calls to <?>' requires an argument which is 'a method call on a mock', | ||
| but [fixture.org] is a mock object. | ||
| | ||
|The following would be correct (note the usage of 'calls to' vs 'calls on'): | ||
| expect no calls to fixture.org.bar(*) | ||
| expect no calls on fixture.org | ||
|""".stripMargin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
Resolves #212 for Expect DSL