lundi 29 juin 2015

Configure test folder for unit testing in Android studio

I have added a folder for unit testing in my android studio project. The default folder is andoidTest but I have added a new folder and name in test instead. (like robolectric sample tests)

When I add test Dependency in my build.gradle under module such as

testCompile("junit:junit:${junitVersion}")
testCompile ("org.robolectric:robolectric:${robolectricVersion}")

They do not get added to external libraries under project, but when I use the default configuration and use androidTestCompile, it can added external libraries.

Then I thought that maybe I should setRoot for tests in gradle, so I used following in android tag in build.gradle:

sourceSets {
        androidTest.setRoot('src/test')
}

But still problem remained. I can run tests using gradlew, but imports in classes in test folder do not apply as well as no external library for test purpose is visible.

Anyone have any solution for this issue?

Aucun commentaire:

Enregistrer un commentaire