easyforgood / mockito

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

can't mock mybatis interface which have @Param annotation #395

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Mock up mybatis Dao interface 
public List<MaintainResult> QueryMaintainStatus(@Param("type")int 
type,@Param("clusterName")String clusterName,@Param("name")String name);
2. The interface has more than two @Param annotation
3. mock like this  
when(maintainDao.QueryMaintainStatus(anyInt(),anyString(),anyString())).thenThro
w(new RuntimeException());

What is the expected output? What do you see instead?
I expected the method be mocked.  Result is the interface's method can't be 
mock.

What version of the product are you using? On what operating system?
version is 1.9.5 ,Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by kingp...@gmail.com on 16 Nov 2012 at 7:07

GoogleCodeExporter commented 8 years ago
I don't quite follow how your test is layed out. Mocking an interface shouldn't 
be an issue, mybatis or not.

On a side note however the annotations are not inherited, a the exception of 
the annotations on the superclass (and if they are annotated by @Inherited). 
Which means that you should not expect annotations on the implementation of an 
interface (which is exactly a mock of an interface).

Original comment by brice.du...@gmail.com on 19 Nov 2012 at 9:22

GoogleCodeExporter commented 8 years ago
Hey,

I'll invalidate the issue for now. Feel free to raise your hand if you think 
there is definitely something going wrong with mockito.

Original comment by brice.du...@gmail.com on 27 Nov 2012 at 4:54