-
Notifications
You must be signed in to change notification settings - Fork 59
Refactor value matchers and postFix dependent syntax #56
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
Conversation
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.
looks good
left some minor comments
@@ -240,7 +249,7 @@ val aMock = mock[Foo] | |||
|
|||
when(aMock.bar) thenReturn "mocked!" <=> aMock.bar shouldReturn "mocked!" | |||
when(aMock.bar) thenReturn "mocked!" thenReturn "mocked again!" <=> aMock.bar shouldReturn "mocked!" andThen "mocked again!" | |||
when(aMock.bar) thenCallRealMethod() <=> aMock.bar shouldCallRealMethod | |||
when(aMock.bar) thenCallRealMethod() <=> aMock.bar shouldCall realMethod |
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.
are there any other things you can type after shouldCall
?
If not, then I'm not sure it's worth splitting it, just my 2c
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.
It was also postfix notation and had a similar compiler error if it had a follow up line
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.
what about shouldReturn whateverRealMethdoReturns
(not really sure what to put as the shouldReturn
parameter, but it would make it more consistent if we can find something that reads nicely
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 think shouldReturn whateverRealMethdoReturns
looks too long, so shouldCall realMethod
is probably better
another way looking at it can be aMock.bar should not be mocked
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.
should not be
would clash with ScalaTest, so it's a no go
I wasn't being literal with whateverRealMethdoReturns
:P just looking for suggestions
verify(aMock, times(2)).bar <=> aMock.bar wasCalled twice | ||
verify(aMock, times(6)).bar <=> aMock.bar wasCalled sixTimes | ||
verifyNoMoreInteractions(aMock) <=> aMock was never called again | ||
verifyNoMoreInteractions(aMock) <=> aMock wasNever calledAgain |
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.
alternatively this can be
aMock wasCalled neverAgain
it looks more consistent with wasCalled twice
and so on
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.
good point
verify(aMock).bar <=> aMock.bar was called | ||
verify(aMock).bar(any) <=> aMock.bar(*) was called | ||
verify(aMock, only).bar <=> aMock.bar wasCalled onlyHere | ||
verify(aMock, never).bar <=> aMock.bar was never called | ||
verify(aMock, never).bar <=> aMock.bar wasNever called |
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.
alternatively aMock.bar wasCalled zeroTimes
or aMock.bar wasCalled never
it's more consistent with the rest of the api, though I admit wasNever Called
(or was neverCalled
) reads better
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.
yeah, I'll take a second look
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.
What about wasNot called
and wasNot calledAgain
I know still doesn't uses the wasCalled
but reads much better and it allows you to copy/paste and just add 'Not' (I've found myself doing that many times, so I think it's a popular use case`
also using Not instead of Never seems nicer, the reason I didn't do it before was that not
was a keyword
and it clashed with the same defined by ScalaTest, but if I use it as part of the method name then that's not an issue anymore
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.
naming things is hard, and there always will be who thinks it can have a better name, so i suggest juts pick something that compiles in all circumstances and be happy :)
i personally think that consistency is more important than following English, easy to remember => quick to use => more productive
but again, this is just me
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 see your point, but one of the main purposes of the DSL is to get rid of awkward reading sentences as well, and the current form is consistent with what it was there before (in both version 1.0.0 and 0.x.x) so I'm gonna keep it like this, history will judge me XD
Thanks a lot for your help!
Refactor eqToVal matcher (Fixes #55)
Replace all syntax that requires postFix notation (Fixex #54) (@jozic please take a look)