File tree Expand file tree Collapse file tree 3 files changed +38
-7
lines changed
plugin/android-junit5/src
main/kotlin/de/mannodermaus/gradle/plugins/junit5
test/kotlin/de/mannodermaus/gradle/plugins/junit5 Expand file tree Collapse file tree 3 files changed +38
-7
lines changed Original file line number Diff line number Diff line change @@ -455,19 +455,35 @@ class InstrumentationTestOptions {
455455 }
456456
457457 /* *
458- * Whether or not to enable support for JUnit 5 instrumentation tests
458+ * Whether or not to check if the instrumentation tests
459+ * are correctly set up. If this is disabled, the plugin
460+ * won't raise an error during evaluation if the instrumentation
461+ * libraries or the test runner are missing.
459462 */
463+ var integrityCheckEnabled = true
464+
465+ /* *
466+ * Whether or not to check if the instrumentation tests
467+ * are correctly set up. If this is disabled, the plugin
468+ * won't raise an error during evaluation if the instrumentation
469+ * libraries or the test runner are missing.
470+ */
471+ fun integrityCheckEnabled (state : Boolean ) {
472+ this .integrityCheckEnabled = state
473+ }
474+
475+ @Deprecated(message = " This does not do anything anymore and can be safely removed" )
460476 var enabled: Boolean = true
461477
478+ @Deprecated(message = " This does not do anything anymore and can be safely removed" )
462479 fun enabled (state : Boolean ) {
463480 this .enabled = state
464481 }
465482
466- /* *
467- * The version of the instrumentation companion library to use
468- */
483+ @Deprecated(message = " This does not do anything anymore and can be safely removed" )
469484 var version: String? = null
470485
486+ @Deprecated(message = " This does not do anything anymore and can be safely removed" )
471487 fun version (version : String? ) {
472488 this .version = version
473489 }
Original file line number Diff line number Diff line change @@ -81,8 +81,10 @@ class AndroidJUnitPlatformPlugin : Plugin<Project> {
8181 }
8282
8383 private fun Project.configureInstrumentationTests () {
84- // Validate configuration of instrumentation tests.
85- // Both of the following statements must be fulfilled for this to work:
84+ // Validate configuration of instrumentation tests, unless this
85+ // step is deactivated through the DSL.
86+ //
87+ // Normally, both of the following statements must be fulfilled for this to work:
8688 // 1) A special test instrumentation runner argument is applied
8789 // 2) The test runner library is added
8890 val hasRunnerBuilder = android.defaultConfig
@@ -95,7 +97,10 @@ class AndroidJUnitPlatformPlugin : Plugin<Project> {
9597 .dependencies
9698 .any { it.group == INSTRUMENTATION_RUNNER_LIBRARY_GROUP && it.name == INSTRUMENTATION_RUNNER_LIBRARY_ARTIFACT }
9799
98- if (hasRunnerBuilder xor hasDependency) {
100+ val extension = project.android.testOptions.junitPlatform
101+ val checkEnabled = extension.instrumentationTests.integrityCheckEnabled
102+
103+ if (checkEnabled && hasRunnerBuilder xor hasDependency) {
99104 val missingStep = if (hasRunnerBuilder) {
100105 " Add the android-test-runner library to the androidTestRuntimeOnly configuration's dependencies"
101106 } else {
Original file line number Diff line number Diff line change @@ -90,6 +90,11 @@ class PluginSpec : Spek({
9090 { assertThat(expected.cause!!.message).contains("Add the android-test-runner library") }
9191 )
9292 }
93+
94+ it("does actually work when the check is explicitly disabled") {
95+ project.android.testOptions.junitPlatform.instrumentationTests.integrityCheckEnabled = false
96+ project.evaluate()
97+ }
9398 }
9499
95100 on("configuring instrumentation test support only partially (2)") {
@@ -107,6 +112,11 @@ class PluginSpec : Spek({
107112 { assertThat(expected.cause!!.message).contains("Add the JUnit 5 RunnerBuilder ") }
108113 )
109114 }
115+
116+ it("does actually work when the check is explicitly disabled") {
117+ project.android.testOptions.junitPlatform.instrumentationTests.integrityCheckEnabled = false
118+ project.evaluate()
119+ }
110120 }
111121 }
112122
You can’t perform that action at this time.
0 commit comments