Skip to content Skip to sidebar Skip to footer

Android Tests Exception In Constructor Noclassdeffounderror

After solving my issues with project structure and android tests it appears that another issue is coming, when I try to run my tests i get this exception: junit.framework.Assertion

Solution 1:

Following this post junit.framework.AssertionFailedError: Exception in constructor: (java.lang.NoClassDefFoundError) I tried adding the contrib lib with excludes like this:

dependencies {
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
    androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.0') {
        exclude group: 'com.android.support', module: 'appcompat'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude module: 'recyclerview-v7'
    }
}

and also, moved all test classes to *.app.test package, set

testApplicationId "es.unizar.vv.mobile.catmdedit.app.test"

and now it properly works!

Post a Comment for "Android Tests Exception In Constructor Noclassdeffounderror"