-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Issue and IssueExtension * Replace issue links * Add ExtensionRegistryTests for IssueExtension * Enable junit.jupiter.extensions.autodetection.enabled for IssueExtension * Revert "Add ExtensionRegistryTests for IssueExtension" This reverts commit ff13d02
- Loading branch information
Showing
5 changed files
with
73 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
31 changes: 31 additions & 0 deletions
31
src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/util/Issue.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,31 @@ | ||
package com.github.jengelman.gradle.plugins.shadow.util | ||
|
||
import org.junit.jupiter.api.Tags | ||
import org.junit.jupiter.api.extension.BeforeEachCallback | ||
import org.junit.jupiter.api.extension.ExtensionContext | ||
import org.junit.jupiter.api.extension.ExtensionContext.Namespace | ||
|
||
/** | ||
* This is related to [spock.lang.Issue](https://github.com/spockframework/spock/blob/master/spock-core/src/main/java/spock/lang/Issue.java) but is used for JUnit 5 tests. | ||
* | ||
* @see [Tags] | ||
*/ | ||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
annotation class Issue(vararg val values: String) | ||
|
||
class IssueExtension : BeforeEachCallback { | ||
override fun beforeEach(context: ExtensionContext) { | ||
val issueAnnotation = context.requiredTestMethod.getAnnotation(Issue::class.java) ?: return | ||
val store = context.getStore(Namespace.create(IssueExtension::class.java, context.requiredTestClass)) | ||
store.put("tags", issueAnnotation.values.map(::issueLinkToTag)) | ||
} | ||
} | ||
|
||
private fun issueLinkToTag(link: String): String { | ||
return issueLinkRegex.replace(link) { matchResult -> | ||
"ISSUE-${matchResult.groupValues[1]}" | ||
} | ||
} | ||
|
||
private val issueLinkRegex = "https://github\\.com/[^/]+/[^/]+/issues/(\\d+)".toRegex() |
1 change: 1 addition & 0 deletions
1
src/intiTest/resources/META-INF/services/org.junit.jupiter.api.extension.Extension
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 @@ | ||
com.github.jengelman.gradle.plugins.shadow.util.IssueExtension |