Skip to content

Commit 21a528e

Browse files
authored
Add module for shared test dependencies (#912)
1 parent 33c8529 commit 21a528e

File tree

15 files changed

+79
-15
lines changed

15 files changed

+79
-15
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ android {
4040
}
4141
}
4242

43-
android {
44-
sourceSets {
45-
val sharedTestDir = "src/sharedTest/java"
46-
getByName("test") {
47-
java.srcDir(sharedTestDir)
48-
resources.srcDir("src/sharedTest/resources")
49-
}
50-
getByName("androidTest") {
51-
java.srcDir(sharedTestDir)
52-
}
53-
}
54-
}
55-
5643
buildTypes {
5744
getByName("debug") {
5845
isMinifyEnabled = false
@@ -191,6 +178,7 @@ dependencies {
191178
testImplementation(libs.androidx.test.core.ktx)
192179
testImplementation(libs.androidx.test.ext)
193180
testImplementation(libs.androidx.test.rules)
181+
testImplementation(project(":shared-test"))
194182

195183
// AndroidX Test - Instrumented testing
196184
androidTestImplementation(libs.androidx.test.core.ktx)
@@ -204,6 +192,7 @@ dependencies {
204192
androidTestImplementation(libs.androidx.test.espresso.intents)
205193
androidTestImplementation(libs.androidx.test.espresso.idling.resources)
206194
androidTestImplementation(libs.androidx.test.espresso.idling.concurrent)
195+
androidTestImplementation(project(":shared-test"))
207196

208197
// AndroidX Test - Hilt testing
209198
androidTestImplementation(libs.hilt.android.testing)

app/src/main/java/com/example/android/architecture/blueprints/todoapp/data/Task.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ import java.util.UUID
2525
* @param description description of the task
2626
* @param isCompleted whether or not this task is completed
2727
* @param id id of the task
28+
*
29+
* TODO: The constructor of this class should be `internal` but it is used in previews and tests
30+
* so that's not possible until those previews/tests are refactored.
2831
*/
29-
data class Task internal constructor(
32+
data class Task(
3033
val title: String = "",
3134
val description: String = "",
3235
val isCompleted: Boolean = false,

build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
plugins {
17+
alias(libs.plugins.android.application) apply false
18+
alias(libs.plugins.android.library) apply false
19+
alias(libs.plugins.kotlin.android) apply false
20+
alias(libs.plugins.kapt) apply false
21+
alias(libs.plugins.hilt) apply false
22+
}

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ dependencyResolutionManagement {
2929
}
3030
}
3131

32-
3332
include(":app")
33+
include(":shared-test")

shared-test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

shared-test/build.gradle.kts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
plugins {
17+
alias(libs.plugins.android.library)
18+
alias(libs.plugins.kotlin.android)
19+
alias(libs.plugins.kapt)
20+
alias(libs.plugins.hilt)
21+
}
22+
23+
android {
24+
namespace = "com.example.android.architecture.blueprints.todoapp.shared.test"
25+
compileSdk = libs.versions.compileSdk.get().toInt()
26+
defaultConfig {
27+
minSdk = libs.versions.minSdk.get().toInt()
28+
}
29+
}
30+
31+
dependencies {
32+
implementation(project(":app"))
33+
implementation(libs.kotlinx.coroutines.android)
34+
implementation(libs.kotlinx.coroutines.test)
35+
implementation(libs.junit4)
36+
implementation(libs.androidx.test.core.ktx)
37+
implementation(libs.androidx.test.ext)
38+
implementation(libs.androidx.test.rules)
39+
implementation(libs.hilt.android.core)
40+
implementation(libs.hilt.android.testing)
41+
kapt(libs.hilt.compiler)
42+
43+
// Room
44+
implementation(libs.room.runtime)
45+
implementation(libs.room.ktx)
46+
kapt(libs.room.compiler)
47+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
xml version="1.0" encoding="utf-8"?>
2+
17+
<manifest />

0 commit comments

Comments
 (0)