-
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
Make detox setup and teardown global #2193
Comments
Thanks for the tutorial btw. The section dedicated to Test Butler here is very unclear on how to actually integrate it in our android app (ie react-native). Few things that I would have liked to know : I. How to add a test runner : II. How to automatically download Test Butler APK III. What to follow from the Test Butler documentation and what from yours
I hope my feedback can help you to improve the documentation in the futur ❤️ |
@d4vidi Regarding the --cleanup arg, when you mention "we've instructed devs to manually apply a killall in scripts, but that doesn't scale.", can you provide an example of this? I'm not entirely sure how to manually kill the detox server |
Hey @badsyntax! You are not required to kill the detox server. Rather, this was referring to the killing of the running emulators. For example, on CI builds that run tests on Android emulators, and immediately thereafter on iOS simulators, you'd wish to clean up the environment before the iOS suite starts running (namely, killing all locally-hosted, currently running Google emulators).
(don't take me up on the exact syntax... you get the gist). |
Thanks for the clarification @d4rky-pl |
Closing in favour of #2894! |
Today, in Jest environments, we initialize Detox from scratch in each and every suite-run from within the context of our circus
Environment
class. As a rule, initialization includes launching emulators/simulators, when needed.This approach creates some drawbacks, as things like prebooting and preconfiguring test emulators, cannot be centrally controlled. We generally want to have Detox init split into two use cases:
Until we introduce this change, the following fixes/enhancements shall remain blocked:
In Test butler app apk #2188, we've created a technical debt where in some cases, util-binary APK's (e.g. test-butler's) cannot overwrite currently installed version of the same APK's, when upgrading them. The reason is that there was no single place to preinstall these APK's, and - so as to avoid reinstalling them again and again in the beginning of each suite (can be painfully time consuming), we instead chose to refrain from installing if the package already exists on the device.
Also in Test butler app apk #2188 (or actually Switch to downloading test-butler APK in jest's global-setup #2194), we've applied a manual resolution of the device type using internal detox API (see https://github.com/wix/Detox/pull/2194/files#diff-a984eb86f26b819ce6f51b8a8fe9226bR4). A preliminary global init, would allow for the device's type to be available at a stage as early as this (e.g. using
device.getPlatform()
).Device cleanup using the
--cleanup
arg isn't properly supported in parallel-execution environments (--cleanup flag fails subsequent tests after first successful suite due to emulator crash #1975 refers to that): instead of tearing down the emulators once when the whole suite ends, it does this in the end of each suite. The runtime penalty here is huge. In internal projects, we've instructed devs to manually apply akillall
in scripts, but that doesn't scale.For the sake of native animations' disabling on Android, we apply the necessary configuration via
adb
in each init, and thus in the beginning of each suite. This is another time-waster, as it should only be done once as part of the global setup.Device launch implementation is overly complex, and cannot be simplified. Since centralized prebooting is not possible, we are forced - at least on Android, at prelaunch, to allocated a unique adb port, outside the recommended range, and run emulators synthetically - preguessing their port-based name (e.g.
emulator-12345
), which is bad practice. A much more simple solution would be to just launch an emulator, having the system allocate its port, and that's that.The text was updated successfully, but these errors were encountered: