Mockito + Dexmaker on Android

前端 未结 7 575
余生分开走
余生分开走 2020-12-05 09:42

I am trying to use Mockito in my Android project. I have found very nice tutorial that deals with it: http://www.paulbutcher.com/2012/05/mockito-on-android-step-by-step/

7条回答
  •  臣服心动
    2020-12-05 10:07

    It looks like the dexmaker project has moved from Google Code to GitHub.

    In the maven central repository there are versions 1.1 and 1.2 published in March 2014 and December 2014.

    I've verified this "dexcache == null" issue still exists through version 1.2 - but only on certain devices. For example, a Galaxy S5 with Android 5.0 has the problem, and a Galaxy S4 with Android 4.4.2 does not.

    I cloned the GitHub repository (last commit March 12th 2015 - ca74669), and ran locally, and the problem has been fixed (there are also commits in the history that back this up). So once there is a 1.3 release, hopefully this problem is gone for good!

    Anyone else wanting to run a local copy of 1.3-SNAPSHOT, here's how I did that (on a Mac, but other platforms should work too, you'll need mvn, adb, and dx on PATH):

    1. git clonehttps://github.com/crittercism/dexmaker.git
    2. cd dexmaker
    3. mvn install -Dmaven.test.skip=true
    4. cp -R ~/.m2/repository/com/google/dexmaker $ANDROID_HOME/extras/android/m2repository/com/google
    5. Then change version in app/build.gradle: androidTestCompile 'com.google.dexmaker:dexmaker:1.3-SNAPSHOT'
      • Or pom.xml if using maven to build, or overwrite your libs/dexmaker.jar with ~/.m2/repository/com/google/dexmaker/dexmaker/1.3-SNAPSHOT/dexmaker-1.3-SNAPSHOT.jar if you are using eclipse/ant

    Also, FYI, the original issue report for the same issue on Google Code as well.

提交回复
热议问题