|
| 1 | +buildscript { |
| 2 | + repositories { |
| 3 | + google() |
| 4 | + mavenCentral() |
| 5 | + } |
| 6 | + |
| 7 | + dependencies { |
| 8 | + classpath 'com.android.tools.build:gradle:4.2.1' |
| 9 | + classpath("de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1") |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +apply plugin: 'com.android.library' |
| 14 | +apply plugin: "de.mannodermaus.android-junit5" |
| 15 | + |
| 16 | +android { |
| 17 | + compileSdkVersion 30 |
| 18 | + defaultConfig { |
| 19 | + minSdkVersion 28 |
| 20 | + targetSdkVersion 30 |
| 21 | + |
| 22 | + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' |
| 23 | + // JUnit 5 support for instrumentation tests |
| 24 | + testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder" |
| 25 | + } |
| 26 | + |
| 27 | + // make the android-test subproject just reuse the math stuff |
| 28 | + sourceSets { |
| 29 | + main { |
| 30 | + java.srcDirs = ["../src/main/java"] |
| 31 | + } |
| 32 | + |
| 33 | + // unit tests. Run via test task |
| 34 | + test { |
| 35 | + java.srcDirs = ["../src/test/java"] |
| 36 | + } |
| 37 | + |
| 38 | + androidTest { |
| 39 | + java.srcDirs = ["../src/test/java"] |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + compileOptions { |
| 44 | + setSourceCompatibility(JavaVersion.VERSION_1_8) |
| 45 | + setTargetCompatibility(JavaVersion.VERSION_1_8) |
| 46 | + } |
| 47 | + |
| 48 | + testOptions { |
| 49 | + unitTests { |
| 50 | + all { |
| 51 | + useJUnitPlatform() |
| 52 | + maxParallelForks 4 |
| 53 | + //we want display the following test events |
| 54 | + testLogging { |
| 55 | + events "PASSED", "STARTED", "FAILED", "SKIPPED" |
| 56 | + } |
| 57 | + afterSuite { desc, result -> |
| 58 | + if (!desc.parent) { // will match the outermost suite |
| 59 | + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)" |
| 60 | + def startItem = '| ', endItem = ' |' |
| 61 | + def repeatLength = startItem.length() + output.length() + endItem.length() |
| 62 | + println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +repositories { |
| 71 | + mavenCentral() |
| 72 | + google() |
| 73 | +} |
| 74 | + |
| 75 | +dependencies { |
| 76 | + implementation group: 'com.googlecode.json-simple', name: 'json-simple', version:'1.1' |
| 77 | + implementation group: 'org.reflections', name: 'reflections', version:'0.9.10' |
| 78 | + |
| 79 | + // (Required) Writing and executing Unit Tests on the JUnit Platform |
| 80 | + testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1" |
| 81 | + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1" |
| 82 | + |
| 83 | + // (Optional) If you need "Parameterized Tests" |
| 84 | + testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1" |
| 85 | + |
| 86 | + // (Optional) If you also have JUnit 4-based tests |
| 87 | + testImplementation "junit:junit:4.13" |
| 88 | + testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.7.1" |
| 89 | + |
| 90 | + // Instrumentation test stuff |
| 91 | + androidTestImplementation "androidx.test:runner:1.3.0" |
| 92 | + androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1" |
| 93 | + androidTestImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1" |
| 94 | + |
| 95 | + androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.2.2" |
| 96 | + androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.2.2" |
| 97 | +} |
0 commit comments