Skip to content

feat(health-sdk): Add smoke UI test case for Health SDK and Bank app …#893

Open
saranyanataraja wants to merge 1 commit intomainfrom
HEAL-143-Android-Health-SDK-Smoke-UI-Test-Suite
Open

feat(health-sdk): Add smoke UI test case for Health SDK and Bank app …#893
saranyanataraja wants to merge 1 commit intomainfrom
HEAL-143-Android-Health-SDK-Smoke-UI-Test-Suite

Conversation

@saranyanataraja
Copy link
Copy Markdown

This pull request introduces a comprehensive suite for UI test automation in the Health SDK example app, focusing on end-to-end payment flows involving both the Health and Bank example apps. The changes enable robust cross-app testing by integrating UiAutomator and Espresso, establishing Page Object Models for key screens, and automating the installation of the Bank app before tests run.

UI test infrastructure and automation:

  • Added Page Object Model classes for MainScreen, InvoicesScreen, PaymentReviewScreen, and BankScreen to encapsulate UI interactions and assertions for each screen, supporting hybrid Espresso + UiAutomator flows. (health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/MainScreen.kt, InvoicesScreen.kt, PaymentReviewScreen.kt, BankScreen.kt) [1] [2] [3] [4]
  • Introduced a central TestData object for all test constants and expected values, improving maintainability and clarity across test cases. (health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/testdata/TestData.kt)

Cross-app test support and dependencies:

  • Automated installation of the Bank SDK example app before running UI tests, ensuring the payment intent can be resolved and the Bank app is present on the device/emulator. (health-sdk/example-app/build.gradle.kts)
  • Added androidx.test.espresso.contrib and androidx.test.uiautomator dependencies to support advanced UI interactions and cross-app automation. (gradle/libs.versions.toml, health-sdk/example-app/build.gradle.kts) [1] [2]…integration - from invoices list

HEAL-143

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'Android Core API Library'

Failed conditions
2 Security Hotspots

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'Android Capture SDK'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sonarqubecloud
Copy link
Copy Markdown

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'Android Bank SDK'

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)
1 New Bugs (required ≤ 0)
6 New Critical Issues (required ≤ 0)
41 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an end-to-end UI smoke test flow for the Health SDK example app, including cross-app verification against the Bank SDK example app using a hybrid Espresso + UiAutomator approach.

Changes:

  • Added a new SmokeTestHealth instrumented test that drives the “invoice list → payment review → launch bank app → return” flow.
  • Introduced Page Object Model (POM) page classes (MainScreen, InvoicesScreen, PaymentReviewScreen, BankScreen) plus centralized TestData.
  • Updated build configuration to include needed Android test dependencies and to install the Bank SDK example app before connected UI tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/uitest/SmokeTestHealth.kt New smoke test orchestrating the full cross-app payment flow
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/testdata/TestData.kt Centralized constants for invoice/bank/app package test data
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/PaymentReviewScreen.kt POM interactions/assertions for payment review and pay actions
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/MainScreen.kt POM interaction to enter invoices list flow
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/InvoicesScreen.kt POM interactions for loading invoices and selecting an invoice to pay
health-sdk/example-app/src/androidTest/java/net/gini/android/health/sdk/exampleapp/test/pages/BankScreen.kt UiAutomator-based verification and return flow inside the bank app
health-sdk/example-app/build.gradle.kts Adds test deps + installs bank app prior to connectedAndroidTest
gradle/libs.versions.toml Adds Espresso contrib dependency entry

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +60
// Tap "Continue to overview" button
onView(withText("Continue to overview"))
Comment on lines +69 to +76
/**
* Taps the "Pay" button on the payment overview screen to launch the bank app.
* The button is identified by [net.gini.android.internal.payment.R.id.gps_pay_button].
*/
fun tapPayButton(): PaymentReviewScreen {
onView(
allOf(
withId(net.gini.android.internal.payment.R.id.payment),
Comment on lines +60 to +77
override fun perform(uiController: UiController, view: View) {
val recyclerView = view as RecyclerView
val adapter = recyclerView.adapter
?: throw PerformException.Builder()
.withActionDescription(description)
.withViewDescription("RecyclerView has no adapter")
.build()

// Find the adapter position of the item matching recipientName
var targetPosition = -1
for (pos in 0 until adapter.itemCount) {
recyclerView.post {
(recyclerView.layoutManager as? LinearLayoutManager)
?.scrollToPositionWithOffset(pos, 0)
}
uiController.loopMainThreadUntilIdle()
Thread.sleep(100)
uiController.loopMainThreadUntilIdle()
Comment on lines +58 to +61
device.wait(
Until.hasObject(By.pkg(TestData.AppPackages.BANK_SDK_EXAMPLE_APP).depth(0)),
LAUNCH_TIMEOUT_MS
)
Comment on lines +121 to +142
device.findObject(
By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "resolve_payment")
)?.click()

// Wait for "Return to Business" button — confirms payment was processed
device.wait(
Until.findObject(
By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "return_to_payment_initiator_app")
),
FIELD_TIMEOUT_MS
)

// Tap it — triggers deep-link back to Health app
device.findObject(
By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "return_to_payment_initiator_app")
)?.click()

// Wait for the Health app to return to the foreground — Espresso takes over from here
device.wait(
Until.hasObject(By.pkg(TestData.AppPackages.HEALTH_SDK_EXAMPLE_APP).depth(0)),
LAUNCH_TIMEOUT_MS
)
Comment on lines +87 to +103
val actualIban = device
.findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "iban"))
?.text ?: ""
println("✅ Bank App IBAN: $actualIban")
assertEquals("IBAN mismatch in bank app", expectedIban, actualIban)

// Verify Amount
val actualAmount = device
.findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "amount"))
?.text ?: ""
println("✅ Bank App Amount: $actualAmount")
assertEquals("Amount mismatch in bank app", expectedAmount, actualAmount)

// Verify Purpose
val actualPurpose = device
.findObject(By.res(TestData.AppPackages.BANK_SDK_EXAMPLE_APP, "purpose"))
?.text ?: ""
Comment on lines +24 to +26
/** Expected extracted amount on the payment review screen. */
const val AMOUNT = "18,23"
const val AMOUNT1 = "18.23"
Copy link
Copy Markdown
Contributor

@MozhganPeivandianSharbaf MozhganPeivandianSharbaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @saranyanataraja 💯 , Please resolve copilet comments and remove emojis from code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants