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

FakeStorage unresolved reference on TestStorageModule #78

Open
reisfernanda opened this issue Oct 31, 2023 · 2 comments
Open

FakeStorage unresolved reference on TestStorageModule #78

reisfernanda opened this issue Oct 31, 2023 · 2 comments

Comments

@reisfernanda
Copy link

reisfernanda commented Oct 31, 2023

TestStorageModule from androidTest shows an unresolved reference error for FakeStorage on the solution branch, even though the instrumented tests run successfully.
FakeStorage is located at the sharedTest package, and this package is shared with tests through sourceSets, but it looks like sharing code this way is not supported anymore, according to this comment on Google Issue Tracker.

sourceSets {
        String sharedTestDir = 'src/sharedTest/java'
        test {
            java.srcDir sharedTestDir
        }
        androidTest {
            java.srcDir sharedTestDir
        }

    }

A suggestion found on the same comment on Google Issue Tracker is to create a new module with the code that needs to be shared and add it as a dependency for testImplementation and androidTestImplementation.

testImplementation project(path: ':shared-test')
androidTestImplementation project(path: ':shared-test') 

Android Studio version:

Android Studio Giraffe | 2022.3.1 Patch 2
Build #AI-223.8836.35.2231.10811636, built on September 14, 2023
@amazingvoice
Copy link

Still impacted by this issue in:
Android Studio Jellyfish | 2023.3.1 Patch 2
Build #AI-233.14808.21.2331.11926650, built on June 4, 2024

I did some research about sharing code between test and androidTest folder and got the same solution as yours. Thanks for posting this : )

@amazingvoice
Copy link

@manuelvicnt Please check the solution to this issue. Thanks.

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

No branches or pull requests

2 participants