-
Notifications
You must be signed in to change notification settings - Fork 288
Create Cross-Platform Compose UI Tests #447
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
joreilly
merged 5 commits into
main
from
claude/multiplatform-ui-tests-011CUSYuGiuNEE2C6VpwnhTb
Oct 25, 2025
Merged
Create Cross-Platform Compose UI Tests #447
joreilly
merged 5 commits into
main
from
claude/multiplatform-ui-tests-011CUSYuGiuNEE2C6VpwnhTb
Oct 25, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds comprehensive UI tests for Compose Multiplatform components that can run across Android, iOS, Desktop, and Web platforms. Changes: - Add compose.uiTest dependency to commonTest in build.gradle.kts - Create PeopleInSpaceRepositoryFake for consistent test data - Add ComposeMultiplatformUiTests.kt: Basic UI component tests for CoordinateDisplay - Add ISSPositionUiTests.kt: Tests for ISS position display with realistic data - Add ViewModelUiTests.kt: Advanced tests demonstrating ViewModel integration - Add TestTagExampleTests.kt: Best practices for using test tags in UI tests - Add comprehensive README.md documenting the testing approach and patterns The tests use runComposeUiTest instead of platform-specific createComposeRule, allowing them to run on multiple platforms. They demonstrate: - Testing simple composables and complex UI components - Integration with ViewModels and StateFlow - Test tag usage and best practices - Coroutine test dispatcher management - Data-driven testing patterns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit adds CI/CD workflows to automatically run the Compose Multiplatform
UI tests on pull requests and pushes to main/master branches.
New Workflows:
1. compose-ui-tests.yml (Recommended for fast feedback)
- Runs Compose UI tests on JVM platform
- Executes in ~3 minutes for quick feedback
- Uploads test results as artifacts (7 day retention)
- Publishes detailed test reports with pass/fail info
- Uses Gradle caching for optimal performance
- Includes concurrency control to cancel outdated runs
2. multiplatform-tests.yml (Comprehensive platform coverage)
- Runs tests on all supported platforms:
* JVM (ubuntu-24.04)
* Android (ubuntu-24.04, Robolectric)
* iOS (macos-14, simulator arm64)
* WebAssembly (ubuntu-24.04)
- Includes test summary job aggregating all results
- Uploads platform-specific test result artifacts
- Executes in ~10-15 minutes
3. README.md
- Comprehensive documentation of all workflows
- Guidance on choosing between fast vs comprehensive tests
- Local testing commands and troubleshooting tips
- Best practices for adding new tests
Features:
- Parallel test execution where possible
- Artifact uploads for debugging test failures
- JUnit XML report generation
- Concurrency control to save CI resources
- Gradle caching for faster builds
- Clear test result visualization in PR checks
The workflows automatically run tests from common/src/commonTest including:
- ComposeMultiplatformUiTests.kt
- ISSPositionUiTests.kt
- ViewModelUiTests.kt
- TestTagExampleTests.kt
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Add @OptIn(ExperimentalTestApi::class) annotation to all test classes to suppress "This testing API is experimental and is likely to be changed or removed entirely" warnings. Changes: - Add @OptIn(ExperimentalTestApi::class) to ComposeMultiplatformUiTests - Add @OptIn(ExperimentalTestApi::class) to ISSPositionUiTests - Add @OptIn(ExperimentalTestApi::class) to TestTagExampleTests - Add @OptIn(ExperimentalTestApi::class) to ViewModelUiTests - Update README.md with documentation about the opt-in requirement - Update all code examples in README to include the annotation - Add note explaining why the annotation is needed The annotation is required because the Compose Multiplatform UI testing framework (runComposeUiTest) is currently experimental. This is standard practice when using experimental APIs and does not affect test functionality. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Rewrote ViewModelUiTests to use StateFlow-based testing instead of attempting to instantiate ViewModels directly. The ViewModels in this project use Koin dependency injection and don't accept constructor parameters, which was causing "Too many arguments for constructor" errors. Changes: ViewModelUiTests.kt: - Removed attempts to instantiate ViewModels with repository parameters - Changed to StateFlow-based testing pattern using MutableStateFlow - Added new tests demonstrating state transitions (Loading → Success → Error) - Added test for ISS position state updates - Added tests for all PersonListUiState variants (Loading, Success, Error) - Added test demonstrating state transition from Loading to Success - Updated documentation in comments to explain the testing approach - All test composables now accept StateFlow parameters instead of ViewModels New test coverage: - testISSPositionDisplay_withStateFlow - testISSPositionUpdate_whenStateChanges - testPersonListSuccess_displaysData - testPersonListLoading_displaysLoadingIndicator - testPersonListError_displaysError - testPersonListDisplaysCorrectCount - testPersonListStateTransition_fromLoadingToSuccess README.md: - Updated ViewModelUiTests description to reflect state-based testing - Added new section "Testing State-Based UI Components" - Replaced ViewModel instantiation examples with StateFlow examples - Added explanation of why StateFlow is used instead of actual ViewModels - Updated code examples to show state transition testing - Added note about Koin dependency injection in ViewModels Benefits of this approach: - Tests the UI layer independently of ViewModel implementation - No need to set up complex Koin test modules - More focused on UI behavior rather than ViewModel internals - Easier to test different state scenarios - Demonstrates practical testing patterns for StateFlow-based UIs 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
b6f49c8 to
edec1f2
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.