realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

RealmTransformer doesn't execute when running androidTest #7715

Open danika opened 1 year ago

danika commented 1 year ago

How frequently does the bug occur?

All the time

Description

In order to avoid duplicating fake test data across test and androidTest, I have created a module sharedtestcode which depends on app. I then consume sharedtestcode as a test dependency of the app module via testImplementation and androidTestImplementation.

This is the recommended way to share test data starting from Android Studio Chipmunk. (see: https://issuetracker.google.com/issues/232420188)

This seems to work fine when running unit tests, but when I attempt to run an android test, I get:

RealmTransformer doesn't seem to be applied. Please update the project configuration to use the Realm Gradle plugin.

Stacktrace & log output

No response

Can you reproduce the bug?

Yes, always

Reproduction Steps

Demo project: https://github.com/danika/RealmSharedTest

Version

10.11.1

What SDK flavour are you using?

Local Database only

Are you using encryption?

No, not using encryption

Platform OS and version(s)

Android (SDK 31)

Build environment

Android Studio version: Chipmunk 2021.2.1 Patch 2 Android Build Tools version: 7.2.2 Gradle version: 7.3.3

rorbech commented 1 year ago

Hi @danika. Thanks for the report. This seems like a duplicate of https://github.com/realm/realm-java/pull/3030 that originates from an issue around which classes that are passed to our transformer. The currently used transforer API of AGP has been undergoing development and will be removed from AGP 8.0, so the original reported issue is left as obsolete. We are currently in the process of migrating to the new API in #7714 (specifically also applying the transformer on unittest and test components) and with this we should hopefully also address this

danika commented 1 year ago

hello again, I've updated the realm dependency in my demo project to 10.13.1-transformer-api and the problem persists :(

codyrotwein commented 1 year ago

same issue for me.

danika commented 1 year ago

I can confirm that the issue is fixed with the following combo:

AGP 8.0.0 Kotlin 1.8.20 Realm 10.15.0

thanks!