Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Add AllureId annotation (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Silencegod authored Apr 19, 2020
1 parent 7cd0244 commit 5c05eef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.qameta.allure.android.annotations

import java.lang.annotation.Inherited

/**
* Used by Allure Enterprise to link test cases with related test methods.
*/
@Inherited
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.FUNCTION)
annotation class AllureId(val value: String)
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
package io.qameta.allure.android.utils

import io.qameta.allure.android.annotations.Issues
import io.qameta.allure.android.annotations.Layer
import io.qameta.allure.android.annotations.Tag
import io.qameta.allure.android.annotations.Tags
import io.qameta.allure.android.SeverityLevel
import io.qameta.allure.android.annotations.DisplayName
import io.qameta.allure.android.annotations.Epic
import io.qameta.allure.android.annotations.Epics
import io.qameta.allure.android.annotations.Feature
import io.qameta.allure.android.annotations.Features
import io.qameta.allure.android.annotations.Issue
import io.qameta.allure.android.annotations.Owner
import io.qameta.allure.android.annotations.Severity
import io.qameta.allure.android.annotations.Stories
import io.qameta.allure.android.annotations.Story
import io.qameta.allure.android.annotations.TmsLink
import io.qameta.allure.android.annotations.*
import io.qameta.allure.android.model.Label
import io.qameta.allure.android.model.Link
import org.junit.runner.Description
Expand All @@ -38,6 +24,7 @@ const val FEATURE_LABEL_NAME = "feature"
const val STORY_LABEL_NAME = "story"
const val LAYER_LABEL_NAME = "layer"
const val ISSUE_LABEL_TYPE = "issue"
const val ALLURE_ID_LABEL_NAME = "AS_ID"


fun getMethodDisplayName(description: Description): String {
Expand Down Expand Up @@ -156,6 +143,14 @@ fun createLabel(issue: Issue): Label {
return createLabel(name = ISSUE_LABEL_TYPE, value = issue.value)
}

fun createLabel(allureId: AllureId): Label {
return createAllureIdLabel(allureId.value)
}

fun createAllureIdLabel(value: String): Label {
return createLabel(name = ALLURE_ID_LABEL_NAME, value = value)
}

fun createStoryLabel(value: String): Label {
return createLabel(name = STORY_LABEL_NAME, value = value)
}
Expand Down Expand Up @@ -206,7 +201,9 @@ fun getLabels(description: Description): List<Label> {
getAnnotationsOnMethod(description, Tags::class.java).flatMap { createLabels(it) } +

getAnnotationsOnClass(description, Tag::class.java).map { createLabel(it) } +
getAnnotationsOnMethod(description, Tag::class.java).map { createLabel(it) }
getAnnotationsOnMethod(description, Tag::class.java).map { createLabel(it) } +

getAnnotationsOnMethod(description, AllureId::class.java).map { createLabel(it) }
}

fun <T : Annotation> getAnnotationsOnMethod(description: Description, clazz: Class<T>): List<T> {
Expand Down

0 comments on commit 5c05eef

Please sign in to comment.