When I create a new directory in the src folder, I see test directory options, but I don't see options for creating androidTest directories. I do see androidTest directory options on my other machine on another app. What controls this?
This project has custom buildTypes. Could that be related?
Also, if I create the directory named androidTest, it's not recognized as an androidTest directory.
I have androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.6.1"
I don't think they would, but could it be missing because my company blocks it?
The issue was very difficult to determine but the solution is very simple. I wasn't aware that by default Android Instrumentation Tests are configured to only run on the 'Debug' variant. Since my application doesn't have a 'Debug' variant, resources in the androidTest folder did not appear to be recognized as test resources. By adding the 'testBuildType' setting (below) to my build.gradle:app file, the build variant used for development started recognizing instrumentation tests in the folder.
android {
testBuildType "buildVariantName"
}
In the latest Android Studio (Koala), testBuildType
is not needed for androidTest
to show as a directory type in the dropdown for New Directory.
In one of project's existing modules, I needed to manually add androidTest
(new modules have test
and androidTest
automatically upon creation). All I had to do is
androidTest\java
from the dropdown that pops up:If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With