Skip to content

Commit 90eb8dd

Browse files
author
Marcel Schnelle
authored
Update sample to use 1.2.0.0 (#107)
1 parent 5bb48a9 commit 90eb8dd

File tree

7 files changed

+35
-24
lines changed

7 files changed

+35
-24
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defaults: &defaults
44
docker:
55
- image: circleci/android:api-28-alpha
66
environment:
7-
GRADLE_OPTS: '-Dorg.gradle.daemon=true -Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError"'
7+
GRADLE_OPTS: '-Dorg.gradle.daemon=true -Dorg.gradle.jvmargs="-Xmx4g -XX:+HeapDumpOnOutOfMemoryError"'
88

99
cache_key: &cache_key
1010
key: jars-{{ checksum "build.gradle" }}-{{ checksum "android-junit5/build.gradle" }}-{{ checksum "android-junit5-tests/build.gradle" }}-{{ checksum "instrumentation/build.gradle" }}-{{ checksum "instrumentation-runner/build.gradle" }}-{{ checksum "sample/build.gradle" }}-{{ checksum "gradle.properties" }}-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}

.idea/runConfigurations/Sample__Run_Unit_Tests__Gradle_.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ The latest version of this plugin requires:
5252

5353
## Instrumentation Test Support
5454

55-
There is experimental support for Android instrumentation tests, which requires some additional configuration & dependencies. Note that since JUnit 5 is built on Java 8 from the ground up, these libraries require you to have a `minSdkVersion` of at least `26`.
55+
There is experimental support for Android instrumentation tests, which requires some additional configuration & dependencies. Note that since JUnit 5 is built on Java 8 from the ground up, these libraries require you to have a `minSdkVersion` of at least `26`. It's recommended to use a product flavor for experimentation if you want to keep your global requirements below `26`. Check the sample for how this can be done!
5656

57-
To include the experimental instrumentation test support, add the following to your `build.gradle`:
57+
To start writing instrumentation tests with JUnit Jupiter, add the following to your `build.gradle`:
5858

5959
```groovy
6060
android {
@@ -67,11 +67,13 @@ android {
6767
}
6868
dependencies {
6969
// (Required) Writing tests for JUnit Jupiter
70-
// Note: Including the Engine as well is not required for instrumentation tests
7170
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.2.0"
72-
73-
// (Required) Instrumentation test libraries
71+
// (Required) The instrumentation test companion library
7472
androidTestImplementation "de.mannodermaus.junit5:android-instrumentation-test:0.2.2"
73+
74+
// (Required) Runtime dependencies to orchestrate the execution on-device
75+
androidTestRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.2.0"
76+
androidTestRuntimeOnly "org.junit.platform:junit-platform-runner:1.2.0"
7577
androidTestRuntimeOnly "de.mannodermaus.junit5:android-instrumentation-test-runner:0.2.2"
7678
}
7779
```

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ GITHUB_REPO = mannodermaus/android-junit5
66
LICENSE_NAME = Apache-2.0
77

88
# Artifact configuration (plugin)
9-
PLUGIN_GROUP_ID = de.mannodermaus.gradle.plugins
10-
PLUGIN_ARTIFACT_ID = android-junit5
11-
PLUGIN_DESCRIPTION = Unit Testing with JUnit 5 for Android.
12-
PLUGIN_VERSION_NAME = 1.2.0.1-SNAPSHOT
13-
PLUGIN_VERSION_NAME_LATEST_STABLE = 1.0.32
9+
PLUGIN_GROUP_ID = de.mannodermaus.gradle.plugins
10+
PLUGIN_ARTIFACT_ID = android-junit5
11+
PLUGIN_DESCRIPTION = Unit Testing with JUnit 5 for Android.
12+
PLUGIN_VERSION_NAME = 1.2.0.1-SNAPSHOT
13+
PLUGIN_VERSION_NAME_LATEST_STABLE = 1.2.0.0
1414

