How Can I Create A Location In An Android Unit-test?
I want to create a Location in an android Unit-Test using JUnit 4. with Location loc = new Location(...) loc is null. How can I create a location? As I understood I have to includ
Solution 1:
In your module build.gradle
:
apply plugin: 'com.android.application'
android {
...
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation "org.robolectric:robolectric:4.2.1"
...
}
Your test class has to contain the following:
@RunWith(RobolectricTestRunner.class)publicclassLocationTest {
...
}
And that should be it.
Post a Comment for "How Can I Create A Location In An Android Unit-test?"