Fix roboelectric unit tests

This commit is contained in:
Torsten Grote 2020-09-09 18:12:02 -03:00 committed by Chirayu Desai
parent 415b5729d5
commit 45ac8883a0
3 changed files with 10 additions and 6 deletions

View file

@ -9,7 +9,7 @@ android {
buildToolsVersion '30.0.2' // adapt in .travis.yaml if changed here
defaultConfig {
minSdkVersion 30
minSdkVersion 29 // leave at 29 for robolectric tests
targetSdkVersion 30
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments disableAnalytics: 'true'
@ -138,8 +138,8 @@ dependencies {
def junit_version = "5.5.2" // careful, upgrading this can change a Cipher's IV size in tests!?
def mockk_version = "1.10.0"
testImplementation aospDeps // anything less fails tests run with gradlew
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation('org.robolectric:robolectric:4.3.1') {
testImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation('org.robolectric:robolectric:4.3.1') { // 4.4 has issue with non-idle Looper
// https://github.com/robolectric/robolectric/issues/5245
exclude group: "com.google.auto.service", module: "auto-service"
}
@ -148,8 +148,8 @@ dependencies {
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$junit_version"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test:rules:1.3.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation "io.mockk:mockk-android:$mockk_version"
}

View file

@ -26,6 +26,7 @@ import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.context.stopKoin
import org.robolectric.annotation.Config
import java.io.ByteArrayOutputStream
import java.io.FileInputStream
import java.io.FileNotFoundException
@ -34,6 +35,7 @@ import java.io.IOException
import kotlin.random.Random
@RunWith(AndroidJUnit4::class)
@Config(sdk = [29]) // robolectric does not support 30, yet
class MetadataManagerTest {
private val context: Context = mockk()

View file

@ -12,8 +12,10 @@ import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.core.context.stopKoin
import org.robolectric.annotation.Config
@RunWith(AndroidJUnit4::class)
@Config(sdk = [29]) // robolectric does not support 30, yet
internal class DocumentFileTest {
private val context: Context = mockk()