freepascal / android-mock

Automatically exported from code.google.com/p/android-mock
0 stars 0 forks source link

Android Mock fails to find constructor after restructuring mocked class #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create a class to be mocked, with a constructor that takes a single parameter
2. Run the test, using the mocked class
3. Delete the constructor
4. Modify the test, to remove arguments passed to the constructor
5. Re-run the test; it fails and is unable to find the constructor. It appears 
as though the structure of the original class has been cached.

What is the expected output? What do you see instead?

The mock should be created, and the test should pass. Instead, we get this 
error output:

java.lang.IllegalArgumentException: Could not find the specified Constructor: 
genmocks.uk.org.alexmitchell.wikid.android.AlexConstructorClassDelegateSubclass(
[])
at 
com.google.android.testing.mocking.AndroidMock.getConstructorFor(AndroidMock.jav
a:2775)
at 
com.google.android.testing.mocking.AndroidMock.getSubclassFor(AndroidMock.java:2
647)
at 
com.google.android.testing.mocking.AndroidMock.createMock(AndroidMock.java:188)
at 
com.google.android.testing.mocking.AndroidMock.createMock(AndroidMock.java:157)
at 
uk.org.alexmitchell.wikid.android.test.SynchroniserTest.testUploadLocalFiles(Syn
chroniserTest.java:42)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
0)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

What version of the product are you using? On what operating system?

Using version 1.1.1 on Ubuntu 11.04, in Eclipse 3.7

Original issue reported on code.google.com by shepk1...@gmail.com on 12 Aug 2011 at 7:39

GoogleCodeExporter commented 9 years ago
I have found this to be the case with ALL changes I make to a mocked class, not 
just constructor args. As you say there does seem to be some sort of caching of 
the generated mock interfaces and delegate subclasses going on.

Simply cleaning the project in Eclipse does not seem to solve the problem. The 
only reliable workaround I have found is to close Eclipse, delete the bin 
folder from the project, restart Eclipse then rebuild/clean the project to 
regenerate the mocks. This is pretty time-consuming and annoying but it works.

It would be nice to have this fixed.

Original comment by t...@leach.it on 8 Nov 2011 at 11:51