Skip to content

Commit 2d88eb8

Browse files
wintmainwosys
authored andcommitted
[common][feat]Add app unit test templates
1 parent 6a2e8ba commit 2d88eb8

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

app-catalog/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ dependencies {
9494
// libs.androidx.testext 必须和上面的 runner 一起;AS自动创建的'androidTest'会用到
9595
androidTestImplementation libs.androidx.test.ext.junit
9696
testImplementation libs.androidx.test.ext.junit
97+
testImplementation libs.junit
9798

9899
// 暂时禁用 App中集成CodeLocator: https://github.com/bytedance/CodeLocator
99100
// debugImplementation libs.codelocator.core
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2023-2025 wintmain
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+
17+
package com.wintmain.catalog.app
18+
19+
import org.junit.Test
20+
21+
import org.junit.Assert.*
22+
23+
/**
24+
* Example local unit test, which will execute on the development machine (host).
25+
*
26+
* See [testing documentation](http://d.android.com/tools/testing).
27+
*/
28+
class ExampleUnitTest {
29+
@Test
30+
fun addition_isCorrect() {
31+
assertEquals(4, 2 + 2)
32+
}
33+
}

gradle/libs.versions.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ casa = "0.5.1"
2222
coil = "2.6.0"
2323
compose-bom = "2025.02.00"
2424
composeCompiler = "1.5.9"
25+
documentfile = "1.0.1"
2526
kotlin = "1.9.22"
2627
hilt = "2.48.1"
27-
kotlinxCoroutines = "1.9.0"
28+
kotlinxCoroutines = "1.7.3"
2829
ksp = "1.9.22-1.0.17" # Should be updated when kotlin version is updated
2930
coreExt = "1.13.1"
3031
androidx_activity = "1.9.2"
@@ -34,8 +35,10 @@ androidx_window = "1.3.0"
3435
lifecycleExtensions = "2.2.0"
3536
lifecycleRuntimeKtx = "2.8.7"
3637
multidex = "1.0.3"
38+
okhttp = "4.12.0"
3739
roomRuntime = "2.6.1"
3840
smartrefresh = "1.1.2"
41+
junit = "4.13.2"
3942

4043
[libraries]
4144
# Core dependencies
@@ -60,6 +63,8 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
6063
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx_appcompat" }
6164
androidx-coreExt = { group = "androidx.core", name = "core", version.ref = "coreExt" }
6265
androidx-coreExtkt = { group = "androidx.core", name = "core-ktx", version.ref = "coreExt" }
66+
androidx-documentfile = { module = "androidx.documentfile:documentfile", version.ref = "documentfile" }
67+
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
6368

6469
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "compose-bom" }
6570
compose-material-material3 = { module = "androidx.compose.material3:material3" }
@@ -91,7 +96,6 @@ androidx-annotation = "androidx.annotation:annotation:1.8.2"
9196
androidx-fragment = "androidx.fragment:fragment-ktx:1.8.3"
9297
androidx-exifinterface = "androidx.exifinterface:exifinterface:1.3.7"
9398
androidx-transition = "androidx.transition:transition-ktx:1.5.1"
94-
androidx-lifecycle-viewmodel-compose = "androidx.lifecycle:lifecycle-viewmodel-compose:2.8.6"
9599
androidx-viewpager2 = "androidx.viewpager2:viewpager2:1.1.0"
96100
androidx-work-runtime-ktx = "androidx.work:work-runtime-ktx:2.9.1"
97101
androidx-core-remoteviews = "androidx.core:core-remoteviews:1.1.0"
@@ -118,14 +122,17 @@ androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "
118122
codelocator-core = "com.bytedance.tools.codelocator:codelocator-core:2.0.3"
119123
google-ksp-plugin = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" }
120124
google-ksp-api = { module = "com.google.devtools.ksp:symbol-processing-api", version.ref = "ksp" }
121-
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
122-
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
123125
androidx-lifecycle-extensions = { module = "androidx.lifecycle:lifecycle-extensions", version.ref = "lifecycleExtensions" }
124126
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "lifecycleExtensions" }
125127
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "lifecycleExtensions" }
128+
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
129+
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleRuntimeKtx" }
130+
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" }
131+
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinxCoroutines" }
126132
material = "com.google.android.material:material:1.12.0"
127133
accompanist-permissions = "com.google.accompanist:accompanist-permissions:0.32.0"
128134
multidex = { module = "com.android.support:multidex", version.ref = "multidex" }
135+
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
129136
smartrefreshheader = { module = "com.scwang.smartrefresh:SmartRefreshHeader", version.ref = "smartrefresh" }
130137
smartrefreshlayout = { module = "com.scwang.smartrefresh:SmartRefreshLayout", version.ref = "smartrefresh" }
131138

@@ -144,5 +151,4 @@ androidx-test-ext-junitkt = "androidx.test.ext:junit-ktx:1.2.1"
144151
androidx-test-ext-truth = "androidx.test.ext:truth:1.6.0"
145152
#To use android test orchestrator
146153
androidx-test-orchestrator = "androidx.test:orchestrator:1.5.0"
147-
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
148-
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
154+
junit = { group = "junit", name = "junit", version.ref = "junit" }

0 commit comments

Comments
 (0)