| author | Da Risk <da_risk@geekorum.com> |
| Tue, 03 Mar 2020 20:51:57 -0400 | |
| changeset 635 | 1c1d190b326a |
| parent 611 | 91b8d76c03cd |
| child 644 | e14736328c33 |
| permissions | -rw-r--r-- |
|
137
5464f07a306c
Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents:
128
diff
changeset
|
1 |
/* |
| 0 | 2 |
* Geekttrss is a RSS feed reader application on the Android Platform. |
3 |
* |
|
| 611 | 4 |
* Copyright (C) 2017-2020 by Frederic-Charles Barthelery. |
| 0 | 5 |
* |
6 |
* This file is part of Geekttrss. |
|
7 |
* |
|
8 |
* Geekttrss is free software: you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation, either version 3 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* Geekttrss is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with Geekttrss. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
*/ |
|
21 |
package com.geekorum.build |
|
22 |
||
23 |
import com.android.build.gradle.BaseExtension |
|
24 |
import com.android.build.gradle.internal.dsl.TestOptions |
|
25 |
import org.gradle.api.Project |
|
26 |
import org.gradle.api.artifacts.Dependency |
|
| 357 | 27 |
import org.gradle.api.artifacts.DependencyConstraint |
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
28 |
import org.gradle.api.artifacts.ExternalModuleDependency |
| 357 | 29 |
import org.gradle.api.artifacts.dsl.DependencyConstraintHandler |
| 0 | 30 |
import org.gradle.api.artifacts.dsl.DependencyHandler |
31 |
import org.gradle.kotlin.dsl.closureOf |
|
| 397 | 32 |
import org.gradle.kotlin.dsl.configure |
| 0 | 33 |
import org.gradle.kotlin.dsl.dependencies |
34 |
import org.gradle.kotlin.dsl.kotlin |
|
35 |
||
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
36 |
const val espressoVersion = "3.2.0" |
| 357 | 37 |
const val androidxTestRunnerVersion = "1.3.0-alpha01" |
38 |
const val androidxTestCoreVersion = "1.2.1-alpha01" |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
39 |
const val robolectricVersion = "4.1" |
| 0 | 40 |
|
41 |
||
42 |
/* |
|
43 |
* Configuration for espresso and robolectric usage in an Android project |
|
44 |
*/ |
|
45 |
internal fun Project.configureTests() {
|
|
| 397 | 46 |
extensions.configure<BaseExtension> {
|
| 0 | 47 |
defaultConfig {
|
48 |
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
49 |
testInstrumentationRunnerArgument("clearPackageData", "true")
|
|
256
64383b6d394c
PurgeArticlesWorker: add tests
Da Risk <da_risk@geekorum.com>
parents:
203
diff
changeset
|
50 |
testInstrumentationRunnerArgument("disableAnalytics", "true")
|
| 0 | 51 |
} |
52 |
||
53 |
testOptions {
|
|
54 |
execution = "ANDROIDX_TEST_ORCHESTRATOR" |
|
|
128
e48c1ddb578f
Disable animation during instrumentation tests
Da Risk <da_risk@geekorum.com>
parents:
64
diff
changeset
|
55 |
animationsDisabled = true |
| 0 | 56 |
|
57 |
unitTests(closureOf<TestOptions.UnitTestOptions> {
|
|
58 |
isIncludeAndroidResources = true |
|
59 |
}) |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
dependencies {
|
|
| 397 | 64 |
dualTestImplementation(kotlin("test-junit"))
|
| 0 | 65 |
|
66 |
androidTestUtil("androidx.test:orchestrator:$androidxTestRunnerVersion")
|
|
67 |
androidTestImplementation("androidx.test:runner:$androidxTestRunnerVersion")
|
|
|
294
cf42669347cf
build: Update androidx test libraries
Da Risk <da_risk@geekorum.com>
parents:
256
diff
changeset
|
68 |
dualTestImplementation("androidx.test.ext:junit-ktx:1.1.1")
|
| 0 | 69 |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
70 |
dualTestImplementation("androidx.test:core-ktx:$androidxTestCoreVersion")
|
| 0 | 71 |
dualTestImplementation("androidx.test:rules:$androidxTestRunnerVersion")
|
72 |
||
| 357 | 73 |
// fragment testing is usually declared on debugImplementation configuration and need these dependencies |
74 |
constraints {
|
|
75 |
debugImplementation("androidx.test:core:$androidxTestCoreVersion")
|
|
76 |
debugImplementation("androidx.test:monitor:$androidxTestRunnerVersion")
|
|
77 |
} |
|
78 |
||
| 0 | 79 |
dualTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
80 |
dualTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
|
|
81 |
dualTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")
|
|
82 |
||
83 |
// assertions |
|
| 357 | 84 |
dualTestImplementation("com.google.truth:truth:1.0")
|
85 |
dualTestImplementation("androidx.test.ext:truth:1.3.0-alpha01")
|
|
| 0 | 86 |
|
87 |
// mock |
|
|
635
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
88 |
testImplementation("io.mockk:mockk:1.9.3")
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
89 |
androidTestImplementation("io.mockk:mockk-android:1.9.3")
|
| 0 | 90 |
testImplementation("org.robolectric:robolectric:$robolectricVersion")
|
91 |
||
|
635
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
92 |
constraints {
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
93 |
dualTestImplementation(kotlin("reflect")) {
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
94 |
because("Use the kotlin version that we use")
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
95 |
} |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
96 |
androidTestImplementation("org.objenesis:objenesis") {
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
97 |
because("3.x version use instructions only available with minSdk 26 (Android O)")
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
98 |
version {
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
99 |
strictly("2.6")
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
100 |
} |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
101 |
} |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
102 |
} |
| 0 | 103 |
} |
104 |
} |
|
105 |
||
|
19
5dcfa95ec99b
buildscript: expose dualTestImplementation method
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
106 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any) {
|
| 0 | 107 |
add("androidTestImplementation", dependencyNotation)
|
108 |
add("testImplementation", dependencyNotation)
|
|
109 |
} |
|
110 |
||
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
111 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any, action: ExternalModuleDependency.() -> Unit) {
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
112 |
val closure = closureOf(action) |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
113 |
add("androidTestImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
114 |
add("testImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
115 |
} |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
116 |
|
| 357 | 117 |
internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any): Dependency? = |
| 0 | 118 |
add("androidTestImplementation", dependencyNotation)
|
119 |
||
|
635
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
120 |
internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any, action: ExternalModuleDependency.() -> Unit) {
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
121 |
val closure = closureOf(action) |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
122 |
add("androidTestImplementation", dependencyNotation, closure)
|
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
123 |
} |
| 0 | 124 |
|
| 357 | 125 |
internal fun DependencyHandler.androidTestUtil(dependencyNotation: Any): Dependency? = |
| 0 | 126 |
add("androidTestUtil", dependencyNotation)
|
127 |
||
| 357 | 128 |
internal fun DependencyHandler.testImplementation(dependencyNotation: Any): Dependency? = |
| 0 | 129 |
add("testImplementation", dependencyNotation)
|
130 |
||
| 357 | 131 |
|
132 |
internal fun DependencyConstraintHandler.debugImplementation(dependencyConstraintNotation: Any): DependencyConstraint? = |
|
133 |
add("debugImplementation", dependencyConstraintNotation)
|