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

Burst 2.0 - Parameterized Android Tests #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

handstandsam
Copy link
Owner

@handstandsam handstandsam commented Oct 31, 2024

I wanted to try out Burst 2.0 for Parameterized Android Tests.

Despite IDE support issues, the underlying library works 😄 .

Here are my observations:

It Works on Android! 🎉

https://github.com/google/TestParameterInjector also works, but this is special because it's not determining the tests to run via the JUnit Runner itself at runtime, but while the code is being compiled. This means we have deterministic test permutations generated and existing in the bytecode vs it being computed at test runner initialization time.

Because of this different method, computing all android tests to be run can be done via static analysis of the APK by tools like https://github.com/linkedin/dex-test-parser which computes a full list of methods from an APK. This also means that it will work in Firebase Test Lab and other sharding by method runners. Related Issue of TestParameterInjector -> google/TestParameterInjector#27 to allow that functionality.

Screenshot 2024-10-31 at 9 42 33 AM

Kotlin Compiler Plugin

The new test methods are never Kotlin Source Code, but go straight into the Kotlin Compiler's FIR model and then into the compiled Java Classes. While this is not unique to newer Kotlin Compiler Plugins, it's different from other KSP and KAPT annotation processing methods that end up generating source files that THEN get fed to the Kotlin Compiler. Because of that, you have to look at the compiled class files and don't have an intermediate source file to look at. This makes the compilation process MUCH faster by avoiding disk writes, avoiding different phases, and just doing everything within the compiler. The downside is knowing what's really going on under the hood.

Screenshot 2024-10-31 at 9 39 48 AM Screenshot 2024-10-31 at 9 39 26 AM

Required Dependencies

It brings in Kotlin 2.0.21.

Run Android Test IDE Issue

The option to run the test was there in the IDE even with the "red" highlighting. However, when the test was run it failed in the IDE. It DOES work when running the tests via the commandline with `./gradlew :app:connectedDebugAndroidTest", so it's definitely an IDE support issue.

Screenshot 2024-10-31 at 9 36 37 AM Screenshot 2024-10-31 at 9 37 07 AM

IDE Highlighting Issues

This method of "code" (IR) generation inside the compiler doesn't seem to be something totally supported yet. I am using the latest stable version of Intellij IDEA and tried it with both K2 mode ON and OFF with the same result.

Screenshot 2024-10-31 at 9 53 27 AM Screenshot 2024-10-31 at 9 36 14 AM Screenshot 2024-10-31 at 9 36 04 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant