Skip to content

Commit 13ba6e8

Browse files
fix: Resolve CI test failures
- Add android-actions/setup-android@v3 for Android SDK in CI - Use ./gradlew instead of gradle command - Fix MockK 1.13.12 -> 1.13.14 (Kotlin 2.0 compat) - Fix KSP version 2.0.0-1.0.22 -> 2.0.0-1.0.24 - Add junit-platform-launcher runtime dependency - Remove Dispatchers.IO from text encrypt/decrypt ViewModels (testability) - Rewrite ViewModelsTest using runTest only (no manual Dispatchers.setMain) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 44dca15 commit 13ba6e8

6 files changed

Lines changed: 97 additions & 112 deletions

File tree

.github/workflows/android-build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ jobs:
3030
distribution: temurin
3131
java-version: '17'
3232

33+
- name: Setup Android SDK
34+
uses: android-actions/setup-android@v3
35+
3336
- name: Setup Gradle
3437
uses: gradle/actions/setup-gradle@v4
3538
with:
3639
gradle-version: 8.7
3740

3841
- name: Run unit tests
39-
run: gradle testDebugUnitTest
42+
run: ./gradlew testDebugUnitTest
4043

4144
- name: Upload test reports
4245
uses: actions/upload-artifact@v4
@@ -63,13 +66,16 @@ jobs:
6366
distribution: temurin
6467
java-version: '17'
6568

69+
- name: Setup Android SDK
70+
uses: android-actions/setup-android@v3
71+
6672
- name: Setup Gradle
6773
uses: gradle/actions/setup-gradle@v4
6874
with:
6975
gradle-version: 8.7
7076

7177
- name: Assemble debug APK
72-
run: gradle assembleDebug
78+
run: ./gradlew assembleDebug
7379

7480
- name: Upload APK artifact
7581
uses: actions/upload-artifact@v4

android/app/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ dependencies {
8484
implementation(libs.datastore.preferences)
8585

8686
// Testing
87-
testImplementation(libs.junit.jupiter)
87+
testImplementation(libs.junit.jupiter.api)
88+
testRuntimeOnly(libs.junit.jupiter.engine)
89+
testRuntimeOnly(libs.junit.platform.launcher)
8890
testImplementation(libs.mockk)
8991
testImplementation(libs.turbine)
9092
testImplementation(libs.coroutines.test)

android/app/src/main/java/com/example/encryptapp/ui/viewmodel/TextDecryptViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.example.encryptapp.core.crypto.CryptoManager
66
import com.example.encryptapp.core.domain.model.Algorithm
77
import com.example.encryptapp.ui.components.LogEntry
88
import dagger.hilt.android.lifecycle.HiltViewModel
9-
import kotlinx.coroutines.Dispatchers
109
import kotlinx.coroutines.flow.MutableStateFlow
1110
import kotlinx.coroutines.flow.StateFlow
1211
import kotlinx.coroutines.flow.asStateFlow
@@ -39,7 +38,7 @@ class TextDecryptViewModel @Inject constructor(
3938

4039
_state.value = _state.value.copy(isProcessing = true, error = null, result = null)
4140

42-
viewModelScope.launch(Dispatchers.IO) {
41+
viewModelScope.launch {
4342
try {
4443
val decrypted = cryptoManager.decryptText(encryptedText.trim(), password, algorithm)
4544
val entry = LogEntry("Decrypted ($algorithm):\n$decrypted")

android/app/src/main/java/com/example/encryptapp/ui/viewmodel/TextEncryptViewModel.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import com.example.encryptapp.core.crypto.CryptoManager
66
import com.example.encryptapp.core.domain.model.Algorithm
77
import com.example.encryptapp.ui.components.LogEntry
88
import dagger.hilt.android.lifecycle.HiltViewModel
9-
import kotlinx.coroutines.Dispatchers
109
import kotlinx.coroutines.flow.MutableStateFlow
1110
import kotlinx.coroutines.flow.StateFlow
1211
import kotlinx.coroutines.flow.asStateFlow
@@ -39,7 +38,7 @@ class TextEncryptViewModel @Inject constructor(
3938

4039
_state.value = _state.value.copy(isProcessing = true, error = null, result = null)
4140

42-
viewModelScope.launch(Dispatchers.IO) {
41+
viewModelScope.launch {
4342
try {
4443
val encrypted = cryptoManager.encryptText(text.trimEnd(), password, algorithm)
4544
val entry = LogEntry("Encrypted ($algorithm):\n$encrypted")

0 commit comments

Comments
 (0)