mardi 25 août 2015

In Android, why do I need to use androidTestCompile for the "test" sourceSet?

So I have a library module that wraps an API, and I want to write some tests. I want to import things like JUnit and MockWebServer, but only for the test sourceSet, and not for the androidTest one, as I want to use the former because the latter would cause the tests to be run in an android device or AVD, which I do not want. Therefore, I have this in my gradle file:

sourceSets {
    main {
        test {
            setRoot('src/test')
        }
    }
}

...

dependencies {
    ...
    testCompile 'junit:junit:4.12'
    testCompile 'com.squareup.okhttp:mockwebserver:2.4.0'
}

However, this will not work, and instead I will have to import the dependencies as androidTestCompile ones. Why is this?

Aucun commentaire:

Enregistrer un commentaire