| author | Da Risk <da_risk@geekorum.com> |
| Fri, 14 Jun 2019 18:37:04 -0700 | |
| changeset 256 | 64383b6d394c |
| parent 203 | e7edb332d468 |
| child 294 | cf42669347cf |
| 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 |
* |
|
|
137
5464f07a306c
Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents:
128
diff
changeset
|
4 |
* Copyright (C) 2017-2019 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 |
|
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
27 |
import org.gradle.api.artifacts.ExternalModuleDependency |
| 0 | 28 |
import org.gradle.api.artifacts.dsl.DependencyHandler |
29 |
import org.gradle.kotlin.dsl.closureOf |
|
30 |
import org.gradle.kotlin.dsl.dependencies |
|
31 |
import org.gradle.kotlin.dsl.extra |
|
32 |
import org.gradle.kotlin.dsl.kotlin |
|
| 203 | 33 |
import org.gradle.kotlin.dsl.provideDelegate |
| 0 | 34 |
|
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
35 |
const val espressoVersion = "3.2.0" |
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
36 |
const val androidxTestRunnerVersion = "1.1.1" |
|
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
37 |
const val androidxTestCoreVersion = "1.1.0" |
|
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
38 |
const val androidxTestExtVersion = "1.1.0" |
|
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() {
|
|
46 |
val kotlinVersion: String by rootProject.extra |
|
47 |
||
48 |
extensions.configure<BaseExtension>("android") {
|
|
49 |
defaultConfig {
|
|
50 |
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
51 |
testInstrumentationRunnerArgument("clearPackageData", "true")
|
|
256
64383b6d394c
PurgeArticlesWorker: add tests
Da Risk <da_risk@geekorum.com>
parents:
203
diff
changeset
|
52 |
testInstrumentationRunnerArgument("disableAnalytics", "true")
|
| 0 | 53 |
} |
54 |
||
55 |
testOptions {
|
|
56 |
execution = "ANDROIDX_TEST_ORCHESTRATOR" |
|
|
128
e48c1ddb578f
Disable animation during instrumentation tests
Da Risk <da_risk@geekorum.com>
parents:
64
diff
changeset
|
57 |
animationsDisabled = true |
| 0 | 58 |
|
59 |
unitTests(closureOf<TestOptions.UnitTestOptions> {
|
|
60 |
isIncludeAndroidResources = true |
|
61 |
}) |
|
62 |
} |
|
63 |
} |
|
64 |
||
65 |
||
66 |
dependencies {
|
|
67 |
dualTestImplementation(kotlin("test-junit", kotlinVersion))
|
|
68 |
||
69 |
androidTestUtil("androidx.test:orchestrator:$androidxTestRunnerVersion")
|
|
70 |
androidTestImplementation("androidx.test:runner:$androidxTestRunnerVersion")
|
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
71 |
dualTestImplementation("androidx.test.ext:junit-ktx:$androidxTestExtVersion")
|
| 0 | 72 |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
73 |
dualTestImplementation("androidx.test:core-ktx:$androidxTestCoreVersion")
|
| 0 | 74 |
dualTestImplementation("androidx.test:rules:$androidxTestRunnerVersion")
|
75 |
||
76 |
dualTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
|
77 |
dualTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
|
|
78 |
dualTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")
|
|
79 |
||
80 |
// assertions |
|
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
81 |
dualTestImplementation("com.google.truth:truth:0.44")
|
| 0 | 82 |
dualTestImplementation("androidx.test.ext:truth:$androidxTestExtVersion")
|
83 |
||
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
84 |
// fix for guava listenablefuture conflict with application runtime version |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
85 |
dualTestImplementation("com.google.guava:listenablefuture:1.0") {
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
86 |
isForce = true |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
87 |
} |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
88 |
|
| 0 | 89 |
// mock |
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
90 |
testImplementation("io.mockk:mockk:1.9")
|
| 0 | 91 |
testImplementation("org.robolectric:robolectric:$robolectricVersion")
|
92 |
||
93 |
} |
|
94 |
} |
|
95 |
||
|
19
5dcfa95ec99b
buildscript: expose dualTestImplementation method
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
96 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any) {
|
| 0 | 97 |
add("androidTestImplementation", dependencyNotation)
|
98 |
add("testImplementation", dependencyNotation)
|
|
99 |
} |
|
100 |
||
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
101 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any, action: ExternalModuleDependency.() -> Unit) {
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
102 |
val closure = closureOf(action) |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
103 |
add("androidTestImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
104 |
add("testImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
105 |
} |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
106 |
|
| 0 | 107 |
internal fun DependencyHandler.`androidTestImplementation`(dependencyNotation: Any): Dependency? = |
108 |
add("androidTestImplementation", dependencyNotation)
|
|
109 |
||
110 |
||
111 |
internal fun DependencyHandler.`androidTestUtil`(dependencyNotation: Any): Dependency? = |
|
112 |
add("androidTestUtil", dependencyNotation)
|
|
113 |
||
114 |
internal fun DependencyHandler.`testImplementation`(dependencyNotation: Any): Dependency? = |
|
115 |
add("testImplementation", dependencyNotation)
|
|
116 |