Using JMock on the Android
-
How can I use JMock on the Android? I've several posts saying its not possible, but surely there's some way to do it? The issue seems to be getting the Android to even recognize the JMock jar file. So maybe there's a solution with putting the jar into assets and making a custom class loader? That seems like a lot of trouble, but does it sound like it would work?
-
Answer:
I have JMock working inside Android opensource test projects. Yes: JMock code executes on the device in your hand ;-) I've used: jmock-2.5.1.jar Repackaged hamcrest-all-1.1.jar (I'll explain) jmock-junit3-2.5.1.jar See the following for a Android JMock Test case http://github.com/olibye/ToneDial/blob/master/ToneDialTest/src/net/xpdeveloper/dialer/test/TestDialServiceTest.java Here are the three issues I had to overcome: Hamcrest Packaging The multiple packaging of Hamcrest fails Android package validation. The error you get in Android ADK is:- Error generating final archive: duplicate entry: LICENSE.txt Solution unzip hamcrest-core-1.1.jar unzip hamcrest-library-1.1.jar in the same directory. This the second unzip overwrites MANIFEST.MF and LICENCE.TXT. zip ../hamcrest-all-1.1.jar Initially I raised this with Steve and Nat for JMock http://jira.codehaus.org/browse/JMOCK-242 However it's really Joe's packaging issue in Hamcrest (so I just posted it there ;-) http://code.google.com/p/hamcrest/issues/detail?id=125 JUnit Packaging The JUnit plugin in eclipse contains a subset of Hamcrest. Solution You need to move the JUnit library down your classpath after JMock, in the eclipse project properties. Android Packaging JUnit v3 is part of android.jar so you can't use JUnit 4 style JMock tests. No annotations for us yet ;-)
Ron Romero at Stack Overflow Visit the source
Related Q & A:
- How to play video Using Url On Android?Best solution by Stack Overflow
- How to use Google+ using OAuth in Android?Best solution by Stack Overflow
- Is using `int` more preferable than using `unsigned int`?Best solution by Stack Overflow
- Is it possible to post something on a facebook group using android?Best solution by Stack Overflow
- Why can I download attachments using Yahoo Classic Mail, but not using newer Yahoo Mail?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.