Jetpack compose support
See original GitHub issueI would like to use junit 5 to test my jetpack compose project.
A compose test rule is required for setting up the UI and using Testing APIs: (documentation)
@get:Rule
val composeTestRule = createAndroidComposeRule<MyActivity>()
This only works for junit 4. Is there any way to use junit 5 with jetpack compose?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Jetpack Compose UI App Development Toolkit
Powerful. Create beautiful apps with direct access to the Android platform APIs and built-in support for Material Design, Dark theme, animations, and more....
Read more >What's new in Jetpack Compose - Android Developers Blog
Our first BOM release, Compose October '22, brings support for Staggered Grids, drawing Text directly to Canvas, Pull to Refresh, as well as ......
Read more >Frequently Asked Questions about Jetpack Compose
Find answers to frequently asked questions about Jetpack Compose! What's the current status of Jetpack Compose?
Read more >Introducing Jetpack Compose Support - PSPDFKit
The Android PDF SDK you know and love now supports Jetpack Compose! ... Unveiling Jetpack Compose support as part of the 8.0 release...
Read more >How to Support All Screen Sizes in Jetpack Compose - YouTube
Supporting all these different types of devices and screens is a tough task for a developer. This video will show you how you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for bringing this up! Unfortunately, test rules are a concept exclusive to JUnit 4 and a new implementation is required to make them work with JUnit 5 (similar to the
ActivityScenario
support we already have). While I have done some work with Jetpack Compose, I haven’t had the chance to look into testing and specifically how theComposeTestRule
works. In a nutshell, you’d have to convert its content to JUnit 5 extension points such asBeforeEachCallback
andAfterEachCallback
.I might consider ramping up a library for Compose support in the near future, once that API stabilizes a little further. Until then, please continue to write your Compose UI tests against the JUnit 4 APIs. If you don’t mind, I’d like to keep this ticket around to keep visibility and gauge interest from people towards this feature. 🙏
I was celebrating the stable release of Jetpack Compose by giving the integration another shot. It’s a very, very simple example but I managed to create a bridge to Compose via the existing JUnit 4 stuff. Feels great to see a
@ParameterizedTest
driving a Composable ❤️There’s still a lot to come and I need many more hours to refine this hacky approach, but I’m quite happy about this. 🎉🎉