oghenez / mycila

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

Injected EasyMock mocks have long inappropriate names #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Mocks injected using the @Mock annotation of the EasyMock plugin have an 
automatically generated mock name that is very long and difficult to read.

Steps to reproduce:
1. Create an interface, say my.package.MyClass
2. Create a test case with a field MyClass called myField and decorate it with 
a @Mock annotation
3. Make EasyMock.verify(...) fail with the MyClass mock to get an error message

Sample expected output:
  Unexpected method call my_package_MyClass_myField.someMethod(): ...

Sample actual output:
  Unexpected method call ___________________myField.someMethod(): ...

Cause:
Mock name generation found in EasyMock2TestPlugin@line47 
(mycyla-testing-easymock-2.6.jar) appears to incorrectly use the 
String#replaceAll(String,String) API on the mock's class name.

Actual usage: 
 field.getDeclaringClass().getName().replaceAll(".", "_")

(presumably) Intented usage:
 field.getDeclaringClass().getName().replaceAll("\\.", "_")
  or
 field.getDeclaringClass().getName().replace('.', '_')

Direct link: 
http://www.google.com/codesearch/p?hl=en#jkOSd3dEr64/mycila-testing/tags/mycila-
testing-2.2/mycila-testing-plugins/mycila-testing-easymock/src/main/java/com/myc
ila/testing/plugin/easymock/EasyMock2TestPlugin.java&q=replaceAll%20package:http
://mycila\.googlecode\.com&l=47

Original issue reported on code.google.com by rodion.m...@gmail.com on 10 Dec 2010 at 3:11

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 7 Aug 2011 at 7:41

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 7 Aug 2011 at 7:57