ssacher-tgm / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

javadoc enhancement: any() == anyObject() #176

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If I add a static import on both org.hamcrest.Matchers.* and
org.mockito.Matchers.* together, I get naming conflicts because the
any(Class<T> clazz) method exists in both classes.

In a perfect world it would be nice if we could rename the method, but that
would be non-passive. So, is there any way we can get an alias for this
method, so at the very least we can still use the Mockito method?

Original issue reported on code.google.com by brianmat...@gmail.com on 9 Mar 2010 at 9:37

GoogleCodeExporter commented 8 years ago
Hey,

1. There is an alias: anyObject() == any(Clazz)
2. You can play around with static import, e.g. get rid of '*' wildcard, etc. 
Might help

Original comment by szcze...@gmail.com on 9 Mar 2010 at 9:42

GoogleCodeExporter commented 8 years ago
Ah, sorry about that. I looked through all the any methods... I must have 
missed that
one.

startsWith(String) and endsWith(String) also are in conflict. I haven't gone 
through
the whole list, so there may be more. It is also something to think about when 
you
add new methods to the Matchers class.

"get rid of '*' wildcard, etc"
Yeah, but it can be a real pain to have to import all of the methods 
individually
when you are using a lot of them.

Original comment by brianmat...@gmail.com on 9 Mar 2010 at 10:02

GoogleCodeExporter commented 8 years ago
So the complier complains only when you use those methods?

Forget about hamcrest. Use FEST-assert :)

Original comment by szcze...@gmail.com on 9 Mar 2010 at 10:05

GoogleCodeExporter commented 8 years ago
Yeah, I get a message similar to the following:
The method startsWith(String) is ambiguous for the type TestClass

"Forget about hamcrest. Use FEST-assert"
That looks awesome. I'm very sad I hadn't heard of it sooner. I will be looking 
into
it. Thanks!

However, I think I am stuck with hamcrest when using mockito.

Original comment by brianmat...@gmail.com on 9 Mar 2010 at 10:18

GoogleCodeExporter commented 8 years ago
I think the other Mockito matchers but any() are hardly used by anyone so let's 
not
worry about them.

Let me know if you hit the problem with some other matcher that clashes - we 
will
decide what to do.

In meantime I will update the javadocs to make sure it is clear that any() == 
anyObject()

Thanks!

Original comment by szcze...@gmail.com on 9 Mar 2010 at 11:21

GoogleCodeExporter commented 8 years ago
Sounds good to me.

Original comment by brianmat...@gmail.com on 10 Mar 2010 at 1:16

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 15 Mar 2010 at 8:19

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 17 Mar 2010 at 8:28

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 17 Mar 2010 at 8:32

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 2 Dec 2012 at 10:21