I'm upgrading to `AGP 9` from 8 .. are `testRelea...
# gradle
u
I'm upgrading to
AGP 9
from 8 .. are
testReleaseUnitTest
now gone?
Copy code
./gradlew :app:testReleaseUnitTest
Calculating task graph as no cached configuration is available for tasks: :app:testReleaseUnitTest

FAILURE: Build failed with an exception.

* What went wrong:
Cannot locate tasks that match ':app:testReleaseUnitTest' as task 'testReleaseUnitTest' not found in project ':app'.
it's not in
check
as well .. and this is a plain hello world app Am I doing it wrong? Or is it obsolete now?
m
AGP 9.0.0 only creates the unit test task for the tested build type by default. You can either set the
android.onlyEnableUnitTestForTheTestedBuildType
property to
false
, or set the
testBuildType
to
release
. See https://developer.android.com/build/releases/agp-9-0-0-release-notes
u
What does "tested" build type mean? Is there some sort of currently selected build type state?
I thought I select the build type by qualifying the test task I'm executing
Okay it works thank you! But, could you ellaborate a bit? this is new info to me - I don't necessarily have
release
specific unit tests, and to be frank I dont really know how does build type come into play for unit tests, it's not like it's running the obfucasted release variant, as this is jvm, right?
Am I leaving some perf on the table by
android.onlyEnableUnitTestForTheTestedBuildType=false
?
m
AGP used to create all the variations of
test<variant>UnitTest
. With AGP 9.0 it only creates one task, matching the variant defined by
testBuildType
. As far your other questions/remarks, I don't have enough knowledge to answer you properly
e
I can guess the Google intention - the want to make smaller configuration times since registering all these tasks takes time. I can guess majority of projects (at least on google side) don’t have specific functionality differences to Release build variant. So they consider the result of running unit tests for release is same as for debug. Therefore they removed release unit test tasks. And as pointed above - you can still override and come back to having release unit tests tasks creation.
u
I see its just my instinct seeing debug task in release build I guess 😀 But, what does even release unit test mean? Is it just about source sets?
e
Yeah source sets and everything custom you define in grade related to build type.
Maybe also some compiler flags
I'm not super sure except sources
u
I still find it odd, as then its unqualified really, nor debug not release
But I see thanks!
🙌🏼 1
d
Would be nice if they could also make it match on one flavour now it still creates
test<flavor>DebugUnitTest
for each flavor/dimension combination
262 Views