-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid executing tests when ./gradlew assemble is called (via #76)
- Loading branch information
Showing
4 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
allure-adapter-plugin/src/it/adapter-assemble/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
id("java") | ||
id("io.qameta.allure-adapter") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.junit:junit-bom:5.8.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
doLast { | ||
throw new IllegalStateException("test task must not be called when executing ./gradlew assemble") | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
allure-adapter-plugin/src/it/adapter-assemble/src/test/java/tests/Junit5Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package tests; | ||
|
||
import io.qameta.allure.Attachment; | ||
import io.qameta.allure.Step; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class Junit5Test { | ||
|
||
@Test | ||
public void testWithAttachment() { | ||
stepMethod(); | ||
assertTrue(true); | ||
} | ||
|
||
@Step("step") | ||
public void stepMethod() { | ||
attachment(); | ||
} | ||
|
||
@Attachment(value = "attachment", type = "text/plain") | ||
public String attachment() { | ||
return "<p>HELLO</p>"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
allure-adapter-plugin/src/test/kotlin/io/qameta/allure/gradle/adapter/AssembleTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.qameta.allure.gradle.adapter | ||
|
||
import io.qameta.allure.gradle.rule.GradleRunnerRule | ||
import org.assertj.core.api.Assertions | ||
import org.gradle.testkit.runner.TaskOutcome | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
class AssembleTest { | ||
@Rule | ||
@JvmField | ||
val gradleRunner = GradleRunnerRule() | ||
.version { version } | ||
.project { project } | ||
.tasks { tasks } | ||
|
||
@Parameterized.Parameter(0) | ||
lateinit var version: String | ||
|
||
@Parameterized.Parameter(1) | ||
lateinit var project: String | ||
|
||
@Parameterized.Parameter(2) | ||
lateinit var tasks: Array<String> | ||
|
||
companion object { | ||
@JvmStatic | ||
@Parameterized.Parameters(name = "{1} [{0}]") | ||
fun getFrameworks() = listOf( | ||
arrayOf( | ||
"7.0", | ||
"src/it/adapter-assemble", | ||
arrayOf("assemble") | ||
), | ||
arrayOf( | ||
"5.0", | ||
"src/it/adapter-assemble", | ||
arrayOf("assemble") | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `assemble should not execute tests`() { | ||
Assertions.assertThat(gradleRunner.buildResult.tasks) | ||
.`as`("assemble should succeed, and test must not be executed") | ||
.filteredOn { task -> task.path == ":assemble" } | ||
.extracting("outcome") | ||
.containsAnyOf(TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE) | ||
} | ||
} |