【问题标题】:How to enable Allure history using Gradle and Junit5?如何使用 Gradle 和 Junit5 启用 Allure 历史?
【发布时间】:2020-03-28 00:05:19
【问题描述】:

我知道我可以将历史目录从 allure-reports 复制到生成的 allure-results 中,然后执行 allure generate 以显示历史记录,但我正在寻找一种方法来实现这一点allure-gradle 中的功能。

目前,我运行 ./gradlew clean test,然后运行 ​​./gradlew allureReport,这为我提供了一个没有历史记录或重新运行的全新 html 报告。我注意到测试任务会删除整个 allure-reports 目录,然后重新制作并重新填充它。

这是我的 build.gradle:

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
}

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id 'java'
    id 'eclipse'
    // Allure reporter
    id 'io.qameta.allure' version '2.8.1'
}

repositories {
    mavenCentral()
    jcenter()
}

def allureVersion = "2.13.1"

allure {
    autoconfigure = true
    version = allureVersion
    useJUnit5 {
       version = '2.0-BETA10'
    }
    downloadLink = "https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/2.13.1/allure-commandline-2.13.1.zip"
}

test {
    useJUnitPlatform() {
        includeEngines 'junit-jupiter'
    }
    ignoreFailures = true
}

dependencies {       
    compile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.6.0'
    compile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.6.0'
    compile group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.6.0'
    // Needed as a workaround for JUnit 5 not failing tests that stopped due to an error message. The fix is in eclipse 4.10
    compile group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.6.0'

    compile group: 'io.qameta.allure', name: 'allure-junit5', version: '2.13.1'
    compile group: 'io.qameta.allure', name: 'allure-java-commons', version: '2.13.1'

    // https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'

}

我也尝试将结果和报告目录指定在构建目录之外,如下所示:

allure {
    autoconfigure = true
    version = allureVersion
    resultsDir = file('../../allure-results')
    reportDir = file('../../allure-report')
       ...
}

这允许 allure-results 文件夹保留以前的报告,该报告显示为重试(不太正确),但历史记录仍然不起作用。

【问题讨论】:

标签: gradle groovy junit5 allure


【解决方案1】:

我已经通过在运行的测试脚本中添加这些行来解决这个问题(我有一些测试脚本)

 call gradlew test -PsuiteFile=YOUR_TEST_SUITE.xml
 mkdir allure-results\history
 xcopy build\allure-results\* allure-results\history
 allure serve allure-results\history

所以我添加了文件夹allure-results\history 以保留所有结果

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 2017-01-14
    • 1970-01-01
    • 2018-01-09
    • 2018-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多