Skip to content

Commit

Permalink
WIP Kotlin unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ovitrif committed Mar 24, 2024
1 parent 94b0741 commit f91d4ab
Show file tree
Hide file tree
Showing 14 changed files with 1,109 additions and 203 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/unit-tests-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: unit-tests-android

on:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'

jobs:
tests-android:
name: Android Unit Tests
runs-on: macos-14 # m1 mac
# runs-on: ubuntu-latest # Uncomment to run locally via act

steps:
- uses: actions/checkout@v3

- name: Use Node 18
uses: actions/setup-node@v3
with:
node-version: 18

# Uncomment to run workflow locally via act
# - name: Install yarn
# run: npm install -g yarn

- name: Install node_modules
working-directory: example
run: yarn install && yarn rn-setup

- name: Use JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
architecture: x64
distribution: 'zulu'

- name: Use Android SDK
uses: android-actions/setup-android@v2

- name: Run Android unit tests
run: ./gradlew testDebugUnitTest --stacktrace --no-daemon
working-directory: lib/android
2 changes: 2 additions & 0 deletions lib/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
dist
src/protos
example
ios/*
android/*
1 change: 1 addition & 0 deletions lib/android/.java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
zulu64-11.0.22
15 changes: 13 additions & 2 deletions lib/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ buildscript {
google()
mavenCentral()
jcenter()
maven { url = uri("https://plugins.gradle.org/m2/") }
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath("com.android.tools.build:gradle:7.1.3")
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath("com.adarshr:gradle-test-logger-plugin:2.0.0")
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'org.jetbrains.kotlin.android'
apply plugin: "com.adarshr.test-logger"

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Ldk_' + name]
Expand Down Expand Up @@ -128,4 +131,12 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// implementation files('libs/ldk-java-javadoc.jar') // Used to get code completion in Kotlin but won't compile with it
compileOnly files('libs/LDK-release.aar')

// Unit testing dependencies
testImplementation project(':')
testImplementation files('libs/ldk-java.jar') // Needs jvm11 aarch64 for tests with LDK references
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito.kotlin:mockito-kotlin:3.2.0")
testImplementation("org.robolectric:robolectric:4.7.3")
}
3 changes: 2 additions & 1 deletion lib/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Ldk_kotlinVersion=1.6.10
Ldk_kotlinVersion=1.8.20
Ldk_compileSdkVersion=29
Ldk_targetSdkVersion=29
android.useAndroidX=true
Binary file modified lib/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit f91d4ab

Please sign in to comment.