My JMock runs inside open source Android projects.
Yes: JMock code runs on the device in your hand; -)
I used:
- JMock-2.5.1.jar
- Repackaged hamcrest-all-1.1.jar (I will explain)
- JMock-junit3-2.5.1.jar
See the following for the Android JMock Test http://github.com/olibye/ToneDial/blob/master/ToneDialTest/src/net/xpdeveloper/dialer/test/TestDialServiceTest.java
Here are three issues that I had to overcome:
Hamcrest Packaging
Hamcrest multiple packaging does not allow you to check the Android package.
Error in Android ADK: - Error creating final archive: duplicate entry: LICENSE.txt
Decision
unzip hamcrest-core-1.1.jar unzip hamcrest-library-1.1.jar in the same directory.
This second unboxing overwrites MANIFEST.MF and LICENCE.TXT.
zip ../ hamcrest-all-1.1.jar
First I brought it up with Steve and Nat for JMock
However, this is really a Joe packaging problem in Hamcrest (so I just posted it there;)
JUnit Packaging
The JUnit plugin in eclipse contains a subset of Hamcrest.
Solution You need to move the JUnit library down the class path after JMock in the properties of the eclipse project.
Android Packaging
JUnit v3 is part of android.jar, so you cannot use JUnit 4-style JMock tests. Annotations for us are not yet available; -)
byeo
source share