diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index fb19a1b5d..bb09719d9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -79,7 +79,7 @@ body: id: terms attributes: label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/allure-framework/allure-java/blob/master/CODE_OF_CONDUCT.md) + description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/allure-framework/allure-java/blob/main/CODE_OF_CONDUCT.md) options: - label: I agree to follow this project's Code of Conduct required: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69f577fc1..8f537bc9c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,8 @@ name: Build +permissions: + contents: read + on: workflow_dispatch: pull_request: @@ -7,29 +10,25 @@ on: - '*' push: branches: - - 'master' + - 'main' - 'hotfix-*' jobs: build: name: "Build" runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - java-version: [ '17.0.x' ] steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v6 - - name: Set up JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 + - name: "Set up JDK" + uses: actions/setup-java@v5 with: distribution: 'zulu' - java-version: ${{ matrix.java-version }} + java-version: 21 - - name: Build with Gradle + - name: "Build with Gradle" run: ./gradlew build -x test --scan - - name: Run tests + - name: "Run tests" if: always() run: ./gradlew --no-build-cache cleanTest test diff --git a/.github/workflows/dependency-submission.yml b/.github/workflows/dependency-submission.yml new file mode 100644 index 000000000..748dfe670 --- /dev/null +++ b/.github/workflows/dependency-submission.yml @@ -0,0 +1,22 @@ +name: Dependency Submission + +on: + push: + branches: + - main + +permissions: + contents: write + +jobs: + dependency-submission: + name: Dependency Submission + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v6 + - name: Generate and submit dependency graph + uses: gradle/actions/dependency-submission@v5 + env: + DEPENDENCY_GRAPH_EXCLUDE_PROJECTS: ':allure-java-commons-test' + DEPENDENCY_GRAPH_INCLUDE_CONFIGURATIONS: 'runtimeClasspath' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index e0d99fc81..f49976b59 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -3,9 +3,14 @@ name: "Set theme labels" on: - pull_request_target +permissions: + contents: read + jobs: triage: runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - uses: actions/labeler@v4 with: diff --git a/.github/workflows/labels-verify.yml b/.github/workflows/labels-verify.yml index 0c18ecb77..7315a905a 100644 --- a/.github/workflows/labels-verify.yml +++ b/.github/workflows/labels-verify.yml @@ -4,9 +4,14 @@ on: pull_request_target: types: [opened, labeled, unlabeled, synchronize] +permissions: + contents: none + jobs: triage: runs-on: ubuntu-latest + permissions: + pull-requests: read steps: - uses: baev/action-label-verify@main with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 75b78957e..2295deb90 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,17 +4,20 @@ on: release: types: [ published ] +permissions: + contents: read + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v6 - - name: "Set up JDK 17.0.x" - uses: actions/setup-java@v4 + - name: "Set up JDK" + uses: actions/setup-java@v5 with: distribution: 'zulu' - java-version: '17.0.x' + java-version: '21' - name: Set up GPG run: echo -n "${GPG_PRIVATE_KEY}" | base64 --decode > ${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg @@ -27,7 +30,7 @@ jobs: - name: "Gradle Publish" run: | - ./gradlew publishToSonatype -Pversion=${GITHUB_REF:10} \ + ./gradlew publishToSonatype closeSonatypeStagingRepository -Pversion=${GITHUB_REF:10} \ -Psigning.keyId=${GPG_KEY_ID} \ -Psigning.password=${GPG_PASSPHRASE} \ -Psigning.secretKeyRingFile=${GITHUB_WORKSPACE}/${GPG_KEY_ID}.gpg diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2167b9d7..7d5ace556 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ name: Release +run-name: Release ${{ inputs.releaseVersion }} (next ${{ inputs.nextVersion }}) by ${{ github.actor }} on: workflow_dispatch: @@ -10,9 +11,14 @@ on: description: "The next version in . format WITHOUT SNAPSHOT SUFFIX" required: true +permissions: + contents: read + jobs: triage: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: "Check release version" run: | @@ -20,7 +26,7 @@ jobs: - name: "Check next version" run: | expr "${{ github.event.inputs.nextVersion }}" : '[[:digit:]][[:digit:]]*\.[[:digit:]][[:digit:]]*$' - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v6 with: token: ${{ secrets.QAMETA_CI }} diff --git a/AUTHORS b/AUTHORS index 0edbd3fb9..8263d9471 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,4 +1,4 @@ The following authors have created the source code of "Allure Java" -published and distributed by Qameta Software OÜ as the owner: +published and distributed by Qameta Software Inc as the owner: * Dmitry Baev diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 64bac5a9e..000000000 --- a/Jenkinsfile +++ /dev/null @@ -1,40 +0,0 @@ -pipeline { - agent { label 'java' } - parameters { - booleanParam(name: 'RELEASE', defaultValue: false, description: 'Perform release?') - string(name: 'RELEASE_VERSION', defaultValue: '', description: 'Release version') - string(name: 'NEXT_VERSION', defaultValue: '', description: 'Next version (without SNAPSHOT)') - } - stages { - stage('Build') { - steps { - sh './gradlew build' - } - } - stage('Release') { - when { expression { return params.RELEASE } } - steps { - withCredentials([usernamePassword(credentialsId: 'qameta-ci_bintray', - usernameVariable: 'BINTRAY_USER', passwordVariable: 'BINTRAY_API_KEY')]) { - sshagent(['qameta-ci_ssh']) { - sh 'git checkout master && git pull origin master' - sh "./gradlew release -Prelease.useAutomaticVersion=true " + - "-Prelease.releaseVersion=${RELEASE_VERSION} " + - "-Prelease.newVersion=${NEXT_VERSION}-SNAPSHOT" - } - } - } - } - } - post { - always { - allure results: [[path: '**/build/allure-results']] - deleteDir() - } - - failure { - slackSend message: "${env.JOB_NAME} - #${env.BUILD_NUMBER} failed (<${env.BUILD_URL}|Open>)", - color: 'danger', teamDomain: 'qameta', channel: 'allure', tokenCredentialId: 'allure-channel' - } - } -} diff --git a/LICENSE b/LICENSE index e078585bf..aa0c10ae1 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2021 Qameta Software OÜ + Copyright 2016-2024 Qameta Software Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java b/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java index fbf10f7f0..128791172 100644 --- a/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java +++ b/allure-assertj/src/main/java/io/qameta/allure/assertj/AllureAspectJ.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java b/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java index 12437b900..57ddef240 100644 --- a/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java +++ b/allure-assertj/src/test/java/io/qameta/allure/assertj/AllureAspectJTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentContent.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentContent.java index c8fe7c111..50af67ea4 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentContent.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentContent.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentData.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentData.java index 86b318a05..5c6d09f34 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentData.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentData.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ * * @author charlie (Dmitry Baev). */ +@FunctionalInterface public interface AttachmentData { String getName(); diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentProcessor.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentProcessor.java index cfc93c716..99129f89a 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentProcessor.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ * @param the type of attachment data. * @author charlie (Dmitry Baev). */ +@FunctionalInterface public interface AttachmentProcessor { void addAttachment(T attachmentData, AttachmentRenderer renderer); diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderException.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderException.java index 5d702bffa..daaf9cc91 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderException.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderException.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java index 1d239331e..2b6f5b1a5 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/AttachmentRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ * @author charlie (Dmitry Baev). */ @SuppressWarnings("PMD.AvoidUncheckedExceptionsInSignatures") +@FunctionalInterface public interface AttachmentRenderer { AttachmentContent render(T attachmentData) throws AttachmentRenderException; diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentContent.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentContent.java index ab26abbb6..ccdc978a8 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentContent.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentContent.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentProcessor.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentProcessor.java index dc57e9a01..652c8ca5f 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentProcessor.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/DefaultAttachmentProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/FreemarkerAttachmentRenderer.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/FreemarkerAttachmentRenderer.java index 244230d25..50ac53924 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/FreemarkerAttachmentRenderer.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/FreemarkerAttachmentRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpRequestAttachment.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpRequestAttachment.java index 47493fc46..a51052cf7 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpRequestAttachment.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpRequestAttachment.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ import io.qameta.allure.attachment.AttachmentData; import io.qameta.allure.util.ObjectUtils; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -41,9 +42,18 @@ public class HttpRequestAttachment implements AttachmentData { private final Map cookies; + private final Map formParams; + public HttpRequestAttachment(final String name, final String url, final String method, final String body, final String curl, final Map headers, final Map cookies) { + this(name, url, method, body, curl, headers, cookies, Collections.emptyMap()); + } + + @SuppressWarnings("checkstyle:parameternumber") + public HttpRequestAttachment(final String name, final String url, final String method, + final String body, final String curl, final Map headers, + final Map cookies, final Map formParams) { this.name = name; this.url = url; this.method = method; @@ -51,6 +61,7 @@ public HttpRequestAttachment(final String name, final String url, final String m this.curl = curl; this.headers = headers; this.cookies = cookies; + this.formParams = formParams; } public String getUrl() { @@ -73,6 +84,10 @@ public Map getCookies() { return cookies; } + public Map getFormParams() { + return formParams; + } + public String getCurl() { return curl; } @@ -90,13 +105,13 @@ public String toString() { + ",\n\tbody=" + this.body + ",\n\theaders=" + ObjectUtils.mapToString(this.headers) + ",\n\tcookies=" + ObjectUtils.mapToString(this.cookies) + + ",\n\tformParams=" + ObjectUtils.mapToString(this.formParams) + "\n)"; } /** * Builder for HttpRequestAttachment. */ - @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") public static final class Builder { private final String name; @@ -111,6 +126,8 @@ public static final class Builder { private final Map cookies = new HashMap<>(); + private final Map formParams = new HashMap<>(); + private Builder(final String name, final String url) { Objects.requireNonNull(name, "Name must not be null value"); Objects.requireNonNull(url, "Url must not be null value"); @@ -160,6 +177,12 @@ public Builder setBody(final String body) { return this; } + public Builder setFormParams(final Map formParams) { + Objects.requireNonNull(formParams, "Form params must not be null value"); + this.formParams.putAll(formParams); + return this; + } + /** * Use setter method instead. * @deprecated scheduled for removal in 3.0 release @@ -215,7 +238,7 @@ public Builder withBody(final String body) { } public HttpRequestAttachment build() { - return new HttpRequestAttachment(name, url, method, body, getCurl(), headers, cookies); + return new HttpRequestAttachment(name, url, method, body, getCurl(), headers, cookies, formParams); } private String getCurl() { @@ -226,6 +249,7 @@ private String getCurl() { builder.append(" '").append(url).append('\''); headers.forEach((key, value) -> appendHeader(builder, key, value)); cookies.forEach((key, value) -> appendCookie(builder, key, value)); + formParams.forEach((key, value) -> appendFormParams(builder, key, value)); if (Objects.nonNull(body)) { builder.append(" -d '").append(body).append('\''); @@ -248,5 +272,13 @@ private static void appendCookie(final StringBuilder builder, final String key, .append(value) .append('\''); } + + private static void appendFormParams(final StringBuilder builder, final String key, final String value) { + builder.append(" --form '") + .append(key) + .append('=') + .append(value) + .append('\''); + } } } diff --git a/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpResponseAttachment.java b/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpResponseAttachment.java index ee79d0ba5..d606af57e 100644 --- a/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpResponseAttachment.java +++ b/allure-attachments/src/main/java/io/qameta/allure/attachment/http/HttpResponseAttachment.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,6 @@ public String toString() { /** * Builder for HttpRequestAttachment. */ - @SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName") public static final class Builder { private final String name; diff --git a/allure-attachments/src/main/resources/tpl/http-request.ftl b/allure-attachments/src/main/resources/tpl/http-request.ftl index b4e31d632..935c1c91a 100644 --- a/allure-attachments/src/main/resources/tpl/http-request.ftl +++ b/allure-attachments/src/main/resources/tpl/http-request.ftl @@ -3,36 +3,45 @@
<#if data.method??>${data.method}<#else>GET to <#if data.url??>${data.url}<#else>Unknown
<#if data.body??> -

Body

-
+

Body

+
     <#t>${data.body}
     
-
+
<#if (data.headers)?has_content> -

Headers

-
- <#list data.headers as name, value> -
${name}: ${value!"null"}
- -
+

Headers

+
+ <#list data.headers as name, value> +
${name}: ${value!"null"}
+ +
<#if (data.cookies)?has_content> -

Cookies

-
- <#list data.cookies as name, value> -
${name}: ${value!"null"}
- -
+

Cookies

+
+ <#list data.cookies as name, value> +
${name}: ${value!"null"}
+ +
<#if data.curl??> -

Curl

-
-${data.curl} -
+

Curl

+
+ ${data.curl} +
+ + +<#if (data.formParams)?has_content> +

FormParams

+
+ <#list data.formParams as name, value> +
${name}: ${value!"null"}
+ +
diff --git a/allure-attachments/src/test/java/io/qameta/allure/attachment/DefaultAttachmentProcessorTest.java b/allure-attachments/src/test/java/io/qameta/allure/attachment/DefaultAttachmentProcessorTest.java index 1283d6116..a1d2def2e 100644 --- a/allure-attachments/src/test/java/io/qameta/allure/attachment/DefaultAttachmentProcessorTest.java +++ b/allure-attachments/src/test/java/io/qameta/allure/attachment/DefaultAttachmentProcessorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java b/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java index 0dabc89d2..0a773e59f 100644 --- a/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java +++ b/allure-attachments/src/test/java/io/qameta/allure/attachment/FreemarkerAttachmentRendererTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/test/java/io/qameta/allure/attachment/NegativeFreemarkerAttachmentRendererTest.java b/allure-attachments/src/test/java/io/qameta/allure/attachment/NegativeFreemarkerAttachmentRendererTest.java index 865eb5e48..fbc2e6611 100644 --- a/allure-attachments/src/test/java/io/qameta/allure/attachment/NegativeFreemarkerAttachmentRendererTest.java +++ b/allure-attachments/src/test/java/io/qameta/allure/attachment/NegativeFreemarkerAttachmentRendererTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-attachments/src/test/java/io/qameta/allure/attachment/testdata/TestData.java b/allure-attachments/src/test/java/io/qameta/allure/attachment/testdata/TestData.java index 60903f8c1..f5933c6db 100644 --- a/allure-attachments/src/test/java/io/qameta/allure/attachment/testdata/TestData.java +++ b/allure-attachments/src/test/java/io/qameta/allure/attachment/testdata/TestData.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-awaitility/build.gradle.kts b/allure-awaitility/build.gradle.kts index 2426a93bc..3c9ed6c79 100644 --- a/allure-awaitility/build.gradle.kts +++ b/allure-awaitility/build.gradle.kts @@ -2,14 +2,15 @@ description = "Allure Awaitlity Integration" val agent: Configuration by configurations.creating -val awaitilityVersion = "4.2.0" +val awaitilityVersion = "4.3.0" dependencies { agent("org.aspectj:aspectjweaver") api(project(":allure-java-commons")) - implementation("org.awaitility:awaitility:$awaitilityVersion") + compileOnly("org.awaitility:awaitility:$awaitilityVersion") testImplementation("javax.annotation:javax.annotation-api") testImplementation("org.assertj:assertj-core") + testImplementation("org.awaitility:awaitility:$awaitilityVersion") testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.slf4j:slf4j-simple") testImplementation(project(":allure-java-commons-test")) @@ -27,4 +28,4 @@ tasks.jar { tasks.test { useJUnitPlatform() -} \ No newline at end of file +} diff --git a/allure-awaitility/readme.md b/allure-awaitility/readme.md index 5a93b6a42..1fcb34691 100644 --- a/allure-awaitility/readme.md +++ b/allure-awaitility/readme.md @@ -7,11 +7,16 @@ For more information about awaitility highly recommended look into [awaitility u ### Configuration examples -Single line for all awaitility conditions in project +Single line for all awaitility conditions in project ```java Awaitility.setDefaultConditionEvaluationListener(new AllureAwaitilityListener()); ``` +And another line to prevent breaking allure lifecycle for Steps inside Awaitility evaluations +```java +Awaitility.pollInSameThread(); +``` + Moreover, it's possible logging only few unstable conditions with method `.conditionEvaluationListener()` ```java final AtomicInteger atomicInteger = new AtomicInteger(0); diff --git a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java index 8a3f468b2..01b793cf5 100644 --- a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java +++ b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/AllureAwaitilityListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,8 @@ public class AllureAwaitilityListener implements ConditionEvaluationListener lifecycle = new InheritableThreadLocal() { + private static final InheritableThreadLocal LIFECYCLE + = new InheritableThreadLocal() { @Override protected AllureLifecycle initialValue() { return Allure.getLifecycle(); @@ -85,7 +86,7 @@ protected AllureLifecycle initialValue() { }; public static AllureLifecycle getLifecycle() { - return lifecycle.get(); + return LIFECYCLE.get(); } /** @@ -250,7 +251,7 @@ public void exceptionIgnored(final IgnoredException ignoredException) { * @param allure allure lifecycle to set */ public static void setLifecycle(final AllureLifecycle allure) { - lifecycle.set(allure); + LIFECYCLE.set(allure); } } diff --git a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/TemporalDuration.java b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/TemporalDuration.java index 17a489e27..d549ee811 100644 --- a/allure-awaitility/src/main/java/io/qameta/allure/awaitility/TemporalDuration.java +++ b/allure-awaitility/src/main/java/io/qameta/allure/awaitility/TemporalDuration.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,10 +60,7 @@ public class TemporalDuration implements TemporalAccessor { @Override public boolean isSupported(final TemporalField field) { - if (!temporal.isSupported(field)) { - return false; - } - return temporal.getLong(field) - BASE.getLong(field) != 0L; + return temporal.isSupported(field) && temporal.getLong(field) - BASE.getLong(field) != 0L; } @Override diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java index e62e0314f..1a3bad814 100644 --- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java +++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/ConditionListenersPositiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ import io.qameta.allure.model.Status; import io.qameta.allure.model.StepResult; import io.qameta.allure.model.TestResult; +import org.awaitility.Awaitility; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.DynamicNode; import org.junit.jupiter.api.DynamicTest; import org.junit.jupiter.api.Test; @@ -38,6 +40,11 @@ class ConditionListenersPositiveTest { + @BeforeAll + static void setup() { + Awaitility.pollInSameThread(); + } + /** * Positive test to check proper allure steps generation. *

diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java index 4b27b17e6..5c169fd63 100644 --- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java +++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsNegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ void reset() { @BeforeEach void setup() { + Awaitility.pollInSameThread(); Awaitility.setDefaultConditionEvaluationListener(new AllureAwaitilityListener()); } diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java index da5f84137..52a6b50db 100644 --- a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java +++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/GlobalSettingsPositiveTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ void reset() { @BeforeEach void setup() { + Awaitility.pollInSameThread(); Awaitility.setDefaultConditionEvaluationListener(new AllureAwaitilityListener()); } diff --git a/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java new file mode 100644 index 000000000..36a74a164 --- /dev/null +++ b/allure-awaitility/src/test/java/io/qameta/allure/awaitility/MultipleConditionsTest.java @@ -0,0 +1,70 @@ +/* + * Copyright 2016-2024 Qameta Software Inc + * + * 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.awaitility; + +import io.qameta.allure.model.Status; +import io.qameta.allure.model.TestResult; +import org.awaitility.Awaitility; +import org.junit.jupiter.api.*; + +import java.util.List; +import java.util.stream.Stream; + +import static io.qameta.allure.test.RunUtils.runWithinTestContext; +import static org.assertj.core.api.Assertions.assertThat; +import static org.awaitility.Awaitility.await; + +public class MultipleConditionsTest { + + @AfterEach + void reset() { + Awaitility.reset(); + } + + @BeforeEach + void setup() { + Awaitility.pollInSameThread(); + Awaitility.setDefaultConditionEvaluationListener(new AllureAwaitilityListener()); + } + + @TestFactory + Stream bothAwaitilityStepsShouldAppearTest() { + final List testResult = runWithinTestContext(() -> { + await().with() + .alias("First waiting") + .until(() -> true); + await().with() + .alias("Second waiting") + .until(() -> true); + }, + AllureAwaitilityListener::setLifecycle + ).getTestResults(); + + return Stream.of( + DynamicTest.dynamicTest("Exactly 2 top level step for 2 awaitility condition", () -> + assertThat(testResult.get(0).getSteps()) + .describedAs("Allure TestResult contains exactly 2 top level step for 2 awaitility condition") + .hasSize(2) + ), + DynamicTest.dynamicTest("All top level step for all awaitility condition has PASSED", () -> + assertThat(testResult.get(0).getSteps()) + .describedAs("Allure TestResult contains all top level step for all awaitility with PASSED condition") + .allMatch(step -> Status.PASSED.equals(step.getStatus())) + ) + ); + } + +} diff --git a/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java b/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java index 3db26c236..21f68bebe 100644 --- a/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java +++ b/allure-citrus/src/main/java/io/qameta/allure/citrus/AllureCitrus.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-citrus/src/test/java/io/qameta/allure/citrus/AllureCitrusTest.java b/allure-citrus/src/test/java/io/qameta/allure/citrus/AllureCitrusTest.java index a31fd6f00..7f29c0490 100644 --- a/allure-citrus/src/test/java/io/qameta/allure/citrus/AllureCitrusTest.java +++ b/allure-citrus/src/test/java/io/qameta/allure/citrus/AllureCitrusTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-cucumber4-jvm/build.gradle.kts b/allure-cucumber4-jvm/build.gradle.kts index 37b660454..26b244ee0 100644 --- a/allure-cucumber4-jvm/build.gradle.kts +++ b/allure-cucumber4-jvm/build.gradle.kts @@ -4,9 +4,11 @@ val cucumberVersion = "4.8.0" dependencies { api(project(":allure-java-commons")) - implementation("io.cucumber:cucumber-core:$cucumberVersion") - implementation("io.cucumber:cucumber-java:$cucumberVersion") + compileOnly("io.cucumber:cucumber-core:$cucumberVersion") + compileOnly("io.cucumber:cucumber-java:$cucumberVersion") testImplementation("commons-io:commons-io") + testImplementation("io.cucumber:cucumber-core:$cucumberVersion") + testImplementation("io.cucumber:cucumber-java:$cucumberVersion") testImplementation("io.github.glytching:junit-extensions") testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter-api") diff --git a/allure-cucumber4-jvm/src/main/java/cucumber/runtime/formatter/TestSourcesModelProxy.java b/allure-cucumber4-jvm/src/main/java/cucumber/runtime/formatter/TestSourcesModelProxy.java index e6af04883..f55994b76 100644 --- a/allure-cucumber4-jvm/src/main/java/cucumber/runtime/formatter/TestSourcesModelProxy.java +++ b/allure-cucumber4-jvm/src/main/java/cucumber/runtime/formatter/TestSourcesModelProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java index ecefc8ef6..b5a5d429d 100644 --- a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java +++ b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/AllureCucumber4Jvm.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ import cucumber.api.HookTestStep; import cucumber.api.HookType; -import cucumber.api.PendingException; import cucumber.api.PickleStepTestStep; import cucumber.api.Result; import cucumber.api.TestCase; +import cucumber.api.TestStep; import cucumber.api.event.ConcurrentEventListener; import cucumber.api.event.EmbedEvent; import cucumber.api.event.EventHandler; @@ -39,6 +39,7 @@ import gherkin.ast.TableRow; import gherkin.pickles.PickleCell; import gherkin.pickles.PickleRow; +import gherkin.pickles.PickleStep; import gherkin.pickles.PickleTable; import gherkin.pickles.PickleTag; import io.qameta.allure.Allure; @@ -52,12 +53,14 @@ import io.qameta.allure.model.TestResultContainer; import java.io.ByteArrayInputStream; +import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.Paths; import java.util.Collections; import java.util.Deque; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.UUID; @@ -66,6 +69,7 @@ import java.util.stream.IntStream; import java.util.stream.Stream; +import static cucumber.api.HookType.Before; import static io.qameta.allure.util.ResultsUtils.createParameter; import static io.qameta.allure.util.ResultsUtils.getStatus; import static io.qameta.allure.util.ResultsUtils.getStatusDetails; @@ -78,21 +82,15 @@ "ClassDataAbstractionCoupling", "ClassFanOutComplexity", "MultipleStringLiterals", - "PMD.ExcessiveImports", }) public class AllureCucumber4Jvm implements ConcurrentEventListener { + private static final String COLON = ":"; + private final AllureLifecycle lifecycle; - private final ConcurrentHashMap scenarioUuids = new ConcurrentHashMap<>(); private final TestSourcesModelProxy testSources = new TestSourcesModelProxy(); - private final ThreadLocal currentFeature = new InheritableThreadLocal<>(); - private final ThreadLocal currentFeatureFile = new InheritableThreadLocal<>(); - private final ThreadLocal currentTestCase = new InheritableThreadLocal<>(); - private final ThreadLocal currentContainer = new InheritableThreadLocal<>(); - private final ThreadLocal forbidTestCaseStatusChange = new InheritableThreadLocal<>(); - private final EventHandler featureStartedHandler = this::handleFeatureStartedHandler; private final EventHandler caseStartedHandler = this::handleTestCaseStarted; private final EventHandler caseFinishedHandler = this::handleTestCaseFinished; @@ -101,11 +99,14 @@ public class AllureCucumber4Jvm implements ConcurrentEventListener { private final EventHandler writeEventHandler = this::handleWriteEvent; private final EventHandler embedEventHandler = this::handleEmbedEvent; + private final Map hookStepContainerUuid = new ConcurrentHashMap<>(); + private final Map testCaseUuids = new ConcurrentHashMap<>(); + private final Map stepUuids = new ConcurrentHashMap<>(); + private final Map fixtureUuids = new ConcurrentHashMap<>(); + private static final String TXT_EXTENSION = ".txt"; private static final String TEXT_PLAIN = "text/plain"; - private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().toString(); - private static final String CLASSPATH_PREFIX = "classpath:"; - private static final String FILE_PREFIX = "file:"; + private static final String CUCUMBER_WORKING_DIR = Paths.get("").toUri().getSchemeSpecificPart(); @SuppressWarnings("unused") public AllureCucumber4Jvm() { @@ -130,39 +131,46 @@ public void setEventPublisher(final EventPublisher publisher) { publisher.registerHandlerFor(EmbedEvent.class, embedEventHandler); } - /* - Event Handlers - */ - private void handleFeatureStartedHandler(final TestSourceRead event) { testSources.addTestSourceReadEvent(event.uri, event); } private void handleTestCaseStarted(final TestCaseStarted event) { - currentFeatureFile.set(event.testCase.getUri()); - currentFeature.set(testSources.getFeature(currentFeatureFile.get())); - currentTestCase.set(event.testCase); - currentContainer.set(UUID.randomUUID().toString()); - forbidTestCaseStatusChange.set(false); + final TestCase testCase = event.getTestCase(); + final Feature feature = testSources.getFeature(testCase.getUri()); - final TestCase testCase = currentTestCase.get(); final Deque tags = new LinkedList<>(testCase.getTags()); - - final Feature feature = currentFeature.get(); final LabelBuilder labelBuilder = new LabelBuilder(feature, testCase, tags); final String name = testCase.getName(); + + // the same way full name is generated for + // org.junit.platform.engine.support.descriptor.ClasspathResourceSource + // to support io.qameta.allure.junitplatform.AllurePostDiscoveryFilter + final String fullName = String.format("%s:%d", + getTestCaseUri(testCase), + testCase.getLine() + ); + + final String testCaseUuid = testCaseUuids + .computeIfAbsent(testCase, tc -> UUID.randomUUID().toString()); + final TestResult result = new TestResult() - .setUuid(getTestCaseUuid(testCase)) + .setUuid(testCaseUuid) + .setTestCaseId(getTestCaseId(testCase)) .setHistoryId(getHistoryId(testCase)) - .setFullName(getTestCaseUri(testCase) + ":" + testCase.getLine()) + .setFullName(fullName) .setName(name) .setLabels(labelBuilder.getScenarioLabels()) .setLinks(labelBuilder.getScenarioLinks()); final ScenarioDefinition scenarioDefinition = - testSources.getScenarioDefinition(currentFeatureFile.get(), testCase.getLine()); + testSources.getScenarioDefinition( + testCase.getUri(), + testCase.getLine() + ); + if (scenarioDefinition instanceof ScenarioOutline) { result.setParameters( getExamplesAsParameters((ScenarioOutline) scenarioDefinition, testCase) @@ -178,74 +186,157 @@ private void handleTestCaseStarted(final TestCaseStarted event) { result.setDescription(description); } - final TestResultContainer resultContainer = new TestResultContainer() - .setName(String.format("%s: %s", scenarioDefinition.getKeyword(), scenarioDefinition.getName())) - .setUuid(getTestContainerUuid()) - .setChildren(Collections.singletonList(getTestCaseUuid(testCase))); - lifecycle.scheduleTestCase(result); - lifecycle.startTestContainer(getTestContainerUuid(), resultContainer); - lifecycle.startTestCase(getTestCaseUuid(testCase)); + lifecycle.startTestCase(testCaseUuid); } private void handleTestCaseFinished(final TestCaseFinished event) { + final TestCase testCase = event.getTestCase(); + final String uuid = testCaseUuids.get(testCase); + if (Objects.isNull(uuid)) { + return; + } + + final Feature feature = testSources.getFeature(testCase.getUri()); + final Result result = event.result; + final Status status = translateTestCaseStatus(result); + final StatusDetails statusDetails = getStatusDetails(result.getError()) + .orElseGet(StatusDetails::new); + + final TagParser tagParser = new TagParser(feature, testCase); + statusDetails + .setFlaky(tagParser.isFlaky()) + .setMuted(tagParser.isMuted()) + .setKnown(tagParser.isKnown()); + + lifecycle.updateTestCase(uuid, testResult -> testResult + .setStatus(status) + .setStatusDetails(statusDetails) + ); - final String uuid = getTestCaseUuid(event.testCase); - final Optional details = getStatusDetails(event.result.getError()); - details.ifPresent(statusDetails -> lifecycle.updateTestCase( - uuid, - testResult -> testResult.setStatusDetails(statusDetails) - )); lifecycle.stopTestCase(uuid); - lifecycle.stopTestContainer(getTestContainerUuid()); lifecycle.writeTestCase(uuid); - lifecycle.writeTestContainer(getTestContainerUuid()); } private void handleTestStepStarted(final TestStepStarted event) { - if (event.testStep instanceof PickleStepTestStep) { - final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep; - final String stepKeyword = Optional.ofNullable( - testSources.getKeywordFromSource(currentFeatureFile.get(), pickleStep.getStepLine()) - ).orElse("UNDEFINED"); - - final StepResult stepResult = new StepResult() - .setName(String.format("%s %s", stepKeyword, pickleStep.getPickleStep().getText())) - .setStart(System.currentTimeMillis()); - - lifecycle.startStep(getTestCaseUuid(currentTestCase.get()), getStepUuid(pickleStep), stepResult); - - pickleStep.getStepArgument().stream() - .filter(PickleTable.class::isInstance) - .findFirst() - .ifPresent(table -> createDataTableAttachment((PickleTable) table)); - } else if (event.testStep instanceof HookTestStep) { - initHook((HookTestStep) event.testStep); + final TestCase testCase = event.getTestCase(); + if (event.testStep instanceof HookTestStep) { + final HookTestStep hook = (HookTestStep) event.testStep; + + if (isFixtureHook(hook)) { + handleStartFixtureHook(testCase, hook); + } else { + handleStartStepHook(testCase, hook); + } + } else if (event.testStep instanceof PickleStepTestStep) { + handleStartPickleStep(testCase, (PickleStepTestStep) event.testStep); + } + } + + private void handleStartPickleStep(final TestCase testCase, + final PickleStepTestStep pickleStep) { + final String uuid = testCaseUuids.get(testCase); + if (Objects.isNull(uuid)) { + return; } + + final PickleStep step = pickleStep.getPickleStep(); + final String stepKeyword = Optional + .ofNullable( + testSources.getKeywordFromSource( + testCase.getUri(), + pickleStep.getStepLine() + ) + ) + .orElse(""); + + final StepResult stepResult = new StepResult() + .setName(stepKeyword + step.getText()) + .setStart(System.currentTimeMillis()); + + final String stepUuid = stepUuids.computeIfAbsent( + pickleStep, + cl -> UUID.randomUUID().toString() + ); + + lifecycle.setCurrentTestCase(uuid); + lifecycle.startStep(uuid, stepUuid, stepResult); + + pickleStep.getStepArgument() + .stream() + .filter(PickleTable.class::isInstance) + .map(PickleTable.class::cast) + .findFirst() + .ifPresent(this::createDataTableAttachment); + } - private void initHook(final HookTestStep hook) { + private void handleStartStepHook(final TestCase testCase, + final HookTestStep hook) { + final String uuid = testCaseUuids.get(testCase); + if (Objects.isNull(uuid)) { + return; + } - final FixtureResult hookResult = new FixtureResult() + final StepResult stepResult = new StepResult() .setName(hook.getCodeLocation()) .setStart(System.currentTimeMillis()); - if (hook.getHookType() == HookType.Before) { - lifecycle.startPrepareFixture(getTestContainerUuid(), getHookStepUuid(hook), hookResult); - } else { - lifecycle.startTearDownFixture(getTestContainerUuid(), getHookStepUuid(hook), hookResult); + final String stepUuid = stepUuids.computeIfAbsent( + hook, unused -> UUID.randomUUID().toString() + ); + + lifecycle.setCurrentTestCase(uuid); + lifecycle.startStep(uuid, stepUuid, stepResult); + } + + private void handleStartFixtureHook(final TestCase testCase, + final HookTestStep hook) { + final String uuid = testCaseUuids.get(testCase); + if (Objects.isNull(uuid)) { + return; } + + final String containerUuid = hookStepContainerUuid + .computeIfAbsent(hook, unused -> UUID.randomUUID().toString()); + + lifecycle.startTestContainer(new TestResultContainer() + .setUuid(containerUuid) + .setChildren(Collections.singletonList(uuid)) + ); + + final FixtureResult hookResult = new FixtureResult() + .setName(hook.getCodeLocation()); + + final String fixtureUuid = fixtureUuids.computeIfAbsent( + hook, unused -> UUID.randomUUID().toString() + ); + if (hook.getHookType() == Before) { + lifecycle.startPrepareFixture(containerUuid, fixtureUuid, hookResult); + } else { + lifecycle.startTearDownFixture(containerUuid, fixtureUuid, hookResult); + } } private void handleTestStepFinished(final TestStepFinished event) { if (event.testStep instanceof HookTestStep) { - handleHookStep(event); - } else { - handlePickleStep(event); + final HookTestStep hook = (HookTestStep) event.testStep; + if (isFixtureHook(hook)) { + handleStopHookStep(event.result, hook); + } else { + handleStopStep(event.getTestCase(), event.result, hook); + } + } else if (event.testStep instanceof PickleStepTestStep) { + final PickleStepTestStep pickleStep = (PickleStepTestStep) event.testStep; + handleStopStep(event.getTestCase(), event.result, pickleStep); } } + private static boolean isFixtureHook(final HookTestStep hook) { + return hook.getHookType() == Before || hook.getHookType() == HookType.After; + } + private void handleWriteEvent(final WriteEvent event) { lifecycle.addAttachment( "Text output", @@ -256,34 +347,41 @@ private void handleWriteEvent(final WriteEvent event) { } private void handleEmbedEvent(final EmbedEvent event) { - lifecycle.addAttachment("Screenshot", null, null, new ByteArrayInputStream(event.data)); + lifecycle.addAttachment( + Objects.isNull(event.name) + ? "Embedding" + : event.name, + event.mimeType, + null, + new ByteArrayInputStream(event.data) + ); } - /* - Utility Methods - */ - - private String getTestContainerUuid() { - return currentContainer.get(); + private String getHistoryId(final TestCase testCase) { + final String testCaseLocation = getTestCaseUri(testCase) + COLON + testCase.getLine(); + return md5(testCaseLocation); } - private String getTestCaseUuid(final TestCase testCase) { - return scenarioUuids.computeIfAbsent(getHistoryId(testCase), it -> UUID.randomUUID().toString()); + private String getTestCaseId(final TestCase testCase) { + final String testCaseId = getTestCaseUri(testCase) + COLON + testCase.getName(); + return md5(testCaseId); } - private String getStepUuid(final PickleStepTestStep step) { - return currentFeature.get().getName() + getTestCaseUuid(currentTestCase.get()) - + step.getPickleStep().getText() + step.getStepLine(); - } + private String getTestCaseUri(final TestCase testCase) { + final String testCaseUri = getUriWithoutScheme(testCase); - private String getHookStepUuid(final HookTestStep step) { - return currentFeature.get().getName() + getTestCaseUuid(currentTestCase.get()) - + step.getHookType().toString() + step.getCodeLocation(); + if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) { + return testCaseUri.substring(CUCUMBER_WORKING_DIR.length()); + } + return testCaseUri; } - private String getHistoryId(final TestCase testCase) { - final String testCaseLocation = getTestCaseUri(testCase) + ":" + testCase.getLine(); - return md5(testCaseLocation); + private static String getUriWithoutScheme(final TestCase testCase) { + try { + return URI.create(testCase.getUri()).getSchemeSpecificPart(); + } catch (Exception ignored) { + return testCase.getUri(); + } } private Status translateTestCaseStatus(final Result testCaseResult) { @@ -304,139 +402,116 @@ private Status translateTestCaseStatus(final Result testCaseResult) { } private List getExamplesAsParameters( - final ScenarioOutline scenarioOutline, final TestCase localCurrentTestCase) { - final Optional examplesBlock = - scenarioOutline.getExamples().stream() + final ScenarioOutline scenario, + final TestCase localCurrentTestCase) { + final Optional maybeExample = + scenario.getExamples().stream() .filter(example -> example.getTableBody().stream() - .anyMatch(row -> row.getLocation().getLine() == localCurrentTestCase.getLine()) - ).findFirst(); - - if (examplesBlock.isPresent()) { - final TableRow row = examplesBlock.get().getTableBody().stream() - .filter(example -> example.getLocation().getLine() == localCurrentTestCase.getLine()) - .findFirst().get(); - return IntStream.range(0, examplesBlock.get().getTableHeader().getCells().size()).mapToObj(index -> { - final String name = examplesBlock.get().getTableHeader().getCells().get(index).getValue(); - final String value = row.getCells().get(index).getValue(); - return createParameter(name, value); - }).collect(Collectors.toList()); - } else { + .anyMatch(row -> row.getLocation().getLine() + == localCurrentTestCase.getLine()) + ) + .findFirst(); + + if (!maybeExample.isPresent()) { return Collections.emptyList(); } + + final Examples examples = maybeExample.get(); + + final Optional maybeRow = examples.getTableBody().stream() + .filter(example -> example.getLocation().getLine() == localCurrentTestCase.getLine()) + .findFirst(); + + if (!maybeRow.isPresent()) { + return Collections.emptyList(); + } + + final TableRow row = maybeRow.get(); + + return IntStream.range(0, examples.getTableHeader().getCells().size()) + .mapToObj(index -> { + final String name = examples.getTableHeader().getCells().get(index).getValue(); + final String value = row.getCells().get(index).getValue(); + return createParameter(name, value); + }) + .collect(Collectors.toList()); } private void createDataTableAttachment(final PickleTable pickleTable) { final List rows = pickleTable.getRows(); final StringBuilder dataTableCsv = new StringBuilder(); - if (!rows.isEmpty()) { - rows.forEach(dataTableRow -> { - dataTableCsv.append( - dataTableRow.getCells().stream() - .map(PickleCell::getValue) - .collect(Collectors.joining("\t")) - ); - dataTableCsv.append('\n'); - }); - - final String attachmentSource = lifecycle - .prepareAttachment("Data table", "text/tab-separated-values", "csv"); - lifecycle.writeAttachment(attachmentSource, - new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))); + for (PickleRow row : rows) { + final String rowString = row.getCells().stream() + .map(PickleCell::getValue) + .collect(Collectors.joining("\t", "", "\n")); + dataTableCsv.append(rowString); } + final String attachmentSource = lifecycle + .prepareAttachment("Data table", "text/tab-separated-values", "csv"); + lifecycle.writeAttachment(attachmentSource, + new ByteArrayInputStream(dataTableCsv.toString().getBytes(StandardCharsets.UTF_8))); } - private void handleHookStep(final TestStepFinished event) { - final HookTestStep hookStep = (HookTestStep) event.testStep; - final String uuid = getHookStepUuid(hookStep); - final FixtureResult fixtureResult = new FixtureResult().setStatus(translateTestCaseStatus(event.result)); - - if (!Status.PASSED.equals(fixtureResult.getStatus())) { - final TestResult testResult = new TestResult().setStatus(translateTestCaseStatus(event.result)); - final StatusDetails statusDetails = getStatusDetails(event.result.getError()) - .orElseGet(StatusDetails::new); - - final String errorMessage = event.result.getError() == null - ? hookStep.getHookType().name() + " is failed." - : hookStep.getHookType().name() + " is failed: " - + event.result.getError().getLocalizedMessage(); - - statusDetails.setMessage(errorMessage); - - if (hookStep.getHookType() == HookType.Before) { - final TagParser tagParser = new TagParser(currentFeature.get(), currentTestCase.get()); - statusDetails - .setFlaky(tagParser.isFlaky()) - .setMuted(tagParser.isMuted()) - .setKnown(tagParser.isKnown()); - testResult.setStatus(Status.SKIPPED); - updateTestCaseStatus(testResult.getStatus()); - forbidTestCaseStatusChange.set(true); - } else { - testResult.setStatus(Status.BROKEN); - updateTestCaseStatus(testResult.getStatus()); - } - fixtureResult.setStatusDetails(statusDetails); + private void handleStopHookStep(final Result eventResult, + final HookTestStep hook) { + final String containerUuid = hookStepContainerUuid.get(hook); + if (Objects.isNull(containerUuid)) { + // maybe throw an exception? + return; } - lifecycle.updateFixture(uuid, result -> result.setStatus(fixtureResult.getStatus()) - .setStatusDetails(fixtureResult.getStatusDetails())); + final String uuid = fixtureUuids.get(hook); + if (Objects.isNull(uuid)) { + // maybe throw an exception? + return; + } + + final Status status = translateTestCaseStatus(eventResult); + final StatusDetails statusDetails = getStatusDetails(eventResult.getError()) + .orElseGet(StatusDetails::new); + + lifecycle.updateFixture(uuid, result -> result + .setStatus(status) + .setStatusDetails(statusDetails) + ); lifecycle.stopFixture(uuid); + + lifecycle.stopTestContainer(containerUuid); + lifecycle.writeTestContainer(containerUuid); } - private void handlePickleStep(final TestStepFinished event) { + private void handleStopStep(final TestCase testCase, + final Result eventResult, + final TestStep step) { + final String stepUuid = stepUuids.get(step); + if (Objects.isNull(stepUuid)) { + // maybe exception? + return; + } - final Status stepStatus = translateTestCaseStatus(event.result); - final StatusDetails statusDetails; - if (event.result.getStatus() == Result.Type.UNDEFINED) { - updateTestCaseStatus(Status.PASSED); + final Feature feature = testSources.getFeature(testCase.getUri()); - statusDetails = - getStatusDetails(new PendingException("TODO: implement me")) - .orElse(new StatusDetails()); - lifecycle.updateTestCase(getTestCaseUuid(currentTestCase.get()), scenarioResult -> - scenarioResult - .setStatusDetails(statusDetails)); - } else { - statusDetails = - getStatusDetails(event.result.getError()) - .orElse(new StatusDetails()); - updateTestCaseStatus(stepStatus); - } + final Status stepStatus = translateTestCaseStatus(eventResult); - if (!Status.PASSED.equals(stepStatus) && stepStatus != null) { - forbidTestCaseStatusChange.set(true); - } + final StatusDetails statusDetails + = eventResult.getStatus() == Result.Type.UNDEFINED + ? new StatusDetails().setMessage("Undefined Step. Please add step definition") + : getStatusDetails(eventResult.getError()) + .orElse(new StatusDetails()); - final TagParser tagParser = new TagParser(currentFeature.get(), currentTestCase.get()); + final TagParser tagParser = new TagParser(feature, testCase); statusDetails .setFlaky(tagParser.isFlaky()) .setMuted(tagParser.isMuted()) .setKnown(tagParser.isKnown()); - lifecycle.updateStep(getStepUuid((PickleStepTestStep) event.testStep), - stepResult -> stepResult.setStatus(stepStatus).setStatusDetails(statusDetails)); - lifecycle.stopStep(getStepUuid((PickleStepTestStep) event.testStep)); - } - - private void updateTestCaseStatus(final Status status) { - if (!forbidTestCaseStatusChange.get()) { - lifecycle.updateTestCase(getTestCaseUuid(currentTestCase.get()), - result -> result.setStatus(status)); - } - } - - private String getTestCaseUri(final TestCase testCase) { - final String testCaseUri = testCase.getUri(); - if (testCaseUri.startsWith(CUCUMBER_WORKING_DIR)) { - return testCaseUri.substring(CUCUMBER_WORKING_DIR.length()); - } - if (testCaseUri.startsWith(CLASSPATH_PREFIX)) { - return testCaseUri.substring(CLASSPATH_PREFIX.length()); - } - if (testCaseUri.startsWith(FILE_PREFIX)) { - return testCaseUri.substring(FILE_PREFIX.length()); - } - return testCaseUri; + lifecycle.updateStep( + stepUuid, + stepResult -> stepResult + .setStatus(stepStatus) + .setStatusDetails(statusDetails) + ); + lifecycle.stopStep(stepUuid); } } diff --git a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java index 9958e8e85..fbcbb3f10 100644 --- a/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java +++ b/allure-cucumber4-jvm/src/main/java/io/qameta/allure/cucumber4jvm/LabelBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,8 +49,8 @@ /** * Scenario labels and links builder. */ -@SuppressWarnings({"CyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.NcssCount", "MultipleStringLiterals"}) -class LabelBuilder { +@SuppressWarnings({"CyclomaticComplexity", "MultipleStringLiterals"}) +final class LabelBuilder { private static final Logger LOGGER = LoggerFactory.getLogger(LabelBuilder.class); private static final String COMPOSITE_TAG_DELIMITER = "="; @@ -89,34 +89,34 @@ class LabelBuilder { switch (tagKey) { case SEVERITY: - getScenarioLabels().add(ResultsUtils.createSeverityLabel(tagValue.toLowerCase())); + scenarioLabels.add(ResultsUtils.createSeverityLabel(tagValue.toLowerCase())); break; case TMS_LINK: - getScenarioLinks().add(ResultsUtils.createTmsLink(tagValue)); + scenarioLinks.add(ResultsUtils.createTmsLink(tagValue)); break; case ISSUE_LINK: - getScenarioLinks().add(ResultsUtils.createIssueLink(tagValue)); + scenarioLinks.add(ResultsUtils.createIssueLink(tagValue)); break; case PLAIN_LINK: - getScenarioLinks().add(ResultsUtils.createLink(null, tagValue, tagValue, null)); + scenarioLinks.add(ResultsUtils.createLink(null, tagValue, tagValue, null)); break; default: LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey); - getScenarioLabels().add(getTagLabel(tag)); + scenarioLabels.add(getTagLabel(tag)); break; } } else if (tagParser.isPureSeverityTag(tag)) { - getScenarioLabels().add(ResultsUtils.createSeverityLabel(tagString.substring(1))); + scenarioLabels.add(ResultsUtils.createSeverityLabel(tagString.substring(1))); } else if (!tagParser.isResultTag(tag)) { - getScenarioLabels().add(getTagLabel(tag)); + scenarioLabels.add(getTagLabel(tag)); } } final String featureName = feature.getName(); final String uri = scenario.getUri(); - getScenarioLabels().addAll(ResultsUtils.getProvidedLabels()); - getScenarioLabels().addAll(Arrays.asList( + scenarioLabels.addAll(ResultsUtils.getProvidedLabels()); + scenarioLabels.addAll(Arrays.asList( createHostLabel(), createThreadLabel(), createFeatureLabel(featureName), @@ -130,7 +130,7 @@ class LabelBuilder { featurePackage(uri, featureName) .map(ResultsUtils::createPackageLabel) - .ifPresent(getScenarioLabels()::add); + .ifPresent(scenarioLabels::add); } public List

- * An attachment is simply a method annotated with - * {@link ru.yandex.qatools.allure.annotations.Attachment} returns - * either String or byte array which should be added to report: - *

- *

- *  @Attachment(value = "Page screenshot", type = "image/png")
- *  public byte[] saveScreenshot(byte[] screenShot) {
- *      return screenShot;
- *  }
- *  
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Attachment { - - /** - * Attachment name. - */ - String value() default "{method}"; - - /** - * Valid attachment MimeType, for example "text/plain" or "application/json". - */ - String type() default ""; -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Description.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Description.java deleted file mode 100644 index 694d1ad63..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Description.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import ru.yandex.qatools.allure.model.DescriptionType; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Using this annotation you can add some text description - * to test suite or test case. - *
- * @Test
- * @Description("This is an example of my test")
- * public void myTest() throws Exception {
- *      ...
- * }
- * 
- * @see ru.yandex.qatools.allure.model.DescriptionType - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Description { - - String value(); - - DescriptionType type() default DescriptionType.TEXT; - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Features.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Features.java deleted file mode 100644 index 32ed82576..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Features.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * In order to group your tests by features simply annotate test suite - * or test case with {@link ru.yandex.qatools.allure.annotations.Features} - * annotation. This annotation can take either one string or a string - * array because one test case can relate to several features: - *

- *

- * @Features({"Feature1", "Feature2"})
- * @Test
- * public void myTest() {
- *     ...
- * }
- *
- * @Features("Feature")
- * @Test
- * public void myTest() {
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Features { - - String[] value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issue.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issue.java deleted file mode 100644 index 82e0af871..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issue.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to link a single issue from issue tracker to test cases and test suites. Usage: - *
- * @Issue("MYPROJECT-1")
- * public void myTest() {
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Issue { - - String value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issues.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issues.java deleted file mode 100644 index 6dc700f9d..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Issues.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to link multiple issues from issue tracker to test cases and test suites. Usage: - *

- *

- * @Issues({
- *     @Issue("MYPROJECT-1"),
- *     @Issue("MYPROJECT-2")
- * })
- * public void myTest(){
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Issues { - - Issue[] value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Parameter.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Parameter.java deleted file mode 100644 index 970a73448..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Parameter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * You can use this annotation to add parameters to your tests: - *
- * @Parameter("My Param")
- * private String myParameter;
- *
- * @Test
- * public void myTest() throws Exception {
- *      myParameter = "first";
- *      myParameter = "second";
- *      myParameter = "third";
- * }
- * 
- * All three values will be added to report - * - * Note that the initializations of constant fields (static final fields - * where the initializer is a constant string object or primitive value) - * are not join points, since Java requires their references to be inlined. - * - * value - it's name of parameter, field name by default - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD, ElementType.PARAMETER}) -public @interface Parameter { - - String value() default ""; - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Severity.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Severity.java deleted file mode 100644 index 1d0c86e75..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Severity.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import ru.yandex.qatools.allure.model.SeverityLevel; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Each test has severity level. You can change test case severity - * label using this annotation. - * - * @see ru.yandex.qatools.allure.model.SeverityLevel - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Severity { - - SeverityLevel value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Step.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Step.java deleted file mode 100644 index 92f3266fb..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Step.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * In order to define steps you need to annotate respective methods - * with @Step annotation. When not specified step name equals to - * annotated method name converted to human readable format. To - * define explicit step name: - *
- * @Step("Open '{0}' page.")
- * public void openPageByAddress(String pageAddress) {
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Step { - - String value() default ""; - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Stories.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Stories.java deleted file mode 100644 index 09e4470fb..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Stories.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * In order to group your tests by stories simply annotate test suite - * or test case with {@link ru.yandex.qatools.allure.annotations.Stories} - * annotation. This annotation can take either one string or a string - * array because one test case can relate to several stories: - *
- * @Stories({"Story1", "Story2"})
- * @Test
- * public void myTest() {
- *     ...
- * }
- *
- * @Stories("Story")
- * @Test
- * public void myTest() {
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Stories { - - String[] value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/TestCaseId.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/TestCaseId.java deleted file mode 100644 index 3b43d7f23..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/TestCaseId.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to link a test method with a test case in Test Management System (TMS). Usage: - *
- * @TestCaseId("MYPROJECT-1")
- * public void myTest() {
- *     ...
- * }
- * 
- */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface TestCaseId { - - String value(); - -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Title.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Title.java deleted file mode 100644 index cfc836e6b..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/annotations/Title.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.annotations; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to set test suite and test case title. - * Title overrides default name in report. - * - * @author Dmitry Baev charlie@yandex-team.ru - * Date: 10.24.13 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.TYPE}) -public @interface Title { - - String value(); -} diff --git a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/model/SeverityLevel.java b/allure-java-migration/src/main/java/ru/yandex/qatools/allure/model/SeverityLevel.java deleted file mode 100644 index e37bf5b71..000000000 --- a/allure-java-migration/src/main/java/ru/yandex/qatools/allure/model/SeverityLevel.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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 ru.yandex.qatools.allure.model; - -/** - * Severity level. - */ -public enum SeverityLevel { - - BLOCKER("blocker"), - - CRITICAL("critical"), - - NORMAL("normal"), - - MINOR("minor"), - - TRIVIAL("trivial"); - - private final String value; - - SeverityLevel(final String v) { - value = v; - } - - public String value() { - return value; - } - -} diff --git a/allure-java-migration/src/main/resources/META-INF/aop-ajc.xml b/allure-java-migration/src/main/resources/META-INF/aop-ajc.xml deleted file mode 100644 index cd3df04f5..000000000 --- a/allure-java-migration/src/main/resources/META-INF/aop-ajc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1AttachAspectsTest.java b/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1AttachAspectsTest.java deleted file mode 100644 index 47df223cf..000000000 --- a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1AttachAspectsTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.aspects; - -import io.qameta.allure.model.TestResult; -import io.qameta.allure.test.AllureResults; -import org.junit.jupiter.api.Test; -import ru.yandex.qatools.allure.annotations.Attachment; - -import static io.qameta.allure.test.RunUtils.runWithinTestContext; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -/** - * eroshenkoam - * 30.04.17 - */ -class Allure1AttachAspectsTest { - - @Test - void shouldSetupAttachmentTitleFromAnnotation() { - final AllureResults results = runWithinTestContext( - () -> attachmentWithTitleAndType("parameter value"), - Allure1AttachAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getAttachments) - .extracting("name", "type") - .containsExactly(tuple("attachment with parameter value", "text/plain")); - - } - - @Test - void shouldSetupAttachmentTitleFromMethodSignature() { - final AllureResults results = runWithinTestContext( - this::attachmentWithoutTitle, - Allure1AttachAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getAttachments) - .extracting("name", "type") - .containsExactly(tuple("attachmentWithoutTitle", null)); - - } - - @Test - void shouldProcessNullAttachment() { - final AllureResults results = runWithinTestContext( - this::attachmentWithNullValue, - Allure1AttachAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getAttachments) - .extracting("name", "type") - .containsExactly(tuple("attachmentWithNullValue", null)); - } - - @SuppressWarnings("all") - @Attachment - byte[] attachmentWithNullValue() { - return null; - } - - @SuppressWarnings("all") - @Attachment - byte[] attachmentWithoutTitle() { - return new byte[]{}; - } - - @SuppressWarnings({"all"}) - @Attachment(value = "attachment with {0}", type = "text/plain") - byte[] attachmentWithTitleAndType(String parameter) { - return new byte[]{}; - } - -} diff --git a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1StepsAspectsTest.java b/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1StepsAspectsTest.java deleted file mode 100644 index 6458b5f47..000000000 --- a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1StepsAspectsTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.aspects; - -import io.qameta.allure.model.StepResult; -import io.qameta.allure.model.TestResult; -import io.qameta.allure.test.AllureResults; -import org.junit.jupiter.api.Test; -import ru.yandex.qatools.allure.annotations.Step; - -import static io.qameta.allure.test.RunUtils.runWithinTestContext; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -public class Allure1StepsAspectsTest { - - @Test - void shouldSetupStepTitleFromAnnotation() { - final AllureResults results = runWithinTestContext( - () -> stepWithTitleAndWithParameter("parameter value"), - Allure1StepsAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getSteps) - .extracting(StepResult::getName) - .containsExactly("step with title and parameter [parameter value]"); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getSteps) - .flatExtracting(StepResult::getParameters) - .extracting("name", "value") - .containsExactly(tuple("parameter", "parameter value")); - } - - @Test - void shouldSetupStepTitleFromMethodSignature() { - final AllureResults results = runWithinTestContext( - () -> stepWithoutTitleAndWithParameter("parameter value"), - Allure1StepsAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getSteps) - .extracting(StepResult::getName) - .containsExactly("stepWithoutTitleAndWithParameter[parameter value]"); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getSteps) - .flatExtracting(StepResult::getParameters) - .extracting("name", "value") - .containsExactly(tuple("parameter", "parameter value")); - } - - @SuppressWarnings("all") - @Step - void stepWithoutTitleAndWithParameter(String parameter) { - - } - - @SuppressWarnings("all") - @Step("step with title and parameter [{0}]") - void stepWithTitleAndWithParameter(String parameter) { - } - -} diff --git a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1TestCaseAspectsTest.java b/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1TestCaseAspectsTest.java deleted file mode 100644 index 9f92462a7..000000000 --- a/allure-java-migration/src/test/java/io/qameta/allure/aspects/Allure1TestCaseAspectsTest.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * 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.aspects; - -import io.qameta.allure.model.Label; -import io.qameta.allure.model.Link; -import io.qameta.allure.model.TestResult; -import io.qameta.allure.test.AllureResults; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.MethodSource; -import ru.yandex.qatools.allure.annotations.Description; -import ru.yandex.qatools.allure.annotations.Features; -import ru.yandex.qatools.allure.annotations.Issue; -import ru.yandex.qatools.allure.annotations.Issues; -import ru.yandex.qatools.allure.annotations.Parameter; -import ru.yandex.qatools.allure.annotations.Severity; -import ru.yandex.qatools.allure.annotations.Stories; -import ru.yandex.qatools.allure.annotations.TestCaseId; -import ru.yandex.qatools.allure.annotations.Title; -import ru.yandex.qatools.allure.model.SeverityLevel; - -import java.util.stream.Stream; - -import static io.qameta.allure.test.RunUtils.runWithinTestContext; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.tuple; - -/** - * eroshenkoam - * 30.04.17 - */ -class Allure1TestCaseAspectsTest { - - static Stream testClassesProvider() { - return Stream.of(new JunitTest(), new TestNgTest()); - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessFeaturesAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getLabels) - .filteredOn(label -> label.getName().equals("feature")) - .extracting(Label::getValue) - .containsExactlyInAnyOrder("feature1", "feature2"); - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessStoriesAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getLabels) - .filteredOn(label -> label.getName().equals("story")) - .extracting(Label::getValue) - .containsExactlyInAnyOrder("story1", "story2"); - - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessSeverityAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getLabels) - .filteredOn(label -> label.getName().equals("severity")) - .extracting(Label::getValue) - .containsExactlyInAnyOrder(SeverityLevel.CRITICAL.value()); - - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessIssuesAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getLinks) - .extracting(Link::getName) - .containsExactlyInAnyOrder("ISSUE-1", "ISSUE-11", "ISSUE-2", "ISSUE-22", "TEST-1"); - - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessTitleAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getName) - .containsExactlyInAnyOrder("testcase"); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getLabels) - .filteredOn(label -> label.getName().equals("suite")) - .extracting(Label::getValue) - .containsExactlyInAnyOrder("testsuite"); - } - - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessDescriptionAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getDescription) - .containsExactlyInAnyOrder("testcase description"); - - } - - @SuppressWarnings("unchecked") - @Issue("206") - @ParameterizedTest - @MethodSource("testClassesProvider") - void shouldProcessParameterAnnotation(final SimpleTest simpleTest) { - final AllureResults results = runWithinTestContext( - simpleTest::testSomething, - Allure1TestCaseAspects::setLifecycle, - Allure1ParametersAspects::setLifecycle - ); - - assertThat(results.getTestResults()) - .flatExtracting(TestResult::getParameters) - .extracting(io.qameta.allure.model.Parameter::getName, io.qameta.allure.model.Parameter::getValue) - .containsExactlyInAnyOrder( - tuple("parameterWithoutName", "testValue1"), - tuple("customParameterName", "testValue2") - ); - } - - public interface SimpleTest { - - void testSomething(); - - } - - @Title("testsuite") - @Issue("ISSUE-1") - @Issues(@Issue("ISSUE-11")) - @Stories("story1") - @Features("feature1") - public static class TestNgTest implements SimpleTest { - - @Parameter - public String parameterWithoutName; - @Parameter("customParameterName") - private String parameterWithName; - @Parameter - private String uninitializedParameter; - - @Title("testcase") - @Description("testcase description") - @Issue("ISSUE-2") - @Issues(@Issue("ISSUE-22")) - @TestCaseId("TEST-1") - @Stories("story2") - @Features("feature2") - @Severity(SeverityLevel.CRITICAL) - @org.testng.annotations.Test - public void testSomething() { - parameterWithoutName = "testValue1"; - parameterWithName = "testValue2"; - } - - } - - @Title("testsuite") - @Issue("ISSUE-1") - @Issues(@Issue("ISSUE-11")) - @Stories("story1") - @Features("feature1") - public static class JunitTest implements SimpleTest { - - @Parameter - private String parameterWithoutName; - @Parameter("customParameterName") - private String parameterWithName; - @Parameter - private String uninitializedParameter; - - @Title("testcase") - @Description("testcase description") - @Issue("ISSUE-2") - @Issues(@Issue("ISSUE-22")) - @TestCaseId("TEST-1") - @Stories("story2") - @Features("feature2") - @Severity(SeverityLevel.CRITICAL) - @org.junit.Test - public void testSomething() { - parameterWithoutName = "testValue1"; - parameterWithName = "testValue2"; - } - - } -} diff --git a/allure-java-migration/src/test/resources/allure.properties b/allure-java-migration/src/test/resources/allure.properties deleted file mode 100644 index 9c0b0a2d7..000000000 --- a/allure-java-migration/src/test/resources/allure.properties +++ /dev/null @@ -1,2 +0,0 @@ -allure.results.directory=build/allure-results -allure.label.epic=#project.description# diff --git a/allure-jax-rs/build.gradle.kts b/allure-jax-rs/build.gradle.kts index 4e1e965e8..acf1b19c9 100644 --- a/allure-jax-rs/build.gradle.kts +++ b/allure-jax-rs/build.gradle.kts @@ -4,7 +4,8 @@ val javaxWsRsApiVersion = "2.1.1" dependencies { api(project(":allure-attachments")) - implementation("javax.ws.rs:javax.ws.rs-api:$javaxWsRsApiVersion") + compileOnly("javax.ws.rs:javax.ws.rs-api:$javaxWsRsApiVersion") + testImplementation("javax.ws.rs:javax.ws.rs-api:$javaxWsRsApiVersion") testImplementation("com.github.tomakehurst:wiremock") testImplementation("org.assertj:assertj-core") testImplementation("org.jboss.resteasy:resteasy-client") diff --git a/allure-jax-rs/src/main/java/io/qameta/allure/jaxrs/AllureJaxRs.java b/allure-jax-rs/src/main/java/io/qameta/allure/jaxrs/AllureJaxRs.java index 7d28b0a1f..d7f61baa0 100644 --- a/allure-jax-rs/src/main/java/io/qameta/allure/jaxrs/AllureJaxRs.java +++ b/allure-jax-rs/src/main/java/io/qameta/allure/jaxrs/AllureJaxRs.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jax-rs/src/test/java/io/qameta/allure/httpclient/AllureJaxRsTest.java b/allure-jax-rs/src/test/java/io/qameta/allure/httpclient/AllureJaxRsTest.java index 3f3ea9e27..d0bc75158 100644 --- a/allure-jax-rs/src/test/java/io/qameta/allure/httpclient/AllureJaxRsTest.java +++ b/allure-jax-rs/src/test/java/io/qameta/allure/httpclient/AllureJaxRsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jbehave/build.gradle.kts b/allure-jbehave/build.gradle.kts index 160a03e87..3be58500b 100644 --- a/allure-jbehave/build.gradle.kts +++ b/allure-jbehave/build.gradle.kts @@ -4,8 +4,9 @@ val jbehaveVersion = "4.8.3" dependencies { api(project(":allure-java-commons")) - implementation("org.jbehave:jbehave-core:$jbehaveVersion") + compileOnly("org.jbehave:jbehave-core:$jbehaveVersion") testImplementation("org.assertj:assertj-core") + testImplementation("org.jbehave:jbehave-core:$jbehaveVersion") testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.mockito:mockito-core") testImplementation("org.slf4j:slf4j-simple") diff --git a/allure-jbehave/src/main/java/io/qameta/allure/jbehave/AllureJbehave.java b/allure-jbehave/src/main/java/io/qameta/allure/jbehave/AllureJbehave.java index b362e3e71..d1ee185b7 100644 --- a/allure-jbehave/src/main/java/io/qameta/allure/jbehave/AllureJbehave.java +++ b/allure-jbehave/src/main/java/io/qameta/allure/jbehave/AllureJbehave.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/AllureJbehaveTest.java b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/AllureJbehaveTest.java index a2f7fe9c2..1f1917b97 100644 --- a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/AllureJbehaveTest.java +++ b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/AllureJbehaveTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ */ package io.qameta.allure.jbehave; -import io.qameta.allure.Allure; -import io.qameta.allure.AllureLifecycle; import io.qameta.allure.Issue; import io.qameta.allure.jbehave.samples.BrokenStorySteps; import io.qameta.allure.jbehave.samples.SimpleStorySteps; @@ -27,7 +25,7 @@ import io.qameta.allure.model.StepResult; import io.qameta.allure.model.TestResult; import io.qameta.allure.test.AllureResults; -import io.qameta.allure.test.AllureResultsWriterStub; +import io.qameta.allure.test.RunUtils; import org.jbehave.core.configuration.MostUsefulConfiguration; import org.jbehave.core.embedder.Embedder; import org.jbehave.core.embedder.EmbedderControls; @@ -176,7 +174,7 @@ void shouldSetDescription() { final AllureResults results = runStories("stories/description.story"); final String expected = "This is description for current story.\n" - + "It should appear on each scenario in report"; + + "It should appear on each scenario in report"; assertThat(results.getTestResults()) .extracting(TestResult::getDescription) @@ -267,42 +265,34 @@ void shouldNotFailIfGivenStoriesSpecified() { } private AllureResults runStories(final String... storyResources) { - final AllureResultsWriterStub writer = new AllureResultsWriterStub(); - final AllureLifecycle lifecycle = new AllureLifecycle(writer); - - final Embedder embedder = new Embedder(); - embedder.useEmbedderMonitor(new NullEmbedderMonitor()); - embedder.useEmbedderControls(new EmbedderControls() - .doGenerateViewAfterStories(false) - .doFailOnStoryTimeout(false) - .doBatch(false) - .doIgnoreFailureInStories(true) - .doIgnoreFailureInView(true) - .doVerboseFailures(false) - .doVerboseFiltering(false) - ); - final AllureJbehave allureJbehave = new AllureJbehave(lifecycle); - embedder.useConfiguration(new MostUsefulConfiguration() - .useStoryLoader(new LoadFromClasspath(this.getClass())) - .useStoryReporterBuilder(new ReportlessStoryReporterBuilder(temp.toFile()) - .withReporters(allureJbehave) - ) - .useDefaultStoryReporter(new NullStoryReporter()) - ); - final InjectableStepsFactory stepsFactory = new InstanceStepsFactory( - embedder.configuration(), - new SimpleStorySteps(), - new BrokenStorySteps() - ); - embedder.useCandidateSteps(stepsFactory.createCandidateSteps()); - final AllureLifecycle cached = Allure.getLifecycle(); - try { - Allure.setLifecycle(lifecycle); + return RunUtils.runTests(lifecycle -> { + final Embedder embedder = new Embedder(); + embedder.useEmbedderMonitor(new NullEmbedderMonitor()); + embedder.useEmbedderControls(new EmbedderControls() + .doGenerateViewAfterStories(false) + .doFailOnStoryTimeout(false) + .doBatch(false) + .doIgnoreFailureInStories(true) + .doIgnoreFailureInView(true) + .doVerboseFailures(false) + .doVerboseFiltering(false) + ); + final AllureJbehave allureJbehave = new AllureJbehave(lifecycle); + embedder.useConfiguration(new MostUsefulConfiguration() + .useStoryLoader(new LoadFromClasspath(this.getClass())) + .useStoryReporterBuilder(new ReportlessStoryReporterBuilder(temp.toFile()) + .withReporters(allureJbehave) + ) + .useDefaultStoryReporter(new NullStoryReporter()) + ); + final InjectableStepsFactory stepsFactory = new InstanceStepsFactory( + embedder.configuration(), + new SimpleStorySteps(), + new BrokenStorySteps() + ); + embedder.useCandidateSteps(stepsFactory.createCandidateSteps()); embedder.runStoriesAsPaths(Arrays.asList(storyResources)); - } finally { - Allure.setLifecycle(cached); - } - return writer; + }); } static class ReportlessStoryReporterBuilder extends StoryReporterBuilder { diff --git a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/LoggingReporter.java b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/LoggingReporter.java index 19103dfb4..dc3b7ba83 100644 --- a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/LoggingReporter.java +++ b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/LoggingReporter.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/BrokenStorySteps.java b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/BrokenStorySteps.java index edc2a804e..e401c825f 100644 --- a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/BrokenStorySteps.java +++ b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/BrokenStorySteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/SimpleStorySteps.java b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/SimpleStorySteps.java index 9e7a664b0..45a93ede9 100644 --- a/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/SimpleStorySteps.java +++ b/allure-jbehave/src/test/java/io/qameta/allure/jbehave/samples/SimpleStorySteps.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/allure-jbehave5/build.gradle.kts b/allure-jbehave5/build.gradle.kts index 256e5af6d..bdd27f73d 100644 --- a/allure-jbehave5/build.gradle.kts +++ b/allure-jbehave5/build.gradle.kts @@ -4,8 +4,9 @@ val jbehaveVersion = "5.1.1" dependencies { api(project(":allure-java-commons")) - implementation("org.jbehave:jbehave-core:$jbehaveVersion") + compileOnly("org.jbehave:jbehave-core:$jbehaveVersion") testImplementation("org.assertj:assertj-core") + testImplementation("org.jbehave:jbehave-core:$jbehaveVersion") testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.mockito:mockito-core") testImplementation("org.slf4j:slf4j-simple") diff --git a/allure-jbehave5/src/main/java/io/qameta/allure/jbehave5/AllureJbehave5.java b/allure-jbehave5/src/main/java/io/qameta/allure/jbehave5/AllureJbehave5.java index 3c38c214c..5ef296db8 100644 --- a/allure-jbehave5/src/main/java/io/qameta/allure/jbehave5/AllureJbehave5.java +++ b/allure-jbehave5/src/main/java/io/qameta/allure/jbehave5/AllureJbehave5.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Qameta Software OÜ + * Copyright 2016-2024 Qameta Software Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import io.qameta.allure.model.StatusDetails; import io.qameta.allure.model.StepResult; import io.qameta.allure.model.TestResult; +import io.qameta.allure.util.ResultsUtils; import org.jbehave.core.failures.UUIDExceptionWrapper; import org.jbehave.core.model.ExamplesTable; import org.jbehave.core.model.Scenario; @@ -227,13 +228,15 @@ protected void startTestCase(final String uuid, .map(entry -> createParameter(entry.getKey(), entry.getValue())) .collect(Collectors.toList()); - final List