1515
# Artifact configuration (instrumentation & runner)
1616
INSTRUMENTATION_GROUP_ID = de.mannodermaus.junit5
@@ -45,7 +45,7 @@ KOTLIN_VERSION = 1.2.51
4545
COMPILE_SDK_VERSION = android-28
4646
BUILD_TOOLS_VERSION = 27.0.3
4747
TARGET_SDK_VERSION = 28
48-
JAVA_MAX_HEAP_SIZE = 1024m
48+
JAVA_MAX_HEAP_SIZE = 3g
4949

5050
# Android Environment (sample)
5151
SAMPLE_MIN_SDK_VERSION = 14

sample/build.gradle

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ android {
2929
versionCode 1
3030
versionName "1.0"
3131

32+
// Make sure to use the AndroidJUnitRunner (or a sub-class) in order to hook in the JUnit 5 Test Builder
3233
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
34+
testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"
3335
}
3436

3537
// Since the minSdkVersion requirement for JUnit 5 Instrumentation Tests is quite high,
@@ -59,10 +61,10 @@ android {
5961

6062
testOptions {
6163
junitPlatform {
62-
details "tree"
63-
platformVersion JUNIT_PLATFORM_VERSION
64-
jupiterVersion JUNIT_JUPITER_VERSION
65-
vintageVersion JUNIT_VINTAGE_VERSION
64+
// Configure JUnit 5 tests here
65+
}
66+
unitTests.all {
67+
testLogging.events = ["passed", "skipped", "failed"]
6668
}
6769
}
6870

@@ -75,13 +77,20 @@ android {
7577
dependencies {
7678
implementation "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
7779

78-
testImplementation junit5.unitTests()
79-
testImplementation junit5.parameterized()
80+
testImplementation "org.junit.jupiter:junit-jupiter-api:$JUNIT_JUPITER_VERSION"
81+
testImplementation "org.junit.jupiter:junit-jupiter-params:$JUNIT_JUPITER_VERSION"
82+
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$JUNIT_JUPITER_VERSION"
8083

8184
androidTestImplementation "junit:junit:$JUNIT4_VERSION"
8285
androidTestImplementation "com.android.support.test:runner:$SUPPORT_TEST_LIBRARY_VERSION"
8386

84-
// Include the instrumentation test dependencies to the product flavor
85-
androidTestExperimentalImplementation junit5.unitTests()
86-
androidTestExperimentalImplementation junit5.instrumentationTests()
87+
// Add the Android Instrumentation Test dependencies to the product flavor only
88+
// (with this, only the "experimental" flavor must have minSdkVersion 26)
89+
androidTestExperimentalImplementation "org.junit.jupiter:junit-jupiter-api:$JUNIT_JUPITER_VERSION"
90+
androidTestExperimentalImplementation "de.mannodermaus.junit5:android-instrumentation-test:$INSTRUMENTATION_VERSION_NAME_LATEST_STABLE"
91+
92+
// Runtime dependencies for Android Instrumentation Tests
93+
androidTestExperimentalRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$JUNIT_JUPITER_VERSION"
94+
androidTestExperimentalRuntimeOnly "org.junit.platform:junit-platform-runner:$JUNIT_PLATFORM_VERSION"
95+
androidTestExperimentalRuntimeOnly "de.mannodermaus.junit5:android-instrumentation-test-runner:$INSTRUMENTATION_VERSION_NAME_LATEST_STABLE"
8796
}

sample/src/test/java/de/mannodermaus/junit5/sample/ExampleJavaTest.java renamed to sample/src/test/java/de/mannodermaus/sample/ExampleJavaTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.mannodermaus.junit5.sample;
1+
package de.mannodermaus.sample;
22

33
import java.util.ArrayList;
44
import java.util.Collection;

sample/src/test/kotlin/de/mannodermaus/junit5/sample/ExampleKotlinTest.kt renamed to sample/src/test/kotlin/de/mannodermaus/sample/ExampleKotlinTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package de.mannodermaus.junit5.sample
1+
package de.mannodermaus.sample
22

33
import org.junit.jupiter.api.AfterAll
44
import org.junit.jupiter.api.AfterEach

0 commit comments

Comments
 (0)