Skip to content

Commit 395b237

Browse files
authored
Merge pull request #19 from RevenueCat/feature/test-store
Add unit test cases for the Test Store and Test products with RevenueCat SDK
2 parents 42d657b + 0f58859 commit 395b237

File tree

14 files changed

+1922
-6
lines changed

14 files changed

+1922
-6
lines changed

.github/workflows/android.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,31 @@ jobs:
2121
- name: spotless
2222
run: ./gradlew spotlessCheck
2323

24+
test:
25+
name: Unit Tests
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Check out code
29+
uses: actions/checkout@v3.1.0
30+
- name: Set up JDK
31+
uses: actions/setup-java@v3.5.1
32+
with:
33+
distribution: zulu
34+
java-version: 17
35+
- uses: gradle/gradle-build-action@v2.7.1
36+
- name: Make Gradle executable
37+
run: chmod +x ./gradlew
38+
- name: Run unit tests
39+
run: ./gradlew testDebugUnitTest --stacktrace
40+
- name: Upload test reports
41+
if: always()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: test-reports
45+
path: |
46+
**/build/reports/tests/
47+
**/build/test-results/
48+
2449
build:
2550
runs-on: ubuntu-latest
2651
steps:

baselineprofile/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ plugins {
2222

2323
android {
2424
namespace = "com.revenuecat.articles.paywall.baselineprofile"
25-
compileSdk = 35
25+
compileSdk = 36
2626

2727
compileOptions {
2828
sourceCompatibility = JavaVersion.VERSION_17
@@ -35,7 +35,7 @@ android {
3535

3636
defaultConfig {
3737
minSdk = 28
38-
targetSdk = 35
38+
targetSdk = 36
3939
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4040
}
4141

build-logic/convention/src/main/kotlin/com/revenuecat/KotlinAndroid.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ internal fun Project.configureKotlinAndroid(
1717
commonExtension: CommonExtension<*, *, *, *, *, *>,
1818
) {
1919
commonExtension.apply {
20-
compileSdk = 35
20+
compileSdk = 36
2121

2222
defaultConfig {
23-
minSdk = 21
23+
minSdk = 24
2424
}
2525

2626
compileOptions {

core/data/build.gradle.kts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,73 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
import java.util.Properties
17+
1618
plugins {
1719
id("revenuecat.android.library")
1820
id("revenuecat.android.hilt")
1921
id("revenuecat.spotless")
2022
}
2123

24+
// Load local.properties
25+
val localProperties = Properties().apply {
26+
val localPropertiesFile = rootProject.file("local.properties")
27+
if (localPropertiesFile.exists()) {
28+
localPropertiesFile.inputStream().use { load(it) }
29+
}
30+
}
31+
2232
android {
2333
namespace = "com.revenuecat.articles.paywall.compose.core.data"
34+
35+
buildFeatures {
36+
buildConfig = true
37+
}
38+
39+
defaultConfig {
40+
// Add RevenueCat Test Store API key to BuildConfig for unit tests
41+
buildConfigField(
42+
"String",
43+
"REVENUECAT_TEST_API_KEY",
44+
"\"${localProperties.getProperty("revenuecat.test.api.key", "")}\""
45+
)
46+
47+
// Set configuration for androidTest
48+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
49+
}
50+
51+
testOptions {
52+
unitTests {
53+
isIncludeAndroidResources = true
54+
}
55+
}
56+
57+
// Exclude hilt-navigation-compose from androidTest to avoid minSdk conflicts
58+
configurations {
59+
getByName("androidTestImplementation") {
60+
exclude(group = "androidx.hilt", module = "hilt-navigation-compose")
61+
}
62+
}
2463
}
2564

2665
dependencies {
2766
api(projects.core.model)
2867
api(projects.core.network)
68+
implementation(libs.androidx.junit.ktx)
69+
70+
// Testing
71+
testImplementation(libs.junit)
72+
testImplementation(libs.mockk)
73+
testImplementation(libs.kotlinx.coroutines.test)
74+
testImplementation(libs.turbine)
75+
testImplementation(libs.revenuecat) // Required for extension functions
76+
77+
// Android Instrumentation Testing (for Test Store integration tests)
78+
androidTestImplementation(libs.junit)
79+
androidTestImplementation(libs.androidx.junit)
80+
androidTestImplementation(libs.androidx.test.runner)
81+
androidTestImplementation(libs.androidx.espresso.core)
82+
androidTestImplementation(libs.kotlinx.coroutines.test)
83+
androidTestImplementation(libs.turbine)
84+
androidTestImplementation(libs.revenuecat) // Required for RevenueCat SDK
2985
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) 2025 RevenueCat, Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
19+
<application>
20+
<!-- Test Activity for RevenueCat Test Store purchase flow tests -->
21+
<activity
22+
android:name="com.revenuecat.articles.paywall.coredata.repository.TestPurchaseActivity"
23+
android:exported="false"
24+
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
25+
</application>
26+
27+
</manifest>

0 commit comments

Comments
 (0)