diff --git a/.circleci/config.yml b/.circleci/config.yml index bd2004e921..b66ac53c71 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,8 +25,8 @@ jobs: - android/start-emulator-and-run-tests: system-image: system-images;android-29;google_apis;x86 # Compile while the emulator starts to use the time. - post-emulator-launch-assemble-command: ./gradlew compileFullDebugUnitTestSources database:impl:compileFullDebugAndroidTestSources - test-command: ./gradlew database:impl:connectedFullDebugAndroidTest + post-emulator-launch-assemble-command: ./gradlew compileFullDebugUnitTestSources compileFullDebugAndroidTestSources + test-command: ./gradlew connectedFullDebugAndroidTest - android/run-tests: test-command: ./gradlew testFullDebugUnitTest diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 94fcf31e70..352061a921 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -9,6 +9,7 @@ plugins { id("com.google.gms.google-services") id("com.google.firebase.crashlytics") id("android-app-dependencies") + id("test-app-dependencies") id("jacoco-app-dependencies") } @@ -207,8 +208,6 @@ dependencies { testImplementation(project(":shared:tests")) -// implementation(fileTree (include: listOf("*.jar"), dir = "libs")) - /* Dagger2 - We are going to use dagger.android which includes * support for Activity and fragment injection so we need to include * the following dependencies */ diff --git a/buildSrc/src/main/kotlin/test-app-dependencies.gradle.kts b/buildSrc/src/main/kotlin/test-app-dependencies.gradle.kts index ed3ccac3b6..15db69e88d 100644 --- a/buildSrc/src/main/kotlin/test-app-dependencies.gradle.kts +++ b/buildSrc/src/main/kotlin/test-app-dependencies.gradle.kts @@ -20,7 +20,8 @@ dependencies { androidTestImplementation(Libs.AndroidX.Test.espressoCore) androidTestImplementation(Libs.AndroidX.Test.extKtx) androidTestImplementation(Libs.AndroidX.Test.rules) - //androidTestImplementation(Libs.AndroidX.Test.uiAutomator) + androidTestImplementation(Libs.AndroidX.Test.uiAutomator) + androidTestImplementation(Libs.Google.truth) } tasks.withType { @@ -50,4 +51,12 @@ android { isIncludeAndroidResources = true } } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + excludes += "META-INF/COPYRIGHT" + excludes += "META-INF/LICENSE.md" + excludes += "META-INF/LICENSE-notice.md" + } + } } diff --git a/buildSrc/src/main/kotlin/test-module-dependencies.gradle.kts b/buildSrc/src/main/kotlin/test-module-dependencies.gradle.kts index f3c04f1680..22fc2175b7 100644 --- a/buildSrc/src/main/kotlin/test-module-dependencies.gradle.kts +++ b/buildSrc/src/main/kotlin/test-module-dependencies.gradle.kts @@ -20,7 +20,8 @@ dependencies { androidTestImplementation(Libs.AndroidX.Test.espressoCore) androidTestImplementation(Libs.AndroidX.Test.extKtx) androidTestImplementation(Libs.AndroidX.Test.rules) - //androidTestImplementation(Libs.AndroidX.Test.uiAutomator) + androidTestImplementation(Libs.Google.truth) + androidTestImplementation(Libs.AndroidX.Test.uiAutomator) } tasks.withType { @@ -50,4 +51,12 @@ android { isIncludeAndroidResources = true } } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + excludes += "META-INF/COPYRIGHT" + excludes += "META-INF/LICENSE.md" + excludes += "META-INF/LICENSE-notice.md" + } + } } diff --git a/database/impl/build.gradle.kts b/database/impl/build.gradle.kts index 612b649d93..0a780f1976 100644 --- a/database/impl/build.gradle.kts +++ b/database/impl/build.gradle.kts @@ -40,7 +40,6 @@ dependencies { api(Libs.AndroidX.Room.room) api(Libs.AndroidX.Room.runtime) api(Libs.AndroidX.Room.rxJava3) - kapt(Libs.AndroidX.Room.compiler) api(Libs.Dagger.android) api(Libs.Dagger.androidSupport) @@ -48,4 +47,5 @@ dependencies { androidTestImplementation(Libs.AndroidX.Room.testing) kapt(Libs.Dagger.compiler) + kapt(Libs.AndroidX.Room.compiler) } \ No newline at end of file diff --git a/pump/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt b/pump/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt index 5cb3de649e..f4f8b72415 100644 --- a/pump/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt +++ b/pump/omnipod-dash/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/history/DashHistoryTest.kt @@ -9,8 +9,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.Omnipod import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper +import org.junit.After import org.junit.Before -import org.junit.jupiter.api.Test +import org.junit.Test import org.junit.runner.RunWith @RunWith(AndroidJUnit4::class) @@ -61,7 +62,7 @@ class DashHistoryTest { } } - @org.junit.jupiter.api.AfterEach + @After fun tearDown() { database.close() } diff --git a/pump/omnipod-eros/build.gradle.kts b/pump/omnipod-eros/build.gradle.kts index ddecc8e592..9002b16444 100644 --- a/pump/omnipod-eros/build.gradle.kts +++ b/pump/omnipod-eros/build.gradle.kts @@ -8,8 +8,8 @@ plugins { } android { - namespace = "info.nightscout.androidaps.plugins.pump.omnipod.eros" + defaultConfig { kapt { arguments { diff --git a/pump/omnipod-eros/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/history/ErosHistoryTest.kt b/pump/omnipod-eros/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/history/ErosHistoryTest.kt index d8c0da7cae..ad9235fcdd 100644 --- a/pump/omnipod-eros/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/history/ErosHistoryTest.kt +++ b/pump/omnipod-eros/src/androidTest/java/info/nightscout/androidaps/plugins/pump/omnipod/eros/history/ErosHistoryTest.kt @@ -3,22 +3,25 @@ package info.nightscout.androidaps.plugins.pump.omnipod.eros.history import android.content.Context import androidx.room.Room import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.eros.definition.PodHistoryEntryType import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.eros.history.database.ErosHistoryRecordEntity -import org.junit.Assert.assertNotNull -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +@RunWith(AndroidJUnit4::class) class ErosHistoryTest { private lateinit var dao: ErosHistoryRecordDao private lateinit var database: ErosHistoryDatabase private lateinit var erosHistory: ErosHistory - @BeforeEach + @Before fun setUp() { val context = ApplicationProvider.getApplicationContext() database = Room.inMemoryDatabaseBuilder( @@ -32,7 +35,7 @@ class ErosHistoryTest { @Test fun testInsertionAndRetrieval() { var history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L) - assert(history.isEmpty()) + assertThat(history).isEmpty() val type = PodHistoryEntryType.SET_BOLUS.code.toLong() val entity = ErosHistoryRecordEntity(1000L, type) @@ -40,15 +43,15 @@ class ErosHistoryTest { erosHistory.create(ErosHistoryRecordEntity(3000L, PodHistoryEntryType.CANCEL_BOLUS.code.toLong())) history = erosHistory.getAllErosHistoryRecordsFromTimestamp(0L) - assert(history.size == 2) - assert(type == history.first().podEntryTypeCode) + assertThat(history.size).isEqualTo(2) + assertThat(type).isEqualTo(history.first().podEntryTypeCode) val returnedEntity = erosHistory.findErosHistoryRecordByPumpId(entity.pumpId) - assertNotNull(returnedEntity) - assert(type == returnedEntity?.podEntryTypeCode) + assertThat(returnedEntity).isNotNull() + assertThat(type).isEqualTo(returnedEntity?.podEntryTypeCode) } - @AfterEach + @After fun tearDown() { database.close() }