question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jetpack compose support

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Reactions:6
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

10reactions
mannodermauscommented, Dec 19, 2020

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 the ComposeTestRule works. In a nutshell, you’d have to convert its content to JUnit 5 extension points such as BeforeEachCallback and AfterEachCallback.

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. 🙏

7reactions
mannodermauscommented, Jul 28, 2021

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. 🎉🎉

Screen Shot 2021-07-28 at 20 45 33
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found