Skip to content

Commit

Permalink
Test with robolectric
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Dec 25, 2023
1 parent 1ceefd9 commit cba46a7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 49 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,38 +78,3 @@ jobs:
- run: cp lazythreetenbp/build/outputs/aar/lazythreetenbp-release.aar diffuse-source-file-release
if: github.event_name != 'pull_request'
shell: bash

ui-test:
runs-on: macos-latest
strategy:
matrix:
apiVersion: [ 23, 28, 30, 31, 34 ]
fail-fast: false

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21

- uses: gradle/gradle-build-action@v2

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.apiVersion }}
profile: pixel_xl
target: google_apis
arch: x86_64
disable-spellchecker: true
script: ./gradlew connectedCheck

- name: Upload tests result
uses: actions/upload-artifact@v4
with:
name: "test-results [${{ matrix.apiVersion }}]"
path: "${{ github.workspace }}/**/reports/**"
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ commonConfig {
allprojects {
tasks.withType(KotlinCompile).configureEach {
compilerOptions {
apiVersion = KotlinVersion.KOTLIN_1_5
languageVersion = KotlinVersion.KOTLIN_1_5
apiVersion = KotlinVersion.KOTLIN_1_6
languageVersion = KotlinVersion.KOTLIN_1_6
}
}
pluginManager.withPlugin("kotlin") {
Expand Down
8 changes: 3 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
[versions]
gradle-starter = "0.67.0"
gradle-starter = "0.68.0"
gradle-doctor = "0.9.1"
google-annotation = "1.7.1"
google-androidtest = "1.5.2"
google-androidtestext = "1.1.5"
maven-threetenbp = "1.6.8"
maven-junit = "4.13.2"
maven-truth = "1.2.0"
maven-ticktock = "1.2.0-2021e"
maven-binarycompatiblity = "0.13.2"
maven-robolectric = "4.11.1"

[libraries]
starter-android = { module = "com.project.starter:android", version.ref = "gradle-starter" }
ticktock-compiler = { module = "dev.zacsweers.ticktock:ticktock-compiler", version.ref = "maven-ticktock" }
annotation-core = { module = "androidx.annotation:annotation", version.ref = "google-annotation" }
threetenbp-core = { module = "org.threeten:threetenbp", version.ref = "maven-threetenbp" }
junit-core = { module = "junit:junit", version.ref = "maven-junit" }
robolectric-core = { module = "org.robolectric:robolectric", version.ref = "maven-robolectric" }
truth-core = { module = "com.google.truth:truth", version.ref = "maven-truth" }
androidtest-runner = { module = "androidx.test:runner", version.ref = "google-androidtest" }
androidtest-junitext = { module = "androidx.test.ext:junit-ktx", version.ref = "google-androidtestext" }

[plugins]
starter-library-android = { id = "com.starter.library.android", version.ref = "gradle-starter" }
Expand Down
13 changes: 8 additions & 5 deletions lazythreetenbp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ android {
checkReleaseBuilds false
disable += "UseTomlInstead"
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}

androidComponents {
Expand Down Expand Up @@ -61,9 +66,7 @@ dependencies {
// noinspection UseTomlInstead
implementation("org.threeten:threetenbp:1.6.8:no-tzdb")

androidTestImplementation libs.annotation.core
androidTestImplementation libs.junit.core
androidTestImplementation libs.truth.core
androidTestImplementation libs.androidtest.runner
androidTestImplementation libs.androidtest.junitext
testImplementation libs.junit.core
testImplementation libs.robolectric.core
testImplementation libs.truth.core
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.usefulness.threetenbp

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.threeten.bp.zone.ZoneRulesProvider

@RunWith(AndroidJUnit4::class)
@Config(sdk = [23, 28, 30, 31, 34])
@RunWith(RobolectricTestRunner::class)
internal class AndroidThreeTenTest {

private val context = InstrumentationRegistry.getInstrumentation().context
Expand Down

0 comments on commit cba46a7

Please sign in to comment.