8000 test: [ANDROAPP-6869] Enable SingleRunnerInvocation by andresmr · Pull Request #4091 · dhis2/dhis2-android-capture-app · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

test: [ANDROAPP-6869] Enable SingleRunnerInvocation #4091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
db86126
test [only test]
Balcan Mar 20, 2025
31bc3bc
test [only test]
Balcan Mar 20, 2025
e426b37
test [only test]
Balcan Mar 20, 2025
b3036d1
test [only test]
Balcan Mar 20, 2025
83ebe38
test [only test]
Balcan Mar 21, 2025
646565f
test [only test]
Balcan Mar 21, 2025
3de2d0b
test [only test]
Balcan Mar 21, 2025
5d190fa
restore workInfoStatus
Balcan Mar 21, 2025
7231f3c
remove ignore
Balcan Mar 27, 2025
78b3048
remove ignore
Balcan Mar 27, 2025
445533a
add ignore
Balcan Mar 27, 2025
65f6fab
remove ProgramEventTest ignores
Balcan Mar 28, 2025
91677cc
restart database
Balcan Mar 28, 2025
96f2534
restart database
Balcan Mar 28, 2025
fc45a6e
add logs
Balcan Mar 28, 2025
6f28f35
test: Ignore shouldDeleteEvent test
andresmr Apr 1, 2025
f492097
test: Remove instrumented log
andresmr Apr 1, 2025
df9a187
test: [ANDROAPP-6869] comment restore database action
andresmr Apr 2, 2025
0f00834
test: [ANDROAPP-6869] launch pin Test
andresmr Apr 2, 2025
5d62e9d
test: [ANDROAPP-6869] uncomment LoginTest
andresmr Apr 3, 2025
6e5df5e
test: [ANDROAPP-6869] Set credentials after LoginTest
andresmr Apr 3, 2025
cd2a89b
test: [ANDROAPP-6869] ignore login flow in LoginTest
andresmr Apr 3, 2025
9586535
test: [ANDROAPP-6869] Review loginFlow
andresmr Apr 4, 2025
40bf877
build: reduce browserstask waiting time
andresmr Apr 4, 2025
c5f3d05
test: [ANDROAPP-6869] remove instrumentation login in AppTest
andresmr Apr 7, 2025
a9b488c
test: [ANDROAPP-6869] remove parallel executions
andresmr Apr 7, 2025
20694f1
test: [ANDROAPP-6869] remove only test
andresmr Apr 7, 2025
f09fc9c
test: [ANDROAPP-6869] change LoginTest order
andresmr Apr 7, 2025
13feaf2
test: [ANDROAPP-6869] change suite order
andresmr Apr 8, 2025
b902a21
test: [ANDROAPP-6869] fix shouldDeleteEvent test
andresmr Apr 8, 2025
99189ab
test: [ANDROAPP-6869] Set counter idling resources when loading the d…
andresmr Apr 9, 2025
e2f78c6
test: [ANDROAPP-6869] fix AndroidIdlingResource
andresmr Apr 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 53 additions & 57 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,66 +86,62 @@ pipeline {
}
}
}
stage('Run tests') {
parallel {
stage('Deploy and run Form Tests') {
environment {
BROWSERSTACK = credentials('android-browserstack')
form_apk = sh(returnStdout: true, script: 'find form/build/outputs -iname "*.apk" | sed -n 1p')
form_apk_path = "${env.WORKSPACE}/${form_apk}"
buildTag = "${env.GIT_BRANCH} - form"
}
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running Form module tests'
sh 'chmod +x browserstackJenkinsForm.sh'
sh './browserstackJenkinsForm.sh'
}
}
}
}
stage('Deploy and Run UI Tests') {
environment {
BROWSERSTACK = credentials('android-browserstack')
app_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/dhis2/debug -iname "*.apk"')
test_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/androidTest -iname "*.apk"')
app_apk_path = "${env.WORKSPACE}/${app_apk}"
test_apk_path = "${env.WORKSPACE}/${test_apk}"
buildTag = "${env.GIT_BRANCH}"
}
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running tests'
sh 'chmod +x browserstackJenkins.sh'
sh './browserstackJenkins.sh'
}
}
}
stage('Run Form Tests') {
environment {
BROWSERSTACK = credentials('android-browserstack')
form_apk = sh(returnStdout: true, script: 'find form/build/outputs -iname "*.apk" | sed -n 1p')
form_apk_path = "${env.WORKSPACE}/${form_apk}"
buildTag = "${env.GIT_BRANCH} - form"
}
stage('Run UI Tests in Landscape') {
when {
expression {
return JOB_NAME.startsWith('android-multibranch-PUSH')
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running Form module tests'
sh 'chmod +x browserstackJenkinsForm.sh'
sh './browserstackJenkinsForm.sh'
}
}
environment {
BROWSERSTACK = credentials('android-browserstack')
app_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/dhis2/debug -iname "*.apk"')
test_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/androidTest -iname "*.apk"')
app_apk_path = "${env.WORKSPACE}/${app_apk}"
test_apk_path = "${env.WORKSPACE}/${test_apk}"
buildTag = "${env.GIT_BRANCH}"
}
}
stage('Run UI Tests in portrait') {
environment {
BROWSERSTACK = credentials('android-browserstack')
app_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/dhis2/debug -iname "*.apk"')
test_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/androidTest -iname "*.apk"')
app_apk_path = "${env.WORKSPACE}/${app_apk}"
test_apk_path = "${env.WORKSPACE}/${test_apk}"
buildTag = "${env.GIT_BRANCH}"
}
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running tests'
sh 'chmod +x browserstackJenkins.sh'
sh './browserstackJenkins.sh'
}
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running tests'
sh 'chmod +x browserstackJenkinsLandscape.sh'
sh './browserstackJenkinsLandscape.sh'
}
}
}
}
}
stage('Run UI Tests in Landscape') {
when {
expression {
return JOB_NAME.startsWith('android-multibranch-PUSH')
}
}
environment {
BROWSERSTACK = credentials('android-browserstack')
app_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/dhis2/debug -iname "*.apk"')
test_apk = sh(returnStdout: true, script: 'find app/build/outputs/apk/androidTest -iname "*.apk"')
app_apk_path = "${env.WORKSPACE}/${app_apk}"
test_apk_path = "${env.WORKSPACE}/${test_apk}"
buildTag = "${env.GIT_BRANCH}"
}
steps {
dir("${env.WORKSPACE}/scripts"){
script {
echo 'Browserstack deployment and running tests'
sh 'chmod +x browserstackJenkinsLandscape.sh'
sh './browserstackJenkinsLandscape.sh'
}
}
}
Expand Down Expand Up @@ -212,4 +208,4 @@ def isSkipSizeCheck() {
def prTitle = env.CHANGE_TITLE ?: ""
def prDescription = env.CHANGE_DESCRIPTION ?: ""
return (prTitle.contains("[skip size]") || prDescription.contains("[skip size]"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,11 @@ internal class DataSetTableViewModel(
fun onSaveClicked() {
viewModelScope.launch {
CoroutineTracker.increment()

val result = withContext(dispatcher.io()) {
checkValidationRulesConfiguration()
}
CoroutineTracker.decrement()

when (result) {
NONE -> {
attemptToFinnish()
Expand All @@ -558,7 +559,6 @@ internal class DataSetTableViewModel(
askRunValidationRules()
}
}
CoroutineTracker.decrement()
}
}

Expand All @@ -577,6 +577,7 @@ internal class DataSetTableViewModel(
it
}
}
CoroutineTracker.decrement()
}
}

Expand Down
9 changes: 8 additions & 1 deletion app/src/androidTest/java/org/dhis2/AppTest.kt
F438
Original file line number Diff line numberDiff line change
Expand Up @@ -10,8 +10,8 @@ import org.dhis2.commons.schedulers.SchedulersProviderImpl
import org.dhis2.data.server.ServerModule
import org.dhis2.data.user.UserModule
import org.dhis2.usescases.BaseTest.Companion.MOCK_SERVER_URL
import org.dhis2.usescases.sync.MockedWorkManagerModule
import org.dhis2.usescases.sync.MockedWorkManagerController
import org.dhis2.usescases.sync.MockedWorkManagerModule
import org.dhis2.utils.analytics.AnalyticsModule
import org.hisp.dhis.android.core.D2Manager
import org.hisp.dhis.android.core.D2Manager.blockingInstantiateD2
Expand All @@ -34,6 +34,13 @@ class AppTest : App() {
}
}

fun restoreDB() {
TestingInjector.provideDBImporter(applicationContext).apply {
copyDatabaseFromAssetsIfNeeded(true)
}
setUpServerComponent()
}

@Override
override fun setUpServerComponent() {
D2Manager.setTestingDatabase(MOCK_SERVER_URL, DB_TO_IMPORT, USERNAME)
Expand Down
5 changes: 3 additions & 2 deletions app/src/androidTest/java/org/dhis2/DBTestLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ import java.io.OutputStream

class DBTestLoader(private val context: Context) {

fun copyDatabaseFromAssetsIfNeeded() {
fun copyDatabaseFromAssetsIfNeeded(force: Boolean = false) {
val databasePath = context.applicationInfo?.dataDir + "/databases"
val file = File("$databasePath/$DB_NAME")

if (file.exists()) {
if (file.exists() and !force) {
Timber.i("Database won't be copy, it already exits")
return
}
try {
Timber.tag("RUNNER_LOG").d("Copying database")
val input = InstrumentationRegistry.getInstrumentation()
.context.assets.open("databases/$DB_NAME_TEST")
val output = FileOutputStream("$databasePath/$DB_NAME")
Expand Down
38 changes: 26 additions & 12 deletions app/src/androidTest/java/org/dhis2/usescases/BaseTest.kt
10000
Original file line numberDiff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ import org.junit.After
import org.junit.Before
import org.junit.ClassRule
import org.junit.Rule
import org.junit.rules.TestName
import org.junit.rules.Timeout
import timber.log.Timber
import java.util.concurrent.TimeUnit


open class BaseTest {

@JvmField
Expand All @@ -55,6 +58,9 @@ open class BaseTest {
@get:Rule
val timeout: Timeout = Timeout(120000, TimeUnit.MILLISECONDS)

@get: Rule
var testName: TestName = TestName()

@get:Rule
var permissionRule = if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
GrantPermissionRule.grant(
Expand All @@ -73,11 +79,28 @@ open class BaseTest {
@Before
@Throws(Exception::class)
open fun setUp() {
val currentTest = testName.methodName
Timber.tag("RUNNER_LOG").d("Executing Before Actions for $currentTest")
(context.applicationContext as AppTest).restoreDB()
injectDependencies()
registerCountingIdlingResource()
setupCredentials()
}

@After
@Throws(Exception::class)
open fun teardown() {
val currentTest = testName.methodName
Timber.tag("RUNNER_LOG").d("Executing After Actions for $currentTest")
closeKeyboard()
disableIntents()
cleanPreferences()
cleanLocalDatabase()
cleanKeystore()
stopMockServer()
unregisterCountingIdlingResource()
}

private fun injectDependencies() {
TestingInjector.apply {
keyStoreRobot = providesKeyStoreRobot(context)
Expand Down Expand Up @@ -119,17 +142,6 @@ open class BaseTest {
mockWebServerRobot.start()
}

@After
@Throws(Exception::class)
open fun teardown() {
closeKeyboard()
disableIntents()
cleanPreferences()
cleanKeystore()
stopMockServer()
unregisterCountingIdlingResource()
}

fun enableIntents() {
if (!isIntentsEnable) {
Intents.init()
Expand Down Expand Up @@ -176,7 +188,9 @@ open class BaseTest {
}

fun cleanLocalDatabase() {
(context.applicationContext as AppTest).deleteDatabase(DB_TO_IMPORT)
val deleted = (context.applicationContext as AppTest).deleteDatabase(DB_TO_IMPORT)
val currentTest = testName.methodName
Timber.tag("RUNNER_LOG").d("CleanDataBaseResult. Is deleted? answer: $deleted for $currentTest")
}

protected fun enableFeatureConfigValue(feature: Feature) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import org.junit.runners.Suite
EnrollmentTest::class,
EventInitialTest::class,
EventTest::class,
LoginTest::class,
MainTest::class,
PinTest::class,
ProgramEventTest::class,
Expand All @@ -33,5 +32,6 @@ import org.junit.runners.Suite
SyncActivityTest::class,
TeiDashboardTest::class,
SchedulingDialogUiTest::class,
LoginTest::class,
)
class UseCaseTestsSuite
Loading
Loading
0