Skip to content

IDE-314: Stabilize and optimize sensor list tests with Robolectric integration test#5200

Open
harshsomankar123-tech wants to merge 1 commit into
Catrobat:developfrom
harshsomankar123-tech:feature/IDE-314-optimize-sensor-list-test
Open

IDE-314: Stabilize and optimize sensor list tests with Robolectric integration test#5200
harshsomankar123-tech wants to merge 1 commit into
Catrobat:developfrom
harshsomankar123-tech:feature/IDE-314-optimize-sensor-list-test

Conversation

@harshsomankar123-tech
Copy link
Copy Markdown
Member

@harshsomankar123-tech harshsomankar123-tech commented Apr 18, 2026

Description

Jira Ticket: IDE-314 (https://catrobat.atlassian.net/browse/IDE-314)

This PR overhauls the FormulaEditorSensorList testing strategy. We replaced the slow, flakey Espresso verification with a comprehensive Robolectric integration test that successfully validates the content and ordering of all 160+ sensor items across 16 different categories.

Key Changes

  • New Integration Test: Added FormulaEditorSensorListIntegrationTest.kt (Robolectric).
    • Verifies the entire sensor list (headers, item names, and ordering) in under 3 seconds.
    • Implemented reflection-based mocking for SensorHandler to simulate 100% hardware availability (Accelerometer, Compass, etc.) in a headless environment.
    • Handled Koin-injected dependencies to resolve previous NullPointerException issues.
  • Espresso Optimization: Refactored FormulaEditorSensorListTest.kt.
    • Slimmed down from hundreds of data-heavy assertions to 8 high-value interaction tests.
    • Focuses on UI behavior (opening/closing the list, search filtering) rather than exhaustive raw data checks.
  • Architecture Stabilization:
    • Synchronized ProjectManager and SensorHandler singletons between the test runner and the application context.
    • Simplified test setup using AppCompatActivity as a lightweight context provider.

Verification Plan

  • Robolectric Integration: Ran ./gradlew testCatroidDebugUnitTest --tests "*FormulaEditorSensorListIntegrationTest*" (Passed).
  • Espresso Smoke Tests: Ran ./gradlew connectedCatroidDebugAndroidTest --tests "*FormulaEditorSensorListTest*" (Passed).
  • Edge Cases: Verified that AI-specific sensors (Pose Detection, Object Recognition) and connectivity-based sensors (Drone, Cast) are correctly populated when their respective settings are enabled.

Performance Impact

Metric Before (Espresso Only) After (Hybrid Strategy)
Runtime ~5-8 mins (flaky) ~3s (Robolectric) + ~30s (Espresso)
Coverage Partial verification 100% data parity verification

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

@harshsomankar123-tech harshsomankar123-tech force-pushed the feature/IDE-314-optimize-sensor-list-test branch from 0b93373 to 5687b6d Compare April 18, 2026 23:39
@harshsomankar123-tech harshsomankar123-tech force-pushed the feature/IDE-314-optimize-sensor-list-test branch from 5687b6d to 45b0b49 Compare April 18, 2026 23:39
@sonarqubecloud
Copy link
Copy Markdown

@harshsomankar123-tech harshsomankar123-tech added the Active Member Tickets that are assigned to members that are still currently active label Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Active Member Tickets that are assigned to members that are still currently active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants