X Tutup
Skip to content

Add Android instrumented tests to the app module#110829

Merged
Repiteo merged 2 commits intogodotengine:masterfrom
m4gr3d:javaclasswrapper_regression_tests
Oct 24, 2025
Merged

Add Android instrumented tests to the app module#110829
Repiteo merged 2 commits intogodotengine:masterfrom
m4gr3d:javaclasswrapper_regression_tests

Conversation

@m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Sep 23, 2025

This PR adds an initial set of instrumented tests to the Godot app module 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 app and lib modules 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 app module. A new instrumented product 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 the JavaClassWrapper tests it contains make up the initial set of instrumented tests. To run the instrumented tests from Android Studio, follow these instructions:

    • Set the build variant for the app module to one of the instrumented flavor. Can be instrumentedDebug, instrumentedDev or instrumentedRelease.
    • Open the GodotAppTest test file (under platform/android/java/app/src/androidTestInstrumented/java/com/godot/game/GodotAppTest.kt)
    • Android Studio shows a double play icon next to the class name, click on it and select Run GodotAppTest
    • Note: you should have a connected device or emulator that the test can run on

@m4gr3d m4gr3d added this to the 4.6 milestone Sep 23, 2025
@m4gr3d m4gr3d requested a review from a team as a code owner September 23, 2025 16:50
@m4gr3d m4gr3d requested review from a team as code owners September 23, 2025 16:50
@m4gr3d
Copy link
Contributor Author

m4gr3d commented Sep 23, 2025

@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

@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch 5 times, most recently from d7d0b14 to 0a1c8fe Compare September 28, 2025 16:53
@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch from 0a1c8fe to 9c20665 Compare October 2, 2025 23:30
syntaxerror247

This comment was marked as outdated.

Copy link
Member

@syntaxerror247 syntaxerror247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch from 9c20665 to a68d36f Compare October 13, 2025 00:38
@m4gr3d
Copy link
Contributor Author

m4gr3d commented Oct 13, 2025

@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.

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.

Error2:

ERROR: Couldn't load file 'res://project.binary', error code 19.
    at: _load_settings_text_or_binary (core/config/project_settings.cpp:920)

That's expected. A Godot project can either be loaded from project.godot or project.binary (binary version of the human readable version), but the engine always tries the binary version first, and shows this error when it doesn't find it before falling back to the human readable version.
The instrumented tests use the human readable verison (project.godot, with the project under platform/android/java/app/src/instrumented/assets) so you'll see this error every time they run.

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)

Also expected. The failing condition is the test crashing with a stack overflow error as described here.
The passing condition is the test not crashing and this error being logged.
This test validates the fix added in #110452.

I'm running with ./gradlew connectedInstrumentedDebugAndroidTest -Pperform_signing=true Also tried with Android Studio but same errors.

@syntaxerror247
Copy link
Member

syntaxerror247 commented Oct 13, 2025

@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.

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.

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.

pasted file

@syntaxerror247
Copy link
Member

Tested with an emulator, it works as expected there. Seems like the issue is with my device then :/

@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch from a68d36f to 85169e0 Compare October 21, 2025 16:51
@Repiteo Repiteo requested a review from a team October 21, 2025 19:32
@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch 2 times, most recently from f76f318 to 0e48703 Compare October 22, 2025 01:36
…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>
@m4gr3d m4gr3d force-pushed the javaclasswrapper_regression_tests branch from 0e48703 to 16bdc8c Compare October 24, 2025 14:46
@Repiteo Repiteo merged commit cc008b2 into godotengine:master Oct 24, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 24, 2025

Thanks!

@m4gr3d m4gr3d deleted the javaclasswrapper_regression_tests branch October 24, 2025 23:14
m4gr3d added a commit to m4gr3d/godot that referenced this pull request Dec 1, 2025
ettiSurreal pushed a commit to ettiSurreal/godot that referenced this pull request Dec 1, 2025
AyyZerrAsa pushed a commit to AyyZerrAsa/godot that referenced this pull request Jan 4, 2026
xuhuisheng pushed a commit to xuhuisheng/godot that referenced this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

X Tutup