Add Android instrumented tests to the app module#110829
Add Android instrumented tests to the app module#110829Repiteo merged 2 commits intogodotengine:masterfrom
app module#110829Conversation
|
@syntaxerror247 To complete the integration, we'll need to set up the CI to automatically run the integrated tests. Can you look into what it'd take to make this happen. This blogpost seems like a good reference to start with: https://medium.com/@peterkagure/running-instrumented-tests-on-github-actions-with-firebase-test-lab-ac17bb36ae9c |
d7d0b14 to
0a1c8fe
Compare
0a1c8fe to
9c20665
Compare
There was a problem hiding this comment.
@m4gr3d I just noticed that there's errors in Logcat while running the instrumented tests, and it seems the tests aren’t running.
Error1: App doesn't auto-launch; I have to launch it manually from launcher.
Error2:
ERROR: Couldn't load file 'res://project.binary', error code 19.
at: _load_settings_text_or_binary (core/config/project_settings.cpp:920)
Error3:
ERROR: Variant is too deep! Bailing.
at: _variant_to_jvalue (platform/android/jni_utils.cpp:93)
GDScript backtrace (most recent call first):
[0] test_variant_conversion_safe_from_stack_overflow (res://test/javaclasswrapper/java_class_wrapper_tests.gd:136)
[1] __exec_test (res://test/base_test.gd:12)
[2] run_tests (res://test/javaclasswrapper/java_class_wrapper_tests.gd:17)
[3] _launch_tests (res://main.gd:22)
I'm running with ./gradlew connectedInstrumentedDebugAndroidTest -Pperform_signing=true
Also tried with Android Studio but same errors.
9c20665 to
a68d36f
Compare
I checked out the branch on a new machine, and I'm able to run and replicate the test results, so it may be an issue with how you ran the tests. I've updated the description with some instructions for how to run from Android Studio. Can you give it a try and see if that works.
That's expected. A Godot project can either be loaded from
Also expected. The failing condition is the test crashing with a stack overflow error as described here.
|
Already tried with Android Studio as well, followed the same steps, but the app doesn’t auto-launch. The test run is stuck until I manually open the app, after which it proceeds and completes.
|
|
Tested with an emulator, it works as expected there. Seems like the issue is with my device then :/ |
a68d36f to
85169e0
Compare
f76f318 to
0e48703
Compare
platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt
Outdated
Show resolved
Hide resolved
platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt
Outdated
Show resolved
Hide resolved
platform/android/java/app/src/main/java/com/godot/game/GodotApp.java
Outdated
Show resolved
Hide resolved
…to match the default configuration Both the `app` and `lib` modules had custom source sets configuration originating from the early days of the project. This updates the configuration to match the default Android Studio configuration which will simplify the addition of unit tests and instrumented tests to the project. Note that for backcompat reasons, some folders (such as the `res` folder in the `app` module) are left as is.
This builds on the work from @dsnopek in https://github.com/dsnopek/javaclasswrapper-test, by importing the set of JavaClassWrapper tests from that repo within the Godot core repo in order to bootstrap and standardize how we write and run Android instrumented tests. The approach used here should serve as a base to build upon to expand the set of instrumented tests used to validate the project's stability. Co-authored-by: David Snopek <dsnopek@gmail.com>
0e48703 to
16bdc8c
Compare
|
Thanks! |

This PR adds an initial set of instrumented tests to the Godot
appmodule which should help us improve stability of the engine and detect regressions.To do so, the PR is split into two commits (note: I recommend reviewing each commit by themselves):
The first commit updates the project layout for both the
appandlibmodules in order to align with the default Android Studio project layout. Doing so allow us to more easily set up, use and contribute to instrumented tests for the project. While the commit looks large, it mostly consists of moving files around, and doesn't contain much logical changes except where updates to project paths were needed.The second commit sets up the instrumented tests folder layout and build config for the
appmodule. A newinstrumentedproduct flavor is created which defines a custom Godot project and custom test plugins that are launched when running instrumented tests. The Godot project and test plugins are imported from @dsnopek https://github.com/dsnopek/javaclasswrapper-test repo, and theJavaClassWrappertests it contains make up the initial set of instrumented tests. To run the instrumented tests from Android Studio, follow these instructions:appmodule to one of theinstrumentedflavor. Can beinstrumentedDebug,instrumentedDevorinstrumentedRelease.GodotAppTesttest file (underplatform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt)Run GodotAppTest