Skip to content
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

x/mobile: gomobile test #12181

Open
crawshaw opened this issue Aug 18, 2015 · 1 comment
Open

x/mobile: gomobile test #12181

crawshaw opened this issue Aug 18, 2015 · 1 comment
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@crawshaw
Copy link
Member

This may turn into a design for a gomobile test subcommand, but for now I'm writing down some notes on what I've been thinking about this topic, as I have a tendency to forget parts of this story when I switch work.

Current and potential testing systems for app programmers:

All-Go apps:

  • go test runs unit tests on the host. Works today. Fast, portable, and friendly to development.
  • gomobile test same UI as go test but they run on device. Can this be made easy to configure? (Provisioning issues on iOS, app permission issues on Android, or they would run via adb shell which rules out GUI tests.) Is this useful?
  • GUI tests. Right now x/mobile/app/app_test.go has some primitive GUI tests driven by the host. Can these be run on-device as part of gomobile test?

Go libraries used by android apps:

  • go test runs unit tests on the host.
  • gomobile test runs tests on the device. Same discussion as above.
  • Integration tests. As Go is the library, these have to be driven by the primary app environment, Android Studio, Xcode, etc. (For example, x/mobile/bind tests do this with gradle from the Android SDK.)

If we created a gomobile test mode, it would be built out of the go_darwin_arm_exec and go_android_arm_exec scripts used to run unit tests from the standard library. These are tricky to setup (in particular the ios-deploy dependency) and very tricky to debug. It i not clear we could make that easier with the gomobile tool.

So it’s not clear yet that it is worth building gomobile test, but a worthwhile first experiment would be rewriting x/mobile/app/app_test.go to be a unit test running under an .apk. If that is possible, the second step would be to rewrite go_android_arm_exec so that it builds app packages like go_darwin_arm_exec. In some ways it is easier to install and start an app on Android than it is on iOS, but extracting stdio usefully on a device without root (most development devices) is a bit of work.

@crawshaw crawshaw self-assigned this Aug 18, 2015
@sridharv
Copy link

Some user feedback:

For the second case (Go libraries used by apps) I would not recommend having a gomobile test option, based on my personal experience. For Go code used by native code, if a test is not written in the native language it will not exercise the boundary between Go and the native language. If we don't need to exercise this boundary, then a pure go test is sufficient. If not we will need tests written in the native language. There are a number of existing test frameworks which are geared to doing this. They fit well within the development workflow for those languages and I don't see anything gained by adding a third tool. Hope this is useful!

@rsc rsc added this to the Unreleased milestone Oct 23, 2015
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

4 participants