Android Studio gradle experimental test (JUNit) -


i'm trying test class instrumentationtestcase. i've been checking examples guess i'm missing because "test artifact" dropdown disabled , cannot changed junit.

i declared libraries in gradle

// test compile testcompile 'junit:junit:4.12' testcompile 'org.robolectric:robolectric:2.4' testcompile 'org.mockito:mockito-core:1.9.5' testcompile 'org.reflections:reflections:0.9.9' 

declared app id,

defaultconfig {     testapplicationid "myproject.android.test"   } 

and getting latest gradle version

dependencies {         classpath 'com.android.tools.build:gradle:+'     } 

also created build configuration test package. when run test gives me

exception in thread "main" java.lang.noclassdeffounderror: junit/textui/resultprinter 

probably because test artifact "android instrumentation tests" , build configuration junit configuration. test artifact dropdown disabled cannot change junit. there i'm missing?

edit: package tree this,

myproject  - app    - main     - java       -myproject        -android         -mypackage          -myclass.java    -test     -java      -myproject       -android        -mypackage         -test          -myclasstest.java 

and in android studio preferences, under gradle->experimental, "enable unit testing support" checked.

you need few steps activate jvm unit tests in android studio. follow steps: https://sites.google.com/a/android.com/tools/tech-docs/unit-testing-support


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -