Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have JMock working inside Android opensource test projects. </p> <p>Yes: JMock code executes on the device in your hand ;-)</p> <p>I've used:</p> <ul> <li>jmock-2.5.1.jar</li> <li><strong>Repackaged</strong> hamcrest-all-1.1.jar (I'll explain)</li> <li>jmock-junit3-2.5.1.jar</li> </ul> <p>See the following for a Android JMock Test case <a href="http://github.com/olibye/ToneDial/blob/master/ToneDialTest/src/net/xpdeveloper/dialer/test/TestDialServiceTest.java" rel="noreferrer">http://github.com/olibye/ToneDial/blob/master/ToneDialTest/src/net/xpdeveloper/dialer/test/TestDialServiceTest.java</a></p> <p>Here are the three issues I had to overcome:</p> <hr> <h2>Hamcrest Packaging</h2> <p>The multiple packaging of Hamcrest fails Android package validation.</p> <p>The error you get in Android ADK is:- Error generating final archive: duplicate entry: LICENSE.txt</p> <p><strong>Solution</strong></p> <p>unzip hamcrest-core-1.1.jar unzip hamcrest-library-1.1.jar in the same directory.</p> <p>This the second unzip overwrites MANIFEST.MF and LICENCE.TXT.</p> <p>zip ../hamcrest-all-1.1.jar</p> <p>Initially I raised this with Steve and Nat for JMock</p> <ul> <li><a href="http://jira.codehaus.org/browse/JMOCK-242" rel="noreferrer">http://jira.codehaus.org/browse/JMOCK-242</a></li> </ul> <p>However it's really Joe's packaging issue in Hamcrest (so I just posted it there ;-)</p> <ul> <li><a href="http://code.google.com/p/hamcrest/issues/detail?id=125" rel="noreferrer">http://code.google.com/p/hamcrest/issues/detail?id=125</a></li> </ul> <hr> <h2>JUnit Packaging</h2> <p>The JUnit plugin in eclipse contains a subset of Hamcrest.</p> <p><strong>Solution</strong> You need to move the JUnit library down your classpath after JMock, in the eclipse project properties.</p> <hr> <h2>Android Packaging</h2> <p>JUnit v3 is part of android.jar so you can't use JUnit 4 style JMock tests. No annotations for us yet ;-)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload