I've been capturing screenshots of Compose screens on a headless Linux box with plain Robolectric: @GraphicsMode(NATIVE), createAndroidComposeRule, then drawing the activity's decorView into a Bitmap and writing a PNG. No emulator, and it runs as a normal unit test with Gradle.

It works better than I expected. Text, Material 3 components and tab layouts render correctly, and a full screen takes a few seconds. The rough edges I've hit so far: - I have to drive the main clock manually (autoAdvance = false, then advanceTimeBy) or animations get captured halfway - Fonts look slightly different from a real device - Anything scrolled off screen needs a taller qualifier like w411dp-h1500dp instead of a real scroll capture

For people who've used Paparazzi or Roborazzi: is there a strong reason to switch for simple "render this screen to an image" use, or is plain Robolectric fine when you aren't doing diff-based screenshot testing? And has anyone found a clean way to capture a full scrollable column without a fake tall window?

submitted by /u/ClassKlutzy7633
[link] [comments]