From 35b986a27065e21f170267a2aafb61c9d8a4bdbc Mon Sep 17 00:00:00 2001 From: Alexander Popsuenko Date: Wed, 4 Sep 2019 17:15:28 +0300 Subject: [PATCH] added annotations for behaviors structure --- .../ru/tinkoff/allure/annotations/Epic.kt | 14 ++++ .../ru/tinkoff/allure/annotations/Epics.kt | 12 ++++ .../ru/tinkoff/allure/annotations/Feature.kt | 13 ++++ .../ru/tinkoff/allure/annotations/Features.kt | 12 ++++ .../ru/tinkoff/allure/annotations/Stories.kt | 12 ++++ .../ru/tinkoff/allure/annotations/Story.kt | 13 ++++ .../allure/utils/ResultsUtilsCommon.kt | 66 +++++++++++++++++-- 7 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epic.kt create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epics.kt create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Feature.kt create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Features.kt create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Stories.kt create mode 100644 allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Story.kt diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epic.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epic.kt new file mode 100644 index 0000000..06acacc --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epic.kt @@ -0,0 +1,14 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited +import kotlin.annotation.Repeatable + +/** + * Used to mark tests with epic label. + */ +@Inherited +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +@Repeatable +annotation class Epic(val value: String) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epics.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epics.kt new file mode 100644 index 0000000..2bc69d0 --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Epics.kt @@ -0,0 +1,12 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited + +/** + * Wrapper annotation for {@link Epic}. + */ +@Inherited +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +annotation class Epics(vararg val value: Epic) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Feature.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Feature.kt new file mode 100644 index 0000000..1940737 --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Feature.kt @@ -0,0 +1,13 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited + +/** + * Used to mark tests with feature label. + */ +@Inherited +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +@Repeatable +annotation class Feature(val value: String) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Features.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Features.kt new file mode 100644 index 0000000..2f137e2 --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Features.kt @@ -0,0 +1,12 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited + +/** + * Wrapper annotation for [Feature]. + */ +@Inherited +@MustBeDocumented +@kotlin.annotation.Retention(AnnotationRetention.RUNTIME) +@kotlin.annotation.Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +annotation class Features(vararg val value: Feature) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Stories.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Stories.kt new file mode 100644 index 0000000..d3c4f50 --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Stories.kt @@ -0,0 +1,12 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited + +/** + * Wrapper annotation for [Story]. + */ +@Inherited +@MustBeDocumented +@kotlin.annotation.Retention(AnnotationRetention.RUNTIME) +@kotlin.annotation.Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +annotation class Stories(vararg val value: Story) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Story.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Story.kt new file mode 100644 index 0000000..1559abe --- /dev/null +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/annotations/Story.kt @@ -0,0 +1,13 @@ +package ru.tinkoff.allure.annotations + +import java.lang.annotation.Inherited + +/** + * Used to mark test case with a story label. + */ +@Inherited +@MustBeDocumented +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE) +@Repeatable +annotation class Story(val value: String) \ No newline at end of file diff --git a/allure-common/src/main/kotlin/ru/tinkoff/allure/utils/ResultsUtilsCommon.kt b/allure-common/src/main/kotlin/ru/tinkoff/allure/utils/ResultsUtilsCommon.kt index a55793e..251e3f4 100644 --- a/allure-common/src/main/kotlin/ru/tinkoff/allure/utils/ResultsUtilsCommon.kt +++ b/allure-common/src/main/kotlin/ru/tinkoff/allure/utils/ResultsUtilsCommon.kt @@ -2,10 +2,7 @@ package ru.tinkoff.allure.utils import org.junit.runner.Description import ru.tinkoff.allure.SeverityLevel -import ru.tinkoff.allure.annotations.DisplayName -import ru.tinkoff.allure.annotations.Issue -import ru.tinkoff.allure.annotations.Owner -import ru.tinkoff.allure.annotations.Severity +import ru.tinkoff.allure.annotations.* import ru.tinkoff.allure.model.Label import ru.tinkoff.allure.model.Link import java.math.BigInteger @@ -19,6 +16,10 @@ const val ISSUE_LINK_TYPE = "issue" const val SEVERITY_LABEL_NAME = "severity" const val TAG_LABEL_NAME = "tag" const val OWNER_LABEL_NAME = "owner" +const val EPIC_LABEL_NAME = "epic" +const val FEATURE_LABEL_NAME = "feature" +const val STORY_LABEL_NAME = "story" + fun getMethodDisplayName(description: Description): String { return description.getAnnotation(DisplayName::class.java)?.value ?: description.methodName @@ -78,6 +79,42 @@ fun getLinkUrl(name: String?, type: String): String? { return pattern.replace("\\{}", name ?: "") } +fun createLabels(epics: Epics): List