Comments (5)
Thanks for detailed report, I'll take a look at it.
Original comment by [email protected]
on 13 Mar 2008 at 10:33
from mockito.
Original comment by [email protected]
on 16 Mar 2008 at 2:50
from mockito.
Again, thank you very much for very detailed report and for suggesting the fix.
InvocationMatcher.isSimilarTo() method have no effect on verification. This
method is
only used to decide what kind of verification message to print. E.g. at the
point
when isSimilarTo() is called the verification has already failed.
I created a test case according to your description and everything works fine
(can
you paste it to your IDE and tell me if this is it?):
{{{
interface View {
void addProperty(String property);
void addProperty(DomainObject property);
}
class DomainObject {}
class CustomDomainMatcher extends ArgumentMatcher<DomainObject> {
@Override public boolean matches(Object argument) {
return true;
}
}
@Test
public void testBug() throws Exception {
View view = mock(View.class);
view.addProperty(new DomainObject());
view.addProperty("test");
verify(view, atLeastOnce()).addProperty(argThat(new CustomDomainMatcher()));
verify(view, times(1)).addProperty(argThat(new CustomDomainMatcher()));
verify(view, atLeastOnce()).addProperty("test");
verify(view, times(1)).addProperty("test");
}
}}}
Misbehaviour in your code may be related to following:
Look at this line:
verify(view, atLeastOnce()).addProperty( argThat(new CustomDomainMatcher()) );
Given that addProperty() method is overloaded in your code, it is very
important what
kind of generic type your customDomainMatcher is defined with:
class CustomDomainMatcher extends ArgumentMatcher<DomainObject> {
or
class CustomDomainMatcher extends ArgumentMatcher<String> {
Compiler uses this generic type to determine which overloaded version of the
method
to use.
If your matcher is not generic, you have to cast the argument to make compiler
happy:
verify(view, atLeastOnce()).addProperty((DomainObject) argThat(new
customDomainMatcher()) );
Closing the bug - please reopen if it still doesn't work for you.
Original comment by [email protected]
on 16 Mar 2008 at 3:09
- Changed state: Invalid
from mockito.
It will be a few days, but I will give that a try in my environment.
K
Original comment by [email protected]
on 24 Mar 2008 at 9:02
from mockito.
Original comment by [email protected]
on 19 Apr 2009 at 7:40
- Added labels: Milestone-Pre1.7
from mockito.
Related Issues (20)
- NPE on verification when multiple threads used HOT 4
- New spying feature HOT 9
- allow stubbing with callbacks HOT 4
- Want to extend Mockito class to include my own matchers HOT 3
- Arguments are saved by a reference HOT 4
- PATCH : Performance Enhancement for MockHandler : Search matchers once instead of twice HOT 7
- ArrayEquals throws exception HOT 4
- @Mock annotation does not work very well with Eclipse and IDEA HOT 3
- when arguments are different the exception now allows using the comparison window HOT 2
- add junit runners that automaticaly initialize mocks annotated with @Mock HOT 2
- interaction gets remembered between tests HOT 13
- Can't stub spied object HOT 5
- Javadocs don't tell all the truth about Mockito spies HOT 3
- InOrder.verify() displays the actual invocation on error when arguments are different HOT 19
- verify throws an IllegalArgumentException for overloaded method where array argument is incorrect HOT 4
- make spy working with Anonymous classes HOT 36
- Checking the method calls ordering in multi-thread environment. HOT 7
- Varargs stubbing produces incorrect behavior HOT 3
- Verify without method call causes errors in other tests. HOT 8
- Upload mockito to the Central Repository
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mockito.