anemonetea
anemonetea

Reputation: 61

How to enable Allure history using Gradle and Junit5?

I know I could copy the history directory from allure-reports to a generated allure-results, and then do allure generate to get the history to show up, but I am looking for a way to achieve this with the built-in functionality in allure-gradle.

Currently, I run ./gradlew clean test, then ./gradlew allureReport, and this gives me a fresh html report with no history or reruns. I have noticed that the test task deletes the entire allure-reports directory and then re-makes and re-populates it.

Here is my 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'

}

I have also tried specifying the results and reports directories to be outside of the build directory, like this:

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

This allows the allure-results folder to keep the previous report, which show up as retries (not quite right), but history still doesn't work.

Upvotes: 0

Views: 1339

Answers (1)

Kseniya_T
Kseniya_T

Reputation: 11

I have solved this problem by adding at the running test script these lines( I have some tests scuites)

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

So I have added folder allure-results\history to keep all results

Upvotes: 1

Related Questions