Skip to content

Commit 1732edd

Browse files
pavelzemanclaude
andauthored
Add Kotlin unit test infrastructure and CircleCI step (#159)
* chore: add Kotlin unit test dependencies to build.gradle Add JUnit 4, Mockito, and OkHttp MockWebServer as test dependencies. These are needed to run the existing ExponentialRetryInterceptorTest and future interceptor tests. Co-authored-by: Claude <claude@anthropic.com> * chore: add Kotlin unit test infrastructure and CI step - Add JUnit 4, Mockito, and OkHttp MockWebServer to android/build.gradle test dependencies - Add standalone test-runner project with Gradle wrapper for running Kotlin unit tests independently of the React Native build - Add kotlin-tests job to CircleCI using cimg/android executor - Add smoke test to verify the test infrastructure works - Wire kotlin-tests into the build workflow as a gate for build-package This enables TDD for Android interceptor code without requiring a full React Native app build. Co-authored-by: Claude <claude@anthropic.com> * fix: wrap MockWebServer and Response in use{} blocks in SmokeTest Address CodeRabbit review: prevent resource leaks if assertions fail by using Kotlin's use{} for automatic cleanup of MockWebServer and Response objects. Co-authored-by: Claude <claude@anthropic.com> --------- Co-authored-by: Claude <claude@anthropic.com>
1 parent dd42247 commit 1732edd

File tree

9 files changed

+427
-0
lines changed

9 files changed

+427
-0
lines changed

.circleci/config.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ executors:
55
docker:
66
- image: circleci/node:14
77
working_directory: ~/project
8+
android:
9+
docker:
10+
- image: cimg/android:2024.01
11+
working_directory: ~/project
812

913
commands:
1014
attach_project:
@@ -62,6 +66,21 @@ jobs:
6266
path: coverage
6367
destination: coverage
6468

69+
kotlin-tests:
70+
executor: android
71+
steps:
72+
- checkout
73+
- run:
74+
name: Run Kotlin unit tests
75+
command: |
76+
cd test-runner
77+
./gradlew test
78+
- store_test_results:
79+
path: test-runner/build/test-results
80+
- store_artifacts:
81+
path: test-runner/build/reports/tests
82+
destination: kotlin-test-reports
83+
6584
build-package:
6685
executor: default
6786
steps:
@@ -105,12 +124,14 @@ workflows:
105124
- unit-tests:
106125
requires:
107126
- install-dependencies
127+
- kotlin-tests
108128
- build-package:
109129
requires:
110130
- install-dependencies
111131
- lint
112132
- typescript
113133
- unit-tests
134+
- kotlin-tests
114135
- release:
115136
context: mattermost-rn-libraries
116137
requires:

android/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,8 @@ dependencies {
6565
implementation "com.squareup.okhttp3:okhttp-tls:4.12.0"
6666
implementation "com.squareup.okhttp3:okhttp-urlconnection:4.12.0"
6767
implementation "androidx.datastore:datastore-preferences:1.1.1"
68+
69+
testImplementation "junit:junit:4.13.2"
70+
testImplementation "org.mockito:mockito-core:5.11.0"
71+
testImplementation "com.squareup.okhttp3:mockwebserver:4.12.0"
6872
}

test-runner/build.gradle.kts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
kotlin("jvm") version "1.9.22"
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
11+
testImplementation("junit:junit:4.13.2")
12+
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
13+
}
14+
15+
sourceSets {
16+
test {
17+
kotlin {
18+
srcDir("src/test/kotlin")
19+
}
20+
}
21+
}
42.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

test-runner/gradlew

Lines changed: 249 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)