| author | Da Risk <da_risk@geekorum.com> |
| Thu, 05 Jan 2023 14:02:19 -0400 | |
| changeset 935 | ec942dc5c721 |
| parent 918 | 4ac48c87f4a5 |
| child 943 | 298742859784 |
| 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 |
* |
|
| 882 | 4 |
* Copyright (C) 2017-2022 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 |
||
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
36 |
const val espressoVersion = "3.5.1" |
|
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
37 |
const val androidxTestRunnerVersion = "1.5.2" |
|
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
38 |
const val androidxTestCoreVersion = "1.5.0" |
|
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
39 |
const val robolectricVersion = "4.9.2" |
| 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 {
|
|
726
a89436120a6d
Make SendTransactionsWorkerTest work with hilt
Da Risk <da_risk@geekorum.com>
parents:
644
diff
changeset
|
48 |
testInstrumentationRunner = "com.geekorum.ttrss.HiltRunner" |
|
840
b41d8bc8870e
build: update various dependencies
Da Risk <da_risk@geekorum.com>
parents:
833
diff
changeset
|
49 |
testInstrumentationRunnerArguments += mapOf( |
|
b41d8bc8870e
build: update various dependencies
Da Risk <da_risk@geekorum.com>
parents:
833
diff
changeset
|
50 |
"clearPackageData" to "true", |
|
b41d8bc8870e
build: update various dependencies
Da Risk <da_risk@geekorum.com>
parents:
833
diff
changeset
|
51 |
"disableAnalytics" to "true" |
|
b41d8bc8870e
build: update various dependencies
Da Risk <da_risk@geekorum.com>
parents:
833
diff
changeset
|
52 |
) |
| 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 |
dependencies {
|
|
| 397 | 66 |
dualTestImplementation(kotlin("test-junit"))
|
| 0 | 67 |
|
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
68 |
androidTestUtil("androidx.test:orchestrator:1.4.2")
|
| 0 | 69 |
androidTestImplementation("androidx.test:runner:$androidxTestRunnerVersion")
|
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
70 |
dualTestImplementation("androidx.test.ext:junit-ktx:1.1.5")
|
| 0 | 71 |
|
|
64
0b7cf61c75e5
buildSrc: AndroidTests update dependencies version
Da Risk <da_risk@geekorum.com>
parents:
19
diff
changeset
|
72 |
dualTestImplementation("androidx.test:core-ktx:$androidxTestCoreVersion")
|
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
73 |
dualTestImplementation("androidx.test:rules:1.5.0")
|
| 0 | 74 |
|
| 357 | 75 |
// fragment testing is usually declared on debugImplementation configuration and need these dependencies |
76 |
constraints {
|
|
77 |
debugImplementation("androidx.test:core:$androidxTestCoreVersion")
|
|
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
78 |
debugImplementation("androidx.test:monitor:1.6.1")
|
| 357 | 79 |
} |
80 |
||
| 0 | 81 |
dualTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion")
|
82 |
dualTestImplementation("androidx.test.espresso:espresso-contrib:$espressoVersion")
|
|
83 |
dualTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion")
|
|
84 |
||
85 |
// assertions |
|
|
935
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
86 |
dualTestImplementation("com.google.truth:truth:1.1.3")
|
|
ec942dc5c721
build: update test dependencies
Da Risk <da_risk@geekorum.com>
parents:
918
diff
changeset
|
87 |
dualTestImplementation("androidx.test.ext:truth:1.5.0")
|
| 0 | 88 |
|
89 |
// mock |
|
| 810 | 90 |
testImplementation("io.mockk:mockk:1.11.0")
|
91 |
androidTestImplementation("io.mockk:mockk-android:1.11.0")
|
|
| 0 | 92 |
testImplementation("org.robolectric:robolectric:$robolectricVersion")
|
93 |
||
|
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
} |
|
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 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
} |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
103 |
} |
|
1c1d190b326a
build: update to agp 4.0.0-beta1 and latest play-publisher plugin
Da Risk <da_risk@geekorum.com>
parents:
611
diff
changeset
|
104 |
} |
| 0 | 105 |
} |
106 |
} |
|
107 |
||
|
19
5dcfa95ec99b
buildscript: expose dualTestImplementation method
Da Risk <da_risk@geekorum.com>
parents:
0
diff
changeset
|
108 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any) {
|
| 0 | 109 |
add("androidTestImplementation", dependencyNotation)
|
110 |
add("testImplementation", dependencyNotation)
|
|
111 |
} |
|
112 |
||
|
201
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
113 |
fun DependencyHandler.dualTestImplementation(dependencyNotation: Any, action: ExternalModuleDependency.() -> Unit) {
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
114 |
val closure = closureOf(action) |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
115 |
add("androidTestImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
116 |
add("testImplementation", dependencyNotation, closure)
|
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
117 |
} |
|
f89d3c622b33
tests: Update espresso and truth
Da Risk <da_risk@geekorum.com>
parents:
137
diff
changeset
|
118 |
|
| 357 | 119 |
internal fun DependencyHandler.androidTestImplementation(dependencyNotation: Any): Dependency? = |
| 0 | 120 |
add("androidTestImplementation", dependencyNotation)
|
121 |
||
|
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
} |
| 0 | 126 |
|
| 357 | 127 |
internal fun DependencyHandler.androidTestUtil(dependencyNotation: Any): Dependency? = |
| 0 | 128 |
add("androidTestUtil", dependencyNotation)
|
129 |
||
| 357 | 130 |
internal fun DependencyHandler.testImplementation(dependencyNotation: Any): Dependency? = |
| 0 | 131 |
add("testImplementation", dependencyNotation)
|
132 |
||
| 357 | 133 |
|
134 |
internal fun DependencyConstraintHandler.debugImplementation(dependencyConstraintNotation: Any): DependencyConstraint? = |
|
135 |
add("debugImplementation", dependencyConstraintNotation)
|