Test recorder for jetpack compose - android

I want to record a UI test in my jetpack compose project, just like record an Espresso test.
I want to follow thees steps:
start recording
open the application
click on the objects(buttons, etc...)
finish recording
get generated kotlin codes just like Espresso recording
It seems we cannot use Espresso in a jetpackCompose project.
but in this project I didn't completely migrate to JetpackCompose still. but It recognizes it as a Jetpack Compose project

Espresso testing framework cannot be used with Jetpack Compose so test recording is not yet available but Compose tests are fairly easy to write.
You can check the official documentation if this helps: https://developer.android.com/jetpack/compose/testing

Related

Jetpack Compose Playground

is there any online playground for jetpack compose? where I can test and learn jetpack compose. Like https://play.kotlinlang.org
Android studio is not lite. It takes time for setting up projects. Every little practice takes lots of time. If there is an online playground, it will be very help full. Thanks.
While there is no online playground where you can try it in a web browser, there is playground projects that you can clone from Github.
Here's one:
https://github.com/hitherejoe/ComposeAcademy-Playground
You can clone the project, open it and start experimenting with the #Preview annotation or by extending the existing samples.

Building User Interface in Android Studio

I am new to android development using kotlin, I have no problem implementing functions, but i dont know how to go about the UI, does kotlin has a framework for that like flutter or i am to build my UI using XML
Jetpack Compose launched recently which has a declarative approach for building the UI just like flutter. It works with Kotlin.
Check more about it here :) ( you don't need to use XML if you are using Jetpack Compose in your project )

How to test Jetpack Compose?

I use the new Jetpack Compose, now comes time to test UI. Does anyone know the tools for testing it?
Since Espresso mainly relies on view I don't think that it can help.
Android has a code sample (Jetnews) that includes a couple of UI tests. This may help you to set up some tests or in the future, they may add additional code samples around UI testing.
Edit: Link to Jetnews UI Tests
In goo.gle/compose-testing you'll find the official documentation.
Most of the official code samples have UI tests. Apart from the common UI checks in JetNews, you can find animation+screenshot tests in Rally, Interop tests in Crane, screen recreation and navigation tests in Jetchat, etc.

AndroidStudio record Espresso test

I'm trying the new AndroidStudio 2.2 "Record Espresso test" tool.
(Run -> Record Espresso test).
From what I understand this tool records every interaction and convert them to a single test file. What if I need multiple files, one for every activity I'm interacting with? Is this possible?
Is there a way to record only one target activity instead of go through the whole app every time?
Unfortunately there's no mention of this kind of feature in this android blogpost and maybe the feature is no there at all but I couldn't find any information about that.
The blog post just says:
Android Studio will capture all your UI interactions and convert them into a fully reusable Espresso Test that you can run locally or even on Firebase Test lab.
According to:
Android Studio will capture all your UI interactions and convert them
into a fully reusable Espresso Test that you can run locally or even
on Firebase Test lab.
Espresso Test Recorder although it's already added in Android Studio 2.2, it's still pretty experimental feature. Like you said in comment it allows you to record the app workflow, but you cannot record simple activity or fragment. Maybe in the nearest feature it would be added like Android TV support.
What if I need multiple files, one for every activity I'm interacting
with? Is this possible?
The best way would be record app workflow and split them to the classes. Very handful might be learning basics of Espresso code using these documentation: https://google.github.io/android-testing-support-library/docs/espresso/index.html
I think that at this time the best way to write complete UI tests is to learn how to code, recording may help you, but it won't as it pretty naive, do the whole job.
Hope it will help.

Is it possible to test multiple apps with espresso test recorder?

Is it possible to record tests for multiple apps with espresso test recorder or do you need to write code manually for these tests with UiAutomator?
For background, see:
Google's doc on Espresso,
Google's doc on Espresso Test Reorder,
Google's doc on UI Automator, and
Alex Zhukovich's tutorial Android testing: Espresso & UIAutomator together about combining Espresso + UIAutomator to test multiple apps. (Also Alex's previous tutorials on Android unit testing, Mockito & Roboelectric, Espresso, and UIAutomator.)
The pair of tools should work to test an app's notifications, for instance.
But these docs don't discuss using the Espresso Test Recorder for multiple apps. The test recorder is in beta and still developing.
Suggestion: Try using Espresso Test Recorder to record actions and assertions within each app separately, then manually combine the two generated test programs.
Please report back on lessons learned!
Espresso uses current applications context, so it means that you cannot do things like checking sharingIntent, notifications or opening another app.
You can make tests for each of your aplications, then write bash/python script for running them together, but as you think you cannot test multiple apps using single record or 'manual' test case.
I think that UiAtomator can make a thing as this a pure instrumentation testing framework, but I haven't used that yet.
Hope it will help.

Categories

Resources