0
votes

import static android.support.test.espresso.Espresso.onView; import static android.support.test.espresso.assertion.ViewAssertions.matches; import static android.support.test.espresso.matcher.ViewMatchers.withId; import static android.support.test.espresso.matcher.ViewMatchers.withText;

import android.support.test.espresso.action.ViewActions;

@org.junit.runner.RunWith(android.support.test.runner.AndroidJUnit4.class) @android.test.suitebuilder.annotation.LargeTest

Build.gradle

dependencies {

testCompile 'junit:junit:4.12'

androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:22.1.0'
}

}

Q : I am trying to add imports in to a testing class . i have added all the required dependencies in build.gradle of project module .

it is an old project built into eclipse and now migrated to android studio project.

there is no androidTest folder in android studio project , so i manually crated src/androidTest/java/example/Test.java

Added Junit4 dependency too but still imports are not working .

Followed -: https://code.google.com/p/android-test-kit/wiki/EspressoSetupInstructions

any help would be appriciated .

2

2 Answers

1
votes

Specify your variant explicitly if it is not debug

http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Basics-and-Configuration

Currently only one Build Type is tested. By default it is the debug Build Type, but this can be reconfigured with:

    android {
         ...
          testBuildType "staging" }
0
votes

Since you are doing androidTestCompile the libraries will be compiled for builds which are testable.

Try changing your build variant to a debug one and sync your project with gradle files.