├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── build.gradle.kts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main └── java │ └── io │ └── qameta │ └── allure │ ├── JiraIssue.java │ ├── JiraIssues.java │ ├── Layer.java │ ├── Lead.java │ ├── Manual.java │ ├── Microservice.java │ ├── PagePath.java │ ├── RestSteps.java │ ├── TM4J.java │ ├── UrlPath.java │ └── WebSteps.java └── test ├── java └── io │ └── qameta │ └── allure │ ├── IssuesRestTest.java │ ├── IssuesWebTest.java │ └── PullRequestsWebTest.java └── resources └── index.html /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: 4 | push: 5 | workflow_dispatch: 6 | inputs: 7 | ALLURE_JOB_RUN_ID: 8 | description: "Inner parameter for Allure TestOps" 9 | required: false 10 | ALLURE_USERNAME: 11 | description: "Inner parameter for Allure TestOps" 12 | required: false 13 | 14 | env: 15 | ALLURE_JOB_RUN_ID: ${{ github.event.inputs.ALLURE_JOB_RUN_ID }} 16 | 17 | jobs: 18 | test: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: actions/setup-java@v4 23 | with: 24 | distribution: 'zulu' 25 | java-version: '21' 26 | cache: 'gradle' 27 | - uses: allure-framework/setup-allurectl@v1 28 | with: 29 | allure-endpoint: https://demo.testops.cloud 30 | allure-token: ${{ secrets.ALLURE_TOKEN }} 31 | allure-project-id: 1064 32 | - name: Run Tests 33 | run: allurectl watch -- ./gradlew clean test 34 | env: 35 | ALLURE_RESULTS: build/allure-results 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Idea 2 | .idea 3 | *.im; 4 | 5 | # Gradle 6 | .gradle 7 | build 8 | 9 | # Allure 10 | .allure 11 | allure-report 12 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | id("io.qameta.allure") version "2.12.0" 4 | } 5 | 6 | group = "io.eroshenkoam" 7 | version = version 8 | 9 | allure { 10 | report { 11 | version.set("2.29.1") 12 | } 13 | adapter { 14 | autoconfigure.set(true) 15 | aspectjWeaver.set(true) 16 | frameworks { 17 | junit5 { 18 | adapterVersion.set("2.29.1") 19 | } 20 | } 21 | } 22 | } 23 | 24 | tasks.withType(JavaCompile::class) { 25 | sourceCompatibility = "${JavaVersion.VERSION_21}" 26 | targetCompatibility = "${JavaVersion.VERSION_21}" 27 | options.encoding = "UTF-8" 28 | } 29 | 30 | tasks.withType(Test::class) { 31 | ignoreFailures = true 32 | useJUnitPlatform { 33 | 34 | } 35 | systemProperty("junit.jupiter.execution.parallel.enabled", "true") 36 | systemProperty("junit.jupiter.execution.parallel.config.strategy", "dynamic") 37 | 38 | systemProperty("junit.jupiter.extensions.autodetection.enabled", "true") 39 | } 40 | 41 | 42 | repositories { 43 | mavenCentral() 44 | mavenLocal() 45 | } 46 | 47 | dependencies { 48 | implementation("commons-io:commons-io:2.15.1") 49 | implementation("io.qameta.allure:allure-java-commons:2.29.1") 50 | implementation("org.junit.jupiter:junit-jupiter-api:5.12.2") 51 | implementation("org.junit.jupiter:junit-jupiter-engine:5.12.2") 52 | implementation("org.junit.jupiter:junit-jupiter-params:5.12.2") 53 | } 54 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eroshenkoam/allure-example/bc1bc86c36beb3d0d649c47c15b06fc85303318f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'allure-example' 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/JiraIssue.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Repeatable; 7 | import java.lang.annotation.Retention; 8 | import java.lang.annotation.RetentionPolicy; 9 | import java.lang.annotation.Target; 10 | 11 | /** 12 | * @author eroshenkoam (Artem Eroshenko). 13 | */ 14 | @Documented 15 | @Inherited 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Target({ElementType.METHOD, ElementType.TYPE}) 18 | @Repeatable(JiraIssues.class) 19 | @LabelAnnotation(name = "jira") 20 | public @interface JiraIssue { 21 | 22 | String value(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/JiraIssues.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * @author eroshenkoam (Artem Eroshenko). 12 | */ 13 | @Documented 14 | @Inherited 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Target({ElementType.METHOD, ElementType.TYPE}) 17 | public @interface JiraIssues { 18 | 19 | JiraIssue[] value(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/Layer.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Inherited; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * @author eroshenkoam (Artem Eroshenko). 14 | */ 15 | @Documented 16 | @Inherited 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target({ElementType.METHOD, ElementType.TYPE}) 19 | @LabelAnnotation(name = "layer") 20 | public @interface Layer { 21 | 22 | String value(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/Lead.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Inherited; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | /** 13 | * @author eroshenkoam (Artem Eroshenko). 14 | */ 15 | @Documented 16 | @Inherited 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Target({ElementType.METHOD, ElementType.TYPE}) 19 | @LabelAnnotation(name = "lead") 20 | public @interface Lead { 21 | 22 | String value(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/Manual.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * @author eroshenkoam (Artem Eroshenko). 12 | */ 13 | @Documented 14 | @Inherited 15 | @Retention(RetentionPolicy.RUNTIME) 16 | @Target({ElementType.METHOD, ElementType.TYPE}) 17 | @LabelAnnotation(name = "ALLURE_MANUAL", value = "true") 18 | public @interface Manual { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/Microservice.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Inherited; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | @Documented 13 | @Inherited 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target({ElementType.METHOD, ElementType.TYPE}) 16 | @LabelAnnotation(name = "msrv") 17 | public @interface Microservice { 18 | 19 | String value(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/PagePath.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.*; 6 | 7 | @Documented 8 | @Inherited 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target({ElementType.METHOD, ElementType.TYPE}) 11 | @LabelAnnotation(name = "page") 12 | public @interface PagePath { 13 | 14 | String value(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/RestSteps.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.Step; 4 | 5 | import static io.qameta.allure.Allure.step; 6 | 7 | public class RestSteps { 8 | 9 | @Step("Create issue with title `{title}`") 10 | public void createIssueWithTitle(final String owner, final String repo, final String title) { 11 | step(String.format("POST /repos/%s/%s/issues", owner, repo)); 12 | } 13 | 14 | @Step("Close issue with title `{title}`") 15 | public void closeIssueWithTitle(final String owner, final String repo, final String title) { 16 | step(String.format("GET /repos/%s/%s/issues?text=%s", owner, repo, title)); 17 | step(String.format("PATCH /repos/%s/%s/issues/%s", owner, repo, 10)); 18 | } 19 | 20 | @Step("Check note with content `{title}` exists") 21 | public void shouldSeeIssueWithTitle(final String owner, final String repo, final String title) { 22 | step(String.format("GET /repos/%s/%s/issues?text=%s", owner, repo, title)); 23 | step(String.format("GET /repos/%s/%s/issues/%s", owner, repo, 10)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/TM4J.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Inherited; 8 | import java.lang.annotation.Repeatable; 9 | import java.lang.annotation.Retention; 10 | import java.lang.annotation.RetentionPolicy; 11 | import java.lang.annotation.Target; 12 | 13 | /** 14 | * @author eroshenkoam (Artem Eroshenko). 15 | */ 16 | @Documented 17 | @Inherited 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Target({ElementType.METHOD, ElementType.TYPE}) 20 | @LabelAnnotation(name = "tm4j") 21 | public @interface TM4J { 22 | 23 | String value(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/UrlPath.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.LabelAnnotation; 4 | 5 | import java.lang.annotation.Documented; 6 | import java.lang.annotation.ElementType; 7 | import java.lang.annotation.Inherited; 8 | import java.lang.annotation.Retention; 9 | import java.lang.annotation.RetentionPolicy; 10 | import java.lang.annotation.Target; 11 | 12 | @Documented 13 | @Inherited 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @Target({ElementType.METHOD, ElementType.TYPE}) 16 | @LabelAnnotation(name = "url") 17 | public @interface UrlPath { 18 | 19 | String value(); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/io/qameta/allure/WebSteps.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import io.qameta.allure.Attachment; 4 | import io.qameta.allure.Step; 5 | import org.apache.commons.io.IOUtils; 6 | 7 | import java.io.IOException; 8 | import java.io.InputStream; 9 | import java.nio.charset.Charset; 10 | import java.util.Random; 11 | 12 | import static org.junit.jupiter.api.Assertions.assertEquals; 13 | import static org.junit.jupiter.api.Assertions.fail; 14 | 15 | /** 16 | * @author eroshenkoam (Artem Eroshenko). 17 | */ 18 | public class WebSteps { 19 | 20 | @Step("Starting web driver") 21 | public void startDriver() { 22 | maybeThrowSeleniumTimeoutException(); 23 | } 24 | 25 | @Step("Stopping web driver") 26 | public void stopDriver() { 27 | maybeThrowSeleniumTimeoutException(); 28 | } 29 | 30 | @Step("Open issues page `{owner}/{repo}`") 31 | public void openIssuesPage(final String owner, final String repo) { 32 | attachPageSource(); 33 | maybeThrowElementNotFoundException(); 34 | } 35 | 36 | @Step("Open pull requests page `{owner}/{repo}`") 37 | public void openPullRequestsPage(final String owner, final String repo) { 38 | attachPageSource(); 39 | maybeThrowElementNotFoundException(); 40 | } 41 | 42 | @Step("Create pull request from branch `{branch}`") 43 | public void createPullRequestFromBranch(final String branch) { 44 | maybeThrowElementNotFoundException(); 45 | } 46 | 47 | @Step("Create issue with title `{title}`") 48 | public void createIssueWithTitle(String title) { 49 | maybeThrowAssertionException(title); 50 | } 51 | 52 | @Step("Close pull request for branch `{branch}`") 53 | public void closePullRequestForBranch(final String branch) { 54 | maybeThrowAssertionException(branch); 55 | } 56 | 57 | @Step("Close issue with title `{title}`") 58 | public void closeIssueWithTitle(final String title) { 59 | maybeThrowAssertionException(title); 60 | } 61 | 62 | @Step("Check pull request for branch `{branch}` exists") 63 | public void shouldSeePullRequestForBranch(final String branch) { 64 | maybeThrowAssertionException(branch); 65 | } 66 | 67 | @Step("Check issue with title `{title}` exists") 68 | public void shouldSeeIssueWithTitle(final String title) { 69 | maybeThrowAssertionException(title); 70 | } 71 | 72 | @Step("Check pull request for branch `{branch}` not exists") 73 | public void shouldNotSeePullRequestForBranch(final String branch) { 74 | maybeThrowAssertionException(branch); 75 | } 76 | 77 | @Step("Check issue with title `{title}` not exists") 78 | public void shouldNotSeeIssueWithTitle(final String title) { 79 | maybeThrowAssertionException(title); 80 | } 81 | 82 | @Attachment(value = "Page", type = "text/html", fileExtension = "html") 83 | public byte[] attachPageSource() { 84 | try { 85 | final InputStream stream = ClassLoader.getSystemResourceAsStream("index.html"); 86 | return IOUtils.toString(stream, Charset.forName("UTF-8")).getBytes(); 87 | } catch (IOException e) { 88 | throw new RuntimeException(e); 89 | } 90 | } 91 | 92 | private void maybeThrowSeleniumTimeoutException() { 93 | if (isTimeToThrowException()) { 94 | fail(webDriverIsNotReachable("Allure")); 95 | } 96 | } 97 | 98 | private void maybeThrowElementNotFoundException() { 99 | try { 100 | Thread.sleep(1000); 101 | if (isTimeToThrowException()) { 102 | fail(elementNotFoundMessage("[//div[@class='something']]")); 103 | } 104 | } catch (InterruptedException e) { 105 | //do nothing, it's dummy test 106 | } 107 | } 108 | 109 | private void maybeThrowAssertionException(String text) { 110 | if (isTimeToThrowException()) { 111 | fail(textEqual(text, "another text")); 112 | } 113 | } 114 | 115 | private boolean isTimeToThrowException() { 116 | return new Random().nextBoolean() 117 | && new Random().nextBoolean() 118 | && new Random().nextBoolean() 119 | && new Random().nextBoolean(); 120 | } 121 | 122 | private String webDriverIsNotReachable(final String text) { 123 | return String.format("WebDriverException: chrome not reachable\n" + 124 | "Element not found {By.xpath: //a[@href='/eroshenkoam/allure-example']}\n" + 125 | "Expected: text '%s'\n" + 126 | "Page source: file:/Users/eroshenkoam/Developer/eroshenkoam/webdriver-coverage-example/build/reports/tests/1603973861960.0.html\n" + 127 | "Timeout: 4 s.", text); 128 | } 129 | 130 | private String textEqual(final String expected, final String actual) { 131 | return String.format("Element should text '%s' {By.xpath: //a[@href='/eroshenkoam/allure-example']}\n" + 132 | "Element: '%s'\n" + 133 | "Screenshot: file:/Users/eroshenkoam/Developer/eroshenkoam/webdriver-coverage-example/build/reports/tests/1603973703632.0.png\n" + 134 | "Page source: file:/Users/eroshenkoam/Developer/eroshenkoam/webdriver-coverage-example/build/reports/tests/1603973703632.0.html\n" + 135 | "Timeout: 4 s.\n", expected, actual); 136 | } 137 | 138 | private String elementNotFoundMessage(String selector) { 139 | return String.format("Element not found {By.xpath: %s}\n" + 140 | "Expected: visible or transparent: visible or have css value opacity=0\n" + 141 | "Screenshot: file:/Users/eroshenkoam/Developer/eroshenkoam/webdriver-coverage-example/build/reports/tests/1603973516437.0.png\n" + 142 | "Page source: file:/Users/eroshenkoam/Developer/eroshenkoam/webdriver-coverage-example/build/reports/tests/1603973516437.0.html\n" + 143 | "Timeout: 4 s.\n", selector); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/test/java/io/qameta/allure/IssuesRestTest.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import org.junit.jupiter.api.Tag; 4 | import org.junit.jupiter.api.Tags; 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.ValueSource; 7 | 8 | @Layer("rest") 9 | @Owner("baev") 10 | @Feature("Issues") 11 | public class IssuesRestTest { 12 | 13 | private static final String OWNER = "allure-framework"; 14 | private static final String REPO = "allure2"; 15 | 16 | private final RestSteps steps = new RestSteps(); 17 | 18 | @TM4J("AE-T1") 19 | @Story("Create new issue") 20 | @Microservice("Billing") 21 | @Tags({@Tag("api"), @Tag("smoke")}) 22 | @ParameterizedTest(name = "Create issue via api") 23 | @ValueSource(strings = {"First Note", "Second Note"}) 24 | public void shouldCreateUserNote(@Param(value = "Title") String title) { 25 | steps.createIssueWithTitle(OWNER, REPO, title); 26 | steps.shouldSeeIssueWithTitle(OWNER, REPO, title); 27 | } 28 | 29 | @TM4J("AE-T2") 30 | @Story("Close existing issue") 31 | @Microservice("Repository") 32 | @Tags({@Tag("web"), @Tag("regress")}) 33 | @JiraIssues({@JiraIssue("AE-1")}) 34 | @ParameterizedTest(name = "Close issue via api") 35 | @ValueSource(strings = {"First Note", "Second Note"}) 36 | public void shouldDeleteUserNote(@Param(value = "Title") String title) { 37 | steps.createIssueWithTitle(OWNER, REPO, title); 38 | steps.closeIssueWithTitle(OWNER, REPO, title); 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/io/qameta/allure/IssuesWebTest.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import org.junit.jupiter.api.AfterEach; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.Tag; 7 | import org.junit.jupiter.api.Tags; 8 | import org.junit.jupiter.api.Test; 9 | 10 | /** 11 | * @author eroshenkoam (Artem Eroshenko). 12 | */ 13 | @Layer("web") 14 | @Owner("eroshenkoam") 15 | @Feature("Issues") 16 | public class IssuesWebTest { 17 | 18 | private static final String OWNER = "allure-framework"; 19 | private static final String REPO = "allure2"; 20 | 21 | private static final String ISSUE_TITLE = "Some issue title here"; 22 | 23 | private final WebSteps steps = new WebSteps(); 24 | 25 | @BeforeEach 26 | public void startDriver() { 27 | steps.startDriver(); 28 | } 29 | 30 | @Test 31 | @TM4J("AE-T3") 32 | @Microservice("Billing") 33 | @Story("Create new issue") 34 | @JiraIssues({@JiraIssue("AE-2")}) 35 | @Tags({@Tag("web"), @Tag("critical")}) 36 | @DisplayName("Creating new issue authorized user") 37 | public void shouldCreateIssue() { 38 | steps.openIssuesPage(OWNER, REPO); 39 | steps.createIssueWithTitle(ISSUE_TITLE); 40 | steps.shouldSeeIssueWithTitle(ISSUE_TITLE); 41 | } 42 | 43 | @Test 44 | @TM4J("AE-T4") 45 | @Microservice("Repository") 46 | @Story("Create new issue") 47 | @Tags({@Tag("web"), @Tag("regress")}) 48 | @JiraIssues({@JiraIssue("AE-1")}) 49 | @DisplayName("Adding note to advertisement") 50 | public void shouldAddLabelToIssue() { 51 | steps.openIssuesPage(OWNER, REPO); 52 | steps.createIssueWithTitle(ISSUE_TITLE); 53 | steps.shouldSeeIssueWithTitle(ISSUE_TITLE); 54 | } 55 | 56 | @Test 57 | @TM4J("AE-T5") 58 | @Microservice("Repository") 59 | @Story("Close existing issue") 60 | @Tags({@Tag("web"), @Tag("regress")}) 61 | @JiraIssues({@JiraIssue("AE-1")}) 62 | @DisplayName("Closing new issue for authorized user") 63 | public void shouldCloseIssue() { 64 | steps.openIssuesPage(OWNER, REPO); 65 | steps.createIssueWithTitle(ISSUE_TITLE); 66 | steps.closeIssueWithTitle(ISSUE_TITLE); 67 | steps.shouldNotSeeIssueWithTitle(ISSUE_TITLE); 68 | } 69 | 70 | @AfterEach 71 | public void stopDriver() { 72 | steps.stopDriver(); 73 | } 74 | 75 | } -------------------------------------------------------------------------------- /src/test/java/io/qameta/allure/PullRequestsWebTest.java: -------------------------------------------------------------------------------- 1 | package io.qameta.allure; 2 | 3 | import org.junit.jupiter.api.AfterEach; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.Tag; 7 | import org.junit.jupiter.api.Tags; 8 | import org.junit.jupiter.api.Test; 9 | 10 | /** 11 | * @author eroshenkoam (Artem Eroshenko). 12 | */ 13 | @Layer("web") 14 | @Owner("eroshenkoam") 15 | @Feature("Pull Requests") 16 | public class PullRequestsWebTest { 17 | 18 | private static final String OWNER = "allure-framework"; 19 | private static final String REPO = "allure2"; 20 | 21 | private static final String BRANCH = "new-feature"; 22 | 23 | private final WebSteps steps = new WebSteps(); 24 | 25 | @BeforeEach 26 | public void startDriver() { 27 | steps.startDriver(); 28 | } 29 | 30 | @Test 31 | @TM4J("AE-T6") 32 | @Microservice("Billing") 33 | @Story("Create new pull request") 34 | @Tags({@Tag("web"), @Tag("regress"), @Tag("smoke")}) 35 | @JiraIssues({@JiraIssue("AE-1"), @JiraIssue("AE-2")}) 36 | @DisplayName("Creating new issue for authorized user") 37 | public void shouldCreatePullRequest() { 38 | steps.openPullRequestsPage(OWNER, REPO); 39 | steps.createPullRequestFromBranch(BRANCH); 40 | steps.shouldSeePullRequestForBranch(BRANCH); 41 | } 42 | 43 | @Test 44 | @TM4J("AE-T7") 45 | @JiraIssue("AE-2") 46 | @Microservice("Repository") 47 | @Story("Close existing pull request") 48 | @Tags({@Tag("web"), @Tag("regress")}) 49 | @DisplayName("Deleting existing issue for authorized user") 50 | public void shouldClosePullRequest() { 51 | steps.openPullRequestsPage(OWNER, REPO); 52 | steps.createPullRequestFromBranch(BRANCH); 53 | steps.closePullRequestForBranch(BRANCH); 54 | steps.shouldNotSeePullRequestForBranch(BRANCH); 55 | } 56 | 57 | @AfterEach 58 | public void stopDriver() { 59 | steps.stopDriver(); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /src/test/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Test Cases 5 | 7 | 8 | 9 |
10 |
11 |

Test Cases

12 |

AE-5 Добавление в избранное после создания заметки

13 |
14 |
Features
15 |
"Favorites", "Notes"
16 |
Stories
17 |
"Add to favorites after adding note"
18 |
19 |

Scenario

20 |
    21 |
  1. Открываем главную страницу
  2. 22 |
  3. Открываем страницу машины марки {mark}
  4. 23 |
  5. Добавляем заметку {text} к машине
  6. 24 |
  7. Открываем страницу избранного
  8. 25 |
  9. Проверяем что марка {mark} находится в избранных
  10. 26 |
27 |
28 |
29 | 30 | 31 | 32 | --------------------------------------------------------------------------------