Skip to content

Commit

Permalink
support Gradle Metadata when adding allure-junit5 dependency automati…
Browse files Browse the repository at this point in the history
…cally (via #68)
  • Loading branch information
vlsi authored Sep 27, 2021
1 parent 64b176d commit 93d92c7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,22 @@ class DefaultAutoconfigureRuleBuilder(
override fun compileOnly(dependencyNotation: Any) = compileOnly(dependencyNotation, null)

override fun compileOnly(dependencyNotation: Any, configureAction: Action<in DependencyMetadata<*>>?) {
deps.getOrPut("compile") { mutableListOf() } +=
DependencyDeclaration(dependencyNotation, configureAction)
val dependencyDeclaration = DependencyDeclaration(dependencyNotation, configureAction)
addDependencyToVariant("compile", dependencyDeclaration)
addDependencyToVariant("apiElements", dependencyDeclaration)
}

override fun runtimeOnly(dependencyNotation: Any) = runtimeOnly(dependencyNotation, null)

override fun runtimeOnly(dependencyNotation: Any, configureAction: Action<in DependencyMetadata<*>>?) {
deps.getOrPut("runtime") { mutableListOf() } +=
DependencyDeclaration(dependencyNotation, configureAction)
val dependencyDeclaration = DependencyDeclaration(dependencyNotation, configureAction)
addDependencyToVariant("runtime", dependencyDeclaration)
addDependencyToVariant("runtimeElements", dependencyDeclaration)
}

private fun addDependencyToVariant(variantName: String, dependencyDeclaration: DependencyDeclaration) {
deps.getOrPut(variantName) { mutableListOf() } +=
dependencyDeclaration
}

fun build(): AutoconfigureRule = SimpleRule(
Expand Down
21 changes: 21 additions & 0 deletions allure-plugin/src/it/junit5-5.8.1/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'java'
id 'io.qameta.allure'
}

repositories {
mavenCentral()
}

test {
useJUnitPlatform()
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.8.1')
testImplementation 'org.junit.jupiter:junit-jupiter'
}

allure {
adapter.allureJavaVersion = "2.14.0"
}
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>";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DependenciesTest {
{ "src/it/junit4-autoconfigure", "7.0", "5.0", "6.0" },
{ "src/it/junit4-kotlin", "7.0", "5.1", "5.0" },
{ "src/it/junit5", "7.0", "5.0", "6.0" },
{ "src/it/junit5-5.8.1", "7.2", "5.0", "6.0" },
{ "src/it/testng", "7.0", "5.0", "6.0" },
{ "src/it/testng-autoconfigure", "7.0", "5.0", "6.0" },
{ "src/it/spock", "7.0", "5.0", "6.0" },
Expand Down

0 comments on commit 93d92c7

Please sign in to comment.