integrate androidTests

This commit is contained in:
Milos Kozak 2023-10-20 18:32:29 +02:00
parent d9eeb09e30
commit 5e28accfc9
8 changed files with 42 additions and 21 deletions

View file

@ -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

View file

@ -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 */

View file

@ -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<Test> {
@ -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"
}
}
}

View file

@ -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<Test> {
@ -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"
}
}
}

View file

@ -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)
}

View file

@ -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()
}

View file

@ -8,8 +8,8 @@ plugins {
}
android {
namespace = "info.nightscout.androidaps.plugins.pump.omnipod.eros"
defaultConfig {
kapt {
arguments {

View file

@ -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<Context>()
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()
}