Skip to content

Commit d33d1cd

Browse files
committed
Add TaskfolioTestRunner to tweak TasksApplication behavior
1 parent bebee2a commit d33d1cd

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

gradle/libs.versions.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ coil = "3.2.0"
2323
about-libraries = "12.1.2"
2424
mockito = "5.17.0"
2525
kover = "0.9.1"
26+
androidx-test-runner = "1.6.2"
2627

2728
[libraries]
2829
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
@@ -91,6 +92,7 @@ about-libraries-core = { module = "com.mikepenz:aboutlibraries-core", version.re
9192
androidx-test-core = { module = "androidx.test:core", version = "1.6.1" }
9293
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "compose" }
9394
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose" }
95+
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" }
9496

9597
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
9698

tasks-app-android/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ android {
4949

5050
androidResources.localeFilters += listOf("en", "fr")
5151

52-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
52+
testInstrumentationRunner = "net.opatry.tasks.app.test.TaskfolioTestRunner"
5353
}
5454

5555
androidResources {
@@ -168,6 +168,7 @@ dependencies {
168168
debugImplementation(libs.androidx.ui.test.manifest)
169169

170170
androidTestImplementation(libs.androidx.ui.test.junit4)
171+
androidTestImplementation(libs.androidx.test.runner)
171172
}
172173

173174
aboutLibraries {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2025 Olivier Patry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the Software
9+
* is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20+
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
package net.opatry.tasks.app.test
24+
25+
import android.app.Application
26+
import android.content.Context
27+
import androidx.test.runner.AndroidJUnitRunner
28+
29+
class TaskfolioTestRunner : AndroidJUnitRunner() {
30+
override fun newApplication(classLoader: ClassLoader?, className: String?, context: Context?): Application {
31+
return super.newApplication(classLoader, TestTasksApplication::class.java.name, context)
32+
}
33+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025 Olivier Patry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the Software
9+
* is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16+
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
20+
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
package net.opatry.tasks.app.test
24+
25+
import net.opatry.tasks.app.TasksApplication
26+
27+
class TestTasksApplication : TasksApplication() {
28+
29+
override val target: String
30+
get() = "test"
31+
}

0 commit comments

Comments
 (0)