-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Android Support #96
Comments
No ETA yet, we are in the process of finishing and stabilizing detox for iOS. Android will follow. |
@rotemmiz any specific tool detox would depend on like espresso ? |
The plan is to use espresso, yes |
@rotemmiz is there a rough implementation plan ? would you consider accepting pull requests helping to get android support working faster ? |
There's a plan indeed. I think it will be best if I write a bit about our roadmap in the documentation. In a nutshell, we want to use a similar architecture as the one we implemented on iOS:
|
And of course, we love PRs :) |
for future reference: I managed to make this almost work, look here Although I gave up on this when trying to test application lifecycle, as Espresso runs as part of the app under test's process, so stopping one will stop the other. |
I'm a bit afraid of trusting uiautomator , I had experience with it in MagnetoTesting, and it was flaky, we had to pet our UI tests constantly. |
if you look at the current tests in https://github.com/wix/react-native-navigation/tree/v2/AndroidE2E/app/src/androidTest/java/com/reactnativenavigation/e2e/androide2e you'll see there's zero flakiness, it's just a little different kind of thinking than espresso |
also its worth noting that uiAutomator lets you interact with stuff outside the app. |
Hey, I plan to work on 2. and 3. from @rotemmiz 's list. Is anyone else working on this? Few notes:
|
Which one of the following would be preferred?
The 2. option adds another dependency, might not cover everything, but on the upside is already tested. I would prefer 1. at the moment, but really don't mind. |
@rotemmiz - can you elaborate on this please?
|
@talarari What I did for iOS was to strategically swizzle RN methods so that I could react to what is happening for internal logic, such as starting a timer or the JS thread runloop. Method swizzling is the process of replacing a method implementation at runtime. Since Objective C is dynamic, there is a great flexibility regarding this. Java does not allow method swizzling, so it would be much more difficult to implement a similar approach. |
Some approaches exist by hot-patching the vtable: http://vaioco.github.io/art/art-part-ii-hooking |
Thanks for the references @LeoNatan, I like where this is going :) @talarari , @simonracz , I will post our roadmap for detox soon, along with how we thought about implementing support for Android. |
Just to keep the ball rolling. I have a proof of concept code for a custom Android test runner. It is actually a subclass of MonitoringInstrumentation. It gets the detoxServer and detoxSessionId arguments from cmd line (or from Gradle settings). Can be started like It opens a websocket to the detox server, logins to it and then starts listening to commands. From this point it can call, .e.g Espresso methods using reflection as it has the permission to poke the app in any way it wants. Some open problems for me:
|
Great news. Looking fwd to a follow up! |
@simonracz this is great!! can you please share the code ? regarding your points:
|
@rotemmiz I'll upload the code tomorrow morning.
I am staring at the AndroidJUnitRunner code for half an hour now and can't remember why I made the conclusion that it can't be subclassed for this purpose. So, please ignore my earlier comment about that. |
One thing that goes for the custom test runner is that that is the only way to run code before Application#onCreate(). |
I've uploaded the code here. |
Regarding point 3: |
I delved deep into RN's Android port while keeping in mind Detox's iOS support. At first, I thought of using Espresso's internal QueueInterrogator class for idle detection. It would work fine, as while RN's core classes both have Java and mirror C++ parts, threading is done in a JVM aware style, only in the Java layer. The four relevant MessageQueues to be observed can be found here. The Loopers could be caught through the ReactContext for them. This is a valid approach, but I've found a better one. RN's Android port seems to be more mature than the iOS port. They have a vertically implemented addBridgeIdleDebugListener function in CatalystInstance. They also have an idle detection utility that is based on this here. The waitForBridgeAndUIIdle method could be used by Detox. This still needs to be wrapped for Espresso, but that's not an issue. The only thing that is missing, is that it does not monitor the Timers the same way as Detox does. It just waits 2 frames of Choreographer, then marks it idle. (Choreographer is similar to CADisplayLink on iOS.) However, the timers are orthogonal to this. Waiting for the Timers "the Detox way", could be done by getting hold of the mTimers variable using reflection, and checking whether it's empty or not. So, there is no need to attach to method calls, like on iOS. I'll work on a proof of concept code and will check the idle detection manually with Detox's test. I'll share the code afterwards. Any feedback is welcome. |
Hey @simonracz, please check your Twitter ;) |
Adding to the discussion; I wonder if there will be an issue in providing full android test support without testID being available within android? 🤔 |
BTW, the long discussion about |
Hey, @itsmepetrov Test ids are transformed to view tags on Android. Espresso can use view tags. UIAutomator can't. I think tags will be okay for most of the cases. |
@AlanFoster You can find an RN view with |
This should enable other users to use android more easily as the current status configuration can be quite confusing. Build with the help of @AppsThatMatter Relates to #96
This should enable other users to use android more easily as the current status configuration can be quite confusing. Build with the help of @AppsThatMatter Relates to #96
This should enable other users to use android more easily as the current status configuration can be quite confusing. Build with the help of @AppsThatMatter Relates to #96
I'm going through the problem below when running the tests. My Settings (package.json)
Test (firsTest.spec.js)
Command executed:
Result "after all" hook: Any suggestion? |
Hey @vocampos , Could you please run an Please share those lines with me. Cheers |
The Example usage detox test -c android.emu.debug --debug-synchronization 500 This is the first tool you should consult, in case your tests are extremely slow or even timeouts. It reports back the busy |
I ran the command according to its orientation, but it did not work. When analyzing the adb logs, I have the below error:
Any suggestion? Thank you |
The error is happening for detox.init not finished.
|
Hey @vocampos Thanks for the extra info. You just hit an error of the type I've just noticed that you use RN 0.41.2. We never tested the Android version below 0.44.0. So, any bad thing could happen there. That's my current guess. If you can reproduce it with later RN versions too, please let me know. Regardless of that, I'll take a look whether I can support 0.41.2 too. |
How to match by type on android? |
For Textinput you probably have to search by My guess is that the full classname was the missing part for you. Let me know if it still doesn’t work. |
Is Genymotion supported atm? |
@simonracz hey, I have the same issue with running detox on Android. We got it working in iOS.
I tried to look for stuff in the adb logcat, but didn't see any error with “XY is busy” like you mentioned. Do you have any idea what might be the problem? Thanks! |
Hey @ilonashub , It's hard to guess what went wrong. Few random things, I would check.
I think it would be best to open a seperate issue, and please attach a chunk of Simon |
@simonracz thanks. Probably I can make it a pull request. |
I m having a hard time getting detox working with Android, it can't connect with the Emulator. Is there a more detailed android Get Started where it goes step by step how to configure? |
Not yet, they will be out when Android support gets ironed out. We are currently working on that. |
do we have an estimated date?
…On Thu, Nov 16, 2017 at 11:49 AM, Rotem Mizrachi-Meidan < ***@***.***> wrote:
Not yet, they will be out when Android support gets ironed out. We are
currently working on that.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#96 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ATQZ0sWz6aQPSnVBDut4I7UqFL9Pr69Aks5s3JG7gaJpZM4MVY4e>
.
--
*Ion Pinzari*
QA Automation Engineer | SkySlope
t: 916-225-6318 e: ipinzari93@gmail.com <ipinzari93@gmail.com> | w:
SkySlope.com <http://www.skyslope.com/>
|
It's an ongoing open source project effort. Android support is usable, and will continue to get better as we put lots of efforts in it. You are welcome to open a specific issue with exact information regarding your errors, it might help us pinpoint issues we didn't yet find. There will never be "estimate dates", especially to vague goals ! |
Anyone got Detox + Jest working on Android with Well I have moved from Genymotion to Android Studio 3 and it helped... |
I'm also having issues setting it up for Android (using detox 7). When I run detox it uploads and starts the app, but then it hangs on the first, white screen (app is not responding)... |
Android support is already pretty mature now, I suggest any problem will be handled in a separate issue. Closing this issue. |
Is there any ETA for android support as react-native apps support both iOS and android
The text was updated successfully, but these errors were encountered: