Skip to content

Commit 8028617

Browse files
committed
Prepare 1.0.10
2 parents a16af5a + a47b368 commit 8028617

File tree

22 files changed

+1700
-1319
lines changed

22 files changed

+1700
-1319
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
local.properties
44
.idea/*
55
!.idea/runConfigurations
6+
!.idea/codeStyleSettings.xml
67
.DS_Store
78
build/
89
captures/

.idea/codeStyleSettings.xml

Lines changed: 356 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android:
1111
components:
1212
- tools
1313
- platform-tools
14-
- build-tools-26.0.1
14+
- build-tools-26.0.2
1515
- android-26
1616

1717
jdk:

README.md

Lines changed: 76 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A Gradle plugin that allows for the execution of [JUnit 5][junit5gh] unit tests
99
```groovy
1010
buildscript {
1111
dependencies {
12-
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.0"
12+
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.0.10"
1313
}
1414
}
1515
```
@@ -27,51 +27,104 @@ dependencies {
2727
2828
// (Optional) If you need "parameterized tests"
2929
testImplementation junit5Params()
30-
31-
// For Android Studio users:
32-
//
33-
// All versions up to and including AS 3.0 Beta 5 use a build of IntelliJ IDEA
34-
// that depends on APIs of an outdated Milestone Release of JUnit 5.
35-
// Therefore, your tests will fail with a NoSuchMethodError
36-
// when executed from Android Studio directly.
37-
//
38-
// To prevent this, there is a separate library you can apply here.
39-
// It provides a copy of the JUnit 5 Runtime used in a more recent build
40-
// of IntelliJ, overriding the one embedded in Android Studio.
41-
//
42-
// Please note the version of this dependency! There was an issue with the deployment
43-
// of the "1.0.0" JAR, so that one actually won't work as advertised. Please explicitly
44-
// depend on this version instead; there won't be any incompatibilities with the main plugin,
45-
// since this doesn't share any connection with it. Sorry for the inconvenience!
46-
testCompileOnly "de.mannodermaus.gradle.plugins:android-junit5-embedded-runtime:1.0.0-RC3-rev1"
4730
}
4831
```
4932

5033
## Usage
5134

52-
This plugin configures the `junitPlatform` task for each registered build variant of a project.
53-
It automatically attaches both the Jupiter & Vintage Engines during the execution phase of your tests.
35+
This plugin configures a `junitPlatformTest` task for each registered build variant of a project.
36+
It automatically attaches both the Jupiter & Vintage Engines during the execution phase of your tests as well.
5437

5538
More instructions on how to write JUnit 5 tests can be found [in their User Guide][junit5ug].
5639
Furthermore, this repository provides a small showcase of the functionality provided by JUnit 5 [here][sampletests].
5740

41+
## Android Studio Workarounds
42+
43+
> **Note:**
44+
>
45+
> The following section deals with fixing Test Execution within **Android Studio 3**.
46+
> Running your JUnit 5 tests directly from Android Studio 2.3.3 and earlier **will not work**:
47+
> You will encounter an `AbstractMethodError` when trying to do so ([more information here][as2issue]).
48+
>
49+
> The cause of this error is similar in nature to the one described below, and related to outdated APIs.
50+
> Unlike that issue though, we can't fix the `AbstractMethodError` inside IntelliJ's internal runtime
51+
> in the same way. Therefore, please resort to using Gradle for unit testing in Android Studio 2.
52+
53+
54+
All versions up to and including **Android Studio 3.0 Beta 7** are built
55+
on a version of IntelliJ IDEA that depends on outdated JUnit 5 APIs.
56+
Therefore, your tests will fail with an Exception similar to the following when you try to
57+
launch your tests from inside the IDE (using an *Android JUnit* Run Configuration):
58+
59+
```
60+
Exception in thread "main" java.lang.NoSuchMethodError: org.junit.platform.launcher.Launcher.execute(Lorg/junit/platform/launcher/LauncherDiscoveryRequest;)V
61+
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:42)
62+
...
63+
```
64+
65+
To work around this, there is a separate dependency you can add to the *test* scope
66+
of your project in Android Studio 3. It provides its own copy of the JUnit 5 Runtime
67+
provided by a more recent build of IntelliJ, overriding the one embedded in Android Studio.
68+
69+
To use this, add the following line alongside the other `junit5()` dependencies:
70+
71+
```groovy
72+
testCompileOnly junit5EmbeddedRuntime()
73+
```
74+
75+
*As mentioned above, this will **only** fix Test Execution from Android Studio 3.*
76+
5877
## Extras
5978

79+
### Override Dependency Versions
80+
6081
Inside the configuration closure applied by the plugin, you can specify the same properties as you would
6182
for a Java-based project with the JUnit Platform Gradle plugin.
6283
However, there are some additional properties that you can apply:
6384

6485
```groovy
6586
junitPlatform {
6687
// The JUnit Jupiter dependency version to use; matches the platform's version by default
67-
jupiterVersion "5.0.0"
88+
jupiterVersion "5.0.1"
6889
// The JUnit Vintage Engine dependency version to use; matches the platform's version by default
69-
vintageVersion "4.12.0"
90+
vintageVersion "4.12.1"
7091
}
7192
```
7293

94+
### JaCoCo Integration
95+
96+
If the plugin detects the usage of [JaCoCo][jacoco] inside a project that it's being applied to,
97+
it will automatically configure additional tasks to report the unit test coverage
98+
of your application based on its JUnit 5 tests.
99+
There is no additional setup required to enable this behaviour.
100+
You can however customize the reports JaCoCo should generate.
101+
102+
Configuration is applied through the `jacoco` clause inside the plugin's DSL:
103+
104+
```groovy
105+
junitPlatform {
106+
jacoco {
107+
csvReport true
108+
xmlReport true
109+
htmlReport true
110+
}
111+
}
112+
```
113+
114+
## License
115+
116+
`android-junit5` is distributed with multiple Open Source licenses:
117+
118+
- `android-junit5-embedded-runtime` uses [Apache License v2.0](android-junit5-embedded-runtime/LICENSE.md)
119+
- All other modules use [Eclipse Public License v2.0](android-junit5/LICENSE.md)
120+
121+
Please see the `LICENSE.md` files in the subfolders for more details.
122+
73123
[junit5gh]: https://github.com/junit-team/junit5
74124
[junit5ug]: http://junit.org/junit5/docs/current/user-guide
75125
[travisci]: https://travis-ci.org/mannodermaus/android-junit5
76-
[sonatyperepo]: https://oss.sonatype.org/content/repositories/snapshots
126+
[as2issue]: https://github.com/mannodermaus/android-junit5/issues/19
127+
[jacoco]: http://www.eclemma.org/jacoco
128+
[sonatyperepo]: https://oss.sonatype.org/content/repositories/snapshots/de/mannodermaus/gradle/plugins
77129
[sampletests]: sample/src/test
130+
[licensefile]: LICENSE.md
Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
buildscript {
2-
repositories {
3-
jcenter()
4-
}
5-
dependencies {
6-
classpath "com.github.jengelman.gradle.plugins:shadow:$SHADOW_PLUGIN_VERSION"
7-
}
2+
repositories {
3+
jcenter()
4+
}
5+
dependencies {
6+
classpath "com.github.jengelman.gradle.plugins:shadow:$SHADOW_PLUGIN_VERSION"
7+
}
88
}
99

1010
apply plugin: "java-library"
@@ -13,25 +13,25 @@ apply plugin: "maven-publish"
1313
apply plugin: "com.github.johnrengelman.shadow"
1414
apply plugin: "com.jfrog.bintray"
1515

16-
sourceCompatibility = JavaVersion.VERSION_1_6
17-
targetCompatibility = JavaVersion.VERSION_1_6
18-
1916
// ------------------------------------------------------------------------------------------------
2017
// Dependency Definitions
21-
// This module exports a "fat JAR" with the embedded junit5-rt from IntelliJ IDEA,
18+
// This module exports a "fat JAR" containing embedded JARs from IntelliJ IDEA,
2219
// using a shadowed JAR that overrides the default build artifact.
20+
//
21+
// Path to this JAR inside an IntelliJ IDEA package:
22+
// "plugins/junit/lib/junit5-rt.jar"
2323
// ------------------------------------------------------------------------------------------------
2424

2525
dependencies {
26-
implementation files("libs/junit5-rt.jar")
26+
implementation files("libs/junit5-rt.jar")
2727
}
2828

2929
shadowJar {
30-
// Remove '-all' suffix from the generated JAR
31-
classifier = null
30+
// Remove '-all' suffix from the generated JAR
31+
classifier = null
3232
}
3333

34-
build.doLast { shadowJar.execute() }
34+
build.finalizedBy shadowJar
3535

3636
// ------------------------------------------------------------------------------------------------
3737
// Deployment Setup
@@ -42,76 +42,75 @@ build.doLast { shadowJar.execute() }
4242

4343
// Include sources.jar archive in each release
4444
task sourcesJar(type: Jar, dependsOn: classes) {
45-
classifier = "sources"
46-
from sourceSets.main.allSource
45+
classifier = "sources"
46+
from sourceSets.main.allSource
4747
}
4848

4949
// Include javadoc.jar archive in each release
5050
task javadocJar(type: Jar, dependsOn: javadoc) {
51-
classifier = "javadoc"
52-
from javadoc.destinationDir
51+
classifier = "javadoc"
52+
from javadoc.destinationDir
5353
}
5454

5555
artifacts {
56-
archives sourcesJar
57-
archives javadocJar
56+
archives sourcesJar
57+
archives javadocJar
5858
}
5959

6060
version = VERSION_NAME
6161

6262
publishing {
63-
publications {
64-
library(MavenPublication) {
65-
project.shadow.component(it)
66-
}
63+
publications {
64+
library(MavenPublication) {
65+
project.shadow.component(it)
6766
}
67+
}
6868
}
6969

7070
// Copy POM to location expected by Bintray
7171
task copyPom(type: Copy) {
72-
from "build/publications/library"
73-
into "build/poms"
74-
include "pom-default.xml"
72+
from "build/publications/library"
73+
into "build/poms"
74+
include "pom-default.xml"
7575
}
7676

7777
publish.dependsOn copyPom
7878

7979
project.configure(project) {
80-
if (project.version.endsWith("-SNAPSHOT")) {
81-
// Configure deployment of snapshot versions to Sonatype OSS
82-
project.publishing {
83-
repositories {
84-
maven {
85-
name "snapshot"
86-
credentials {
87-
username project.ext.sonatypeUser
88-
password project.ext.sonatypePass
89-
}
90-
url "https://oss.sonatype.org/content/repositories/snapshots"
91-
}
92-
}
80+
if (project.version.endsWith("-SNAPSHOT")) {
81+
// Configure deployment of snapshot versions to Sonatype OSS
82+
project.publishing {
83+
repositories {
84+
maven {
85+
name "snapshot"
86+
credentials {
87+
username project.ext.sonatypeUser
88+
password project.ext.sonatypePass
89+
}
90+
url "https://oss.sonatype.org/content/repositories/snapshots"
9391
}
94-
95-
} else {
96-
// Configure deployment of release versions to Bintray
97-
project.bintray {
98-
user = project.ext.bintrayUser
99-
key = project.ext.bintrayKey
100-
configurations = ["archives"]
101-
dryRun = false
102-
pkg {
103-
repo = "maven"
104-
name = RUNTIME_ARTIFACT_ID
105-
userOrg = project.ext.bintrayUser
106-
licenses = [RUNTIME_LICENSE_NAME]
107-
publish = true
108-
publicDownloadNumbers = true
109-
vcsUrl = VCS_URL
110-
version {
111-
name = VERSION_NAME
112-
desc = RUNTIME_DESCRIPTION
113-
}
114-
}
92+
}
93+
}
94+
} else {
95+
// Configure deployment of release versions to Bintray
96+
project.bintray {
97+
user = project.ext.bintrayUser
98+
key = project.ext.bintrayKey
99+
configurations = ["archives"]
100+
dryRun = false
101+
pkg {
102+
repo = "maven"
103+
name = RUNTIME_ARTIFACT_ID
104+
userOrg = project.ext.bintrayUser
105+
licenses = [RUNTIME_LICENSE_NAME]
106+
publish = true
107+
publicDownloadNumbers = true
108+
vcsUrl = VCS_URL
109+
version {
110+
name = VERSION_NAME
111+
desc = RUNTIME_DESCRIPTION
115112
}
113+
}
116114
}
115+
}
117116
}

0 commit comments

Comments
 (0)