mirror of
https://github.com/oxen-io/session-android.git
synced 2025-08-12 13:37:56 +00:00
Initial CI setup test
Added code coverage report generation (for future CI stuff) Fixed a flaky unit test
This commit is contained in:
@@ -124,6 +124,7 @@ android {
|
||||
debug {
|
||||
isDefault true
|
||||
minifyEnabled false
|
||||
enableUnitTestCoverage true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,6 +202,27 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task testPlayDebugUnitTestCoverageReport(type: JacocoReport, dependsOn: "testPlayDebugUnitTest") {
|
||||
reports {
|
||||
xml.enabled = true
|
||||
}
|
||||
|
||||
// Add files that should not be listed in the report (e.g. generated Files from dagger)
|
||||
def fileFilter = []
|
||||
def mainSrc = "$projectDir/src/main/java"
|
||||
def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/playDebug", excludes: fileFilter)
|
||||
|
||||
// Compiled Kotlin class files are written into build-variant-specific subdirectories of 'build/tmp/kotlin-classes'.
|
||||
classDirectories.from = files([kotlinDebugTree])
|
||||
|
||||
// To produce an accurate report, the bytecode is mapped back to the original source code.
|
||||
sourceDirectories.from = files([mainSrc])
|
||||
|
||||
// Execution data generated when running the tests against classes instrumented by the JaCoCo agent.
|
||||
// This is enabled with 'enableUnitTestCoverage' in the 'debug' build type.
|
||||
executionData.from = "${project.buildDir}/outputs/unit_test_code_coverage/playDebugUnitTest/testPlayDebugUnitTest.exec"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@@ -10,12 +10,14 @@ import org.hamcrest.CoreMatchers.nullValue
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.anyLong
|
||||
import org.mockito.Mockito.anySet
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.mock
|
||||
import org.mockito.kotlin.whenever
|
||||
import org.mockito.verification.VerificationMode
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.BaseViewModelTest
|
||||
import org.thoughtcrime.securesms.database.Storage
|
||||
@@ -49,7 +51,8 @@ class ConversationViewModelTest: BaseViewModelTest() {
|
||||
|
||||
viewModel.saveDraft(draft)
|
||||
|
||||
verify(repository).saveDraft(threadId, draft)
|
||||
// The above is an async process to wait 100ms to give it a chance to complete
|
||||
verify(repository, Mockito.timeout(100).times(1)).saveDraft(threadId, draft)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user