@@ -50,32 +50,47 @@ val e2eBackendEnv = System.getenv("E2E_BACKEND") ?: "local"
5050val e2eHomegateUrlEnv = System .getenv(" E2E_HOMEGATE_URL" ) ? : " http://127.0.0.1:6288"
5151val trezorBridgeEnv = System .getenv(" TREZOR_BRIDGE" )?.toBoolean()?.toString() ? : " false"
5252val trezorBridgeUrlEnv = System .getenv(" TREZOR_BRIDGE_URL" ) ? : " http://10.0.2.2:21325"
53- val coreServiceIntegrationTestAnnotation = " to.bitkit.test.annotations.CoreServiceIntegrationTest"
54- val composeUiTestAnnotation = " to.bitkit.test.annotations.ComposeUiTest"
55- val deviceIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceIntegrationTest"
56- val deviceStorageIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceStorageIntegrationTest"
57- val deviceUiIntegrationTestAnnotation = " to.bitkit.test.annotations.DeviceUiIntegrationTest"
58- val requestedTaskNames = gradle.startParameter.taskNames.map { it.substringAfterLast(" :" ) }
59- val bitkitAndroidTestSuite = providers.gradleProperty(" bitkitAndroidTestSuite" ).orNull
60- val bitkitAndroidTestAnnotation = when {
61- requestedTaskNames.any { it == " connectedDevDebugComposeAndroidTest" } -> composeUiTestAnnotation
62- requestedTaskNames.any { it == " connectedDevDebugCoreServiceIntegrationAndroidTest" } -> {
63- coreServiceIntegrationTestAnnotation
53+ val androidTestAnnotationPackage = " to.bitkit.test.annotations"
54+ val androidTestAnnotationSuffix = " AndroidTest"
55+ val androidTestTaskPrefix = " connectedDevDebug"
56+ val androidTestTaskSuffix = " AndroidTest"
57+ val androidTestAnnotationNames = file(" src/androidTest/java/to/bitkit/test/annotations" )
58+ .listFiles()
59+ ?.mapNotNull { file ->
60+ file.nameWithoutExtension.takeIf {
61+ file.isFile &&
62+ file.extension == " kt" &&
63+ it.endsWith(androidTestAnnotationSuffix)
64+ }
6465 }
65- requestedTaskNames.any { it == " connectedDevDebugDeviceStorageIntegrationAndroidTest" } -> {
66- deviceStorageIntegrationTestAnnotation
66+ ?.sorted()
67+ .orEmpty()
68+ val requestedTaskNames = gradle.startParameter.taskNames.map { it.substringAfterLast(" :" ) }
69+
70+ fun androidTestTaskName (annotationName : String ): String {
71+ val taskInfix = annotationName.removeSuffix(androidTestAnnotationSuffix)
72+ return " $androidTestTaskPrefix$taskInfix$androidTestTaskSuffix "
73+ }
74+
75+ val requestedAndroidTestAnnotation = providers.gradleProperty(" bitkitAndroidTestAnnotation" )
76+ .orNull
77+ ?.trim()
78+ ?.takeIf { it.isNotEmpty() }
79+ ?.also {
80+ require(' .' !in it) {
81+ " Use a simple Android test annotation name, e.g. 'DeviceUiIntegrationAndroidTest'."
82+ }
83+ require(it in androidTestAnnotationNames) {
84+ " Unsupported bitkitAndroidTestAnnotation '$it '. Supported annotations: " +
85+ androidTestAnnotationNames.joinToString(" , " )
86+ }
6787 }
68- requestedTaskNames.any { it == " connectedDevDebugDeviceUiIntegrationAndroidTest" } -> {
69- deviceUiIntegrationTestAnnotation
88+ val bitkitAndroidTestAnnotationName = requestedAndroidTestAnnotation
89+ ? : requestedTaskNames.firstNotNullOfOrNull { taskName ->
90+ androidTestAnnotationNames.firstOrNull { androidTestTaskName(it) == taskName }
7091 }
71- requestedTaskNames.any { it == " connectedDevDebugDeviceIntegrationAndroidTest" } -> deviceIntegrationTestAnnotation
72- bitkitAndroidTestSuite == " compose" -> composeUiTestAnnotation
73- bitkitAndroidTestSuite == " core-service" -> coreServiceIntegrationTestAnnotation
74- bitkitAndroidTestSuite == " device-storage" -> deviceStorageIntegrationTestAnnotation
75- bitkitAndroidTestSuite == " device-ui" -> deviceUiIntegrationTestAnnotation
76- bitkitAndroidTestSuite == " integration" -> deviceIntegrationTestAnnotation
77- bitkitAndroidTestSuite == null -> null
78- else -> error(" Unsupported bitkitAndroidTestSuite '$bitkitAndroidTestSuite '" )
92+ val bitkitAndroidTestAnnotation = bitkitAndroidTestAnnotationName?.let {
93+ " $androidTestAnnotationPackage .$it "
7994}
8095
8196android {
@@ -397,34 +412,12 @@ tasks.withType<Test>().configureEach {
397412 jvmArgs(" -XX:+EnableDynamicAgentLoading" )
398413}
399414
400- tasks.register(" connectedDevDebugComposeAndroidTest" ) {
401- group = " verification"
402- description = " Runs devDebug Android tests annotated as Compose UI tests."
403- dependsOn(" connectedDevDebugAndroidTest" )
404- }
405-
406- tasks.register(" connectedDevDebugDeviceIntegrationAndroidTest" ) {
407- group = " verification"
408- description = " Runs devDebug Android tests annotated as device integration tests."
409- dependsOn(" connectedDevDebugAndroidTest" )
410- }
411-
412- tasks.register(" connectedDevDebugCoreServiceIntegrationAndroidTest" ) {
413- group = " verification"
414- description = " Runs devDebug Android tests annotated as core service integration tests."
415- dependsOn(" connectedDevDebugAndroidTest" )
416- }
417-
418- tasks.register(" connectedDevDebugDeviceStorageIntegrationAndroidTest" ) {
419- group = " verification"
420- description = " Runs devDebug Android tests annotated as device storage integration tests."
421- dependsOn(" connectedDevDebugAndroidTest" )
422- }
423-
424- tasks.register(" connectedDevDebugDeviceUiIntegrationAndroidTest" ) {
425- group = " verification"
426- description = " Runs devDebug Android tests annotated as device UI integration tests."
427- dependsOn(" connectedDevDebugAndroidTest" )
415+ androidTestAnnotationNames.forEach { annotationName ->
416+ tasks.register(androidTestTaskName(annotationName)) {
417+ group = " verification"
418+ description = " Runs devDebug Android tests annotated with '$annotationName '."
419+ dependsOn(" connectedDevDebugAndroidTest" )
420+ }
428421}
429422
430423// endregion
0 commit comments