Use string resources with testFixtures in Android Studio

Viewed 11

testFixtures have been introduced since AGP 7.0.

I have enabled the following in my build.gradle:

    testFixtures  {
        enable = true
        androidResources = true
    }

    testOptions {
        unitTests.includeAndroidResources = true
    }

In my local unit tests I can reference strings resources (strings in strings.xml) placed in the main source set, but I can't access those placed my testFixtures source set.

Placing string resources under the src/testFixtures/res folder, shows them on Android Studio just fine. But I can't reference them via R.string.string_name either on code found in the testFixture source path or the test source path.

I think that the appt is not picking them up.

Any solutions?

0 Answers
Related