@@ -48,32 +48,47 @@ val bcp47Locales = listOf(
4848)
4949val e2eBackendEnv = System .getenv(" E2E_BACKEND" ) ? : " local"
5050val e2eHomegateUrlEnv = System .getenv(" E2E_HOMEGATE_URL" ) ? : " http://127.0.0.1:6288"
51- val coreServiceIntegrationTestAnnotation = " to.bitkit.test.annotations.CoreServiceIntegrationTest"
52- val composeUiTestAnnotation = " to.bitkit.test.annotations.ComposeUiTest"
53- val deviceIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceIntegrationTest"
54- val deviceStorageIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceStorageIntegrationTest"
55- val deviceUiIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceUiIntegrationTest"
56- val requestedTaskNames = gradle.startParameter.taskNames.map { it.substringAfterLast(" :" ) }
57- val bitkitAndroidTestSuite = providers.gradleProperty(" bitkitAndroidTestSuite" ).orNull
58- val bitkitAndroidTestAnnotation = when {
59- requestedTaskNames.any { it == " connectedDevDebugComposeAndroidTest" } -> composeUiTestAnnotation
60- requestedTaskNames.any { it == " connectedDevDebugCoreServiceIntegrationAndroidTest" } -> {
61- coreServiceIntegrationTestAnnotation
51+ val androidTestAnnotationPackage = " to.bitkit.test.annotations"
52+ val androidTestAnnotationSuffix = " AndroidTest"
53+ val androidTestTaskPrefix = " connectedDevDebug"
54+ val androidTestTaskSuffix = " AndroidTest"
55+ val androidTestAnnotationNames = file(" src/androidTest/java/to/bitkit/test/annotations" )
56+ .listFiles()
57+ ?.mapNotNull { file ->
58+ file.nameWithoutExtension.takeIf {
59+ file.isFile &&
60+ file.extension == " kt" &&
61+ it.endsWith(androidTestAnnotationSuffix)
62+ }
6263 }
63- requestedTaskNames.any { it == " connectedDevDebugDeviceStorageIntegrationAndroidTest" } -> {
64- deviceStorageIntegrationTestAnnotation
64+ ?.sorted()
65+ .orEmpty()
66+ val requestedTaskNames = gradle.startParameter.taskNames.map { it.substringAfterLast(" :" ) }
67+
68+ fun androidTestTaskName (annotationName : String ): String {
69+ val taskInfix = annotationName.removeSuffix(androidTestAnnotationSuffix)
70+ return " $androidTestTaskPrefix$taskInfix$androidTestTaskSuffix "
71+ }
72+
73+ val requestedAndroidTestAnnotation = providers.gradleProperty(" bitkitAndroidTestAnnotation" )
74+ .orNull
75+ ?.trim()
76+ ?.takeIf { it.isNotEmpty() }
77+ ?.also {
78+ require(' .' !in it) {
79+ " Use a simple Android test annotation name, e.g. 'DeviceUiIntegrationAndroidTest'."
80+ }
81+ require(it in androidTestAnnotationNames) {
82+ " Unsupported bitkitAndroidTestAnnotation '$it '. Supported annotations: " +
83+ androidTestAnnotationNames.joinToString(" , " )
84+ }
6585 }
66- requestedTaskNames.any { it == " connectedDevDebugDeviceUiIntegrationAndroidTest" } -> {
67- deviceUiIntegrationTestAnnotation
86+ val bitkitAndroidTestAnnotationName = requestedAndroidTestAnnotation
87+ ? : requestedTaskNames.firstNotNullOfOrNull { taskName ->
88+ androidTestAnnotationNames.firstOrNull { androidTestTaskName(it) == taskName }
6889 }
69- requestedTaskNames.any { it == " connectedDevDebugDeviceIntegrationAndroidTest" } -> deviceIntegrationTestAnnotation
70- bitkitAndroidTestSuite == " compose" -> composeUiTestAnnotation
71- bitkitAndroidTestSuite == " core-service" -> coreServiceIntegrationTestAnnotation
72- bitkitAndroidTestSuite == " device-storage" -> deviceStorageIntegrationTestAnnotation
73- bitkitAndroidTestSuite == " device-ui" -> deviceUiIntegrationTestAnnotation
74- bitkitAndroidTestSuite == " integration" -> deviceIntegrationTestAnnotation
75- bitkitAndroidTestSuite == null -> null
76- else -> error(" Unsupported bitkitAndroidTestSuite '$bitkitAndroidTestSuite '" )
90+ val bitkitAndroidTestAnnotation = bitkitAndroidTestAnnotationName?.let {
91+ " $androidTestAnnotationPackage .$it "
7792}
7893
7994android {
@@ -393,34 +408,12 @@ tasks.withType<Test>().configureEach {
393408 jvmArgs(" -XX:+EnableDynamicAgentLoading" )
394409}
395410
396- tasks.register(" connectedDevDebugComposeAndroidTest" ) {
397- group = " verification"
398- description = " Runs devDebug Android tests annotated as Compose UI tests."
399- dependsOn(" connectedDevDebugAndroidTest" )
400- }
401-
402- tasks.register(" connectedDevDebugDeviceIntegrationAndroidTest" ) {
403- group = " verification"
404- description = " Runs devDebug Android tests annotated as device integration tests."
405- dependsOn(" connectedDevDebugAndroidTest" )
406- }
407-
408- tasks.register(" connectedDevDebugCoreServiceIntegrationAndroidTest" ) {
409- group = " verification"
410- description = " Runs devDebug Android tests annotated as core service integration tests."
411- dependsOn(" connectedDevDebugAndroidTest" )
412- }
413-
414- tasks.register(" connectedDevDebugDeviceStorageIntegrationAndroidTest" ) {
415- group = " verification"
416- description = " Runs devDebug Android tests annotated as device storage integration tests."
417- dependsOn(" connectedDevDebugAndroidTest" )
418- }
419-
420- tasks.register(" connectedDevDebugDeviceUiIntegrationAndroidTest" ) {
421- group = " verification"
422- description = " Runs devDebug Android tests annotated as device UI integration tests."
423- dependsOn(" connectedDevDebugAndroidTest" )
411+ androidTestAnnotationNames.forEach { annotationName ->
412+ tasks.register(androidTestTaskName(annotationName)) {
413+ group = " verification"
414+ description = " Runs devDebug Android tests annotated with '$annotationName '."
415+ dependsOn(" connectedDevDebugAndroidTest" )
416+ }
424417}
425418
426419// endregion
0 commit comments