@@ -10,6 +10,7 @@ import de.mannodermaus.gradle.plugins.junit5.util.assertAll
10
10
import de.mannodermaus.gradle.plugins.junit5.util.evaluate
11
11
import de.mannodermaus.gradle.plugins.junit5.util.get
12
12
import de.mannodermaus.gradle.plugins.junit5.util.getDependentTaskNames
13
+ import org.gradle.testing.jacoco.tasks.JacocoReport
13
14
import org.junit.jupiter.api.DynamicTest
14
15
import org.junit.jupiter.api.DynamicTest.dynamicTest
15
16
import org.junit.jupiter.api.Test
@@ -29,12 +30,55 @@ interface AgpJacocoVariantTests : AgpVariantAwareTests {
29
30
project.evaluate()
30
31
31
32
assertWithMessage(" create a child task" )
32
- .that(project.tasks.findByName(" ${JACOCO_TASK_NAME } Staging" ))
33
- .isNotNull()
33
+ .that(project.tasks.findByName(" ${JACOCO_TASK_NAME } Staging" ))
34
+ .isNotNull()
34
35
35
36
assertWithMessage(" connect to parent task" )
36
- .that(project.tasks.getByName(JACOCO_TASK_NAME ).getDependentTaskNames())
37
- .contains(" ${JACOCO_TASK_NAME } Staging" )
37
+ .that(project.tasks.getByName(JACOCO_TASK_NAME ).getDependentTaskNames())
38
+ .contains(" ${JACOCO_TASK_NAME } Staging" )
39
+ }
40
+
41
+ @TestFactory
42
+ fun `do not interfere if task generation is disabled` () = forEachBuildType(
43
+ beforeBuild = {
44
+ it.applyJacocoPlugin()
45
+ },
46
+ beforeEvaluate = {
47
+ it.junitPlatform.jacocoOptions {
48
+ taskGenerationEnabled = false
49
+ }
50
+ }
51
+ ) { project, buildType ->
52
+ val name = jacocoVariantTaskName(buildType)
53
+
54
+ assertWithMessage(" do not create a child task for build type $buildType " )
55
+ .that(project.tasks.findByName(name))
56
+ .isNull()
57
+ }
58
+
59
+ @TestFactory
60
+ fun `do not interfere with custom Jacoco task if task generation is disabled` () = forEachBuildType(
61
+ beforeBuild = {
62
+ it.applyJacocoPlugin()
63
+ },
64
+ beforeEvaluate = {
65
+ it.tasks.register(" jacocoTestReport" , JacocoReport ::class .java) { task ->
66
+ task.group = " TEST MARKER"
67
+ }
68
+ it.junitPlatform.jacocoOptions {
69
+ taskGenerationEnabled = false
70
+ }
71
+ }
72
+ ) { project, buildType ->
73
+ val name = jacocoVariantTaskName(buildType)
74
+
75
+ assertWithMessage(" do not create a child task for build type $buildType " )
76
+ .that(project.tasks.findByName(name))
77
+ .isNull()
78
+
79
+ assertWithMessage(" do not overwrite the custom task" )
80
+ .that(project.tasks.getByName(" jacocoTestReport" ).group)
81
+ .isEqualTo(" TEST MARKER" )
38
82
}
39
83
40
84
@TestFactory
0 commit comments