louiscad
10/27/2019, 9:32 AMandroidTest
(which maps to AGP test
is seems, but I sadly don't know how).
I'm mentioning you because I know you worked on AGP integration, and I digged so deep without a real solution that I don't know who else could help me on that one.Kris Wong
10/27/2019, 2:51 PMlouiscad
10/27/2019, 5:14 PMDebugUnitTest
and ReleaseUnitTest
in their name so I can focus on things that matter for the project.ankushg
10/27/2019, 8:17 PMandroidTest
for Android unit tests (so it's similar to the other platforms) and create an androidInstrumentationTest
sourceset for Espresso/Android Framework tessSebastian Sellmair [JB]
10/27/2019, 8:39 PMandroidAndroidTest
sourceSet not working for you guys? I just have issues starting those from the ide, but running those Android tests from gradlew with ./gradlew connectedAndroidTest
just works fine for me!louiscad
10/28/2019, 7:10 AMcommonTest
, and it gets run as local Android unit tests, while I want it as instrumented test.Sebastian Sellmair [JB]
10/28/2019, 7:25 AMh0tk3y
10/28/2019, 1:05 PMcommonTest
are compiled and run as both Android unit tests and Android instrumented tests. This may actually be not the right way, and we'll reconsider this and maybe leave only one opiton. In unit tests, you could exclude all the tests from your commonTest
by specifying an exclude
patterrn.src/androidTest/kotlin
, we have a nasty naming clash here that we are going to fix. Basically, src/androidTest/kotlin
sources are the unit test sources, because the Android test
source set gets a Kotlin source set counterpart with the name prefixed with the target name, androidTest
. Similarly, the androidTest
source set gets the Kotlin counterpart androidAndroidTest
with the Kotlin sources in src/androidAndroidTest/kotlin
.Kris Wong
10/28/2019, 1:23 PMandroidInstrumentedTest
makes the most sense to meSebastian Sellmair [JB]
10/28/2019, 1:26 PMlouiscad
10/28/2019, 3:40 PMexclude
pattern? Or do you know where I should look for documentation regarding that?h0tk3y
10/28/2019, 3:56 PMtasks.withType(Test).all {
exclude 'com/h0tk3y/androidtestinginvestigation/common/**'
}
The string I passed to exclude '...'
is the package name prefix with dots replaced by slashes. This excludes test classes that are found under paths that match the pattern. The Android unit test tasks are just normal Gradle Test
tasks, which are documented here: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.htmllouiscad
10/28/2019, 4:14 PMclass
files from an intermediate directory that lost the fact that the file is coming from a common
source set or not, so I would need to hardcode it for each file, which is clearly not scalable for a 40+ modules project.tasks.withType<Test>().matching { "UnitTest" in it.name }.all {
this.exclude {
println("got: $it")
false
}
}
h0tk3y
10/28/2019, 4:17 PMlouiscad
10/28/2019, 4:20 PMh0tk3y
10/28/2019, 4:25 PMcommonTest
tests as unit tests only or instrumented tests only.src/androidTest/kotlin
sources. For example, use JUnit Assume
in your tests' superclass @BeforeAll
method and check that the marker class which is only present in the unit tests is not loaded. Doesn't look pretty, but it may work until KT-34662 is done.expect
function in commonTest
and providing an implementation that finishes a test as ignored in the Android unit tests.louiscad
10/28/2019, 5:00 PMyou could disable the unit tests tasks altogetherYes, that's what I'm currently doing:
tasks.whenTaskAdded {
if("DebugUnitTest" in name || "ReleaseUnitTest" in name) {
enabled = false // [Some comment linking to this Slack thread]
}
}
assume(someExpression)
in a @BeforeAll
function is a great idea!