Skip to content

Commit

Permalink
add support for recursive meta annotations (via allure-framework#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed May 20, 2019
1 parent c659614 commit 4e0b4a4
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 50,7 @@
/**
* Scenario labels and links builder.
*/
@SuppressWarnings({"CyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.NcssCount"})
@SuppressWarnings({"CyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.NcssCount", "MultipleStringLiterals"})
class LabelBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class);
private static final String COMPOSITE_TAG_DELIMITER = "=";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 15,7 @@
*/
package io.qameta.allure.test;

import io.qameta.allure.LabelAnnotation;
import io.qameta.allure.Feature;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand All @@ -24,8 24,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static io.qameta.allure.util.ResultsUtils.FEATURE_LABEL_NAME;

/**
* @author charlie (Dmitry Baev).
*/
Expand All @@ -37,191 35,191 @@
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Basic framework support")
@Feature("Basic framework support")
@interface Base {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Parallel test execution support")
@Feature("Parallel test execution support")
@interface Parallel {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Full name")
@Feature("Full name")
@interface FullName {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Display name")
@Feature("Display name")
@interface DisplayName {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Descriptions")
@Feature("Descriptions")
@interface Descriptions {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timings")
@Feature("Timings")
@interface Timings {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Steps")
@Feature("Steps")
@interface Steps {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Attachments")
@Feature("Attachments")
@interface Attachments {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Parameters")
@Feature("Parameters")
@interface Parameters {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Fixtures")
@Feature("Fixtures")
@interface Fixtures {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Links")
@Feature("Links")
@interface Links {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Marker annotations")
@Feature("Marker annotations")
@interface MarkerAnnotations {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Failed tests")
@Feature("Failed tests")
@interface FailedTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Broken tests")
@Feature("Broken tests")
@interface BrokenTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Passed tests")
@Feature("Passed tests")
@interface PassedTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Skipped tests")
@Feature("Skipped tests")
@interface SkippedTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Ignored tests")
@Feature("Ignored tests")
@interface IgnoredTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Not implemented tests")
@Feature("Not implemented tests")
@interface NotImplementedTests {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "History")
@Feature("History")
@interface History {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Retries")
@Feature("Retries")
@interface Retries {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Stages")
@Feature("Stages")
@interface Stages {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Trees")
@Feature("Trees")
@interface Trees {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timeline")
@Feature("Timeline")
@interface Timeline {
}

@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LabelAnnotation(name = FEATURE_LABEL_NAME, value = "Timeline")
@Feature("Timeline")
@interface Severity {
}
}
3 changes: 3 additions & 0 deletions allure-java-commons/src/main/java/io/qameta/allure/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 23,16 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static io.qameta.allure.util.ResultsUtils.ISSUE_LINK_TYPE;

/**
* Used to link tests with issues.
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LinkAnnotation(type = ISSUE_LINK_TYPE)
@Repeatable(Issues.class)
public @interface Issue {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 38,7 @@
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LinkAnnotation
@Repeatable(Links.class)
public @interface Link {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,7 @@
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
Expand All @@ -36,20 37,31 @@
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
@Repeatable(LinkAnnotations.class)
public @interface LinkAnnotation {

String DEFAULT_VALUE = "$$$$$$$$__value__$$$$$$$$";

/**
* The value of link. In not specified will take value from <code>value()</code>
* method of target annotation.
*
* @return the value of the link to add.
*/
String value() default "";
String value() default DEFAULT_VALUE;

/**
* This type is used for create an icon for link. Also there is few reserved types such as issue and tms.
*
* @return the link type.
*/
String type() default CUSTOM_LINK_TYPE;

/**
* Url for link. By default will search for system property `allure.link.{type}.pattern`, and use it
* to generate url.
*
* @return the link url.
*/
String url() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 1,36 @@
/*
* Copyright 2019 Qameta Software OÜ
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.qameta.allure;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Wrapper annotation for {@link LinkAnnotation}.
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.ANNOTATION_TYPE})
public @interface LinkAnnotations {

LinkAnnotation[] value();

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 23,16 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static io.qameta.allure.util.ResultsUtils.TMS_LINK_TYPE;

/**
* Used to link tests with test cases in external test management system.
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@LinkAnnotation(type = TMS_LINK_TYPE)
@Repeatable(TmsLinks.class)
public @interface TmsLink {

Expand Down
Loading

0 comments on commit 4e0b4a4

Please sign in to comment.