Allure generates empty reports page on local machine - gradle

As the title says I cannot force Allure 2 to generate reports for me on local machine.
I've tried a lot of things from Google but nothing helped. I use Kotlin+Selenide+TestNG to write tests, if it helps somehow :)
I'm a little bit confused with Allure because it has version for testNG and version for Gradle - which one should be used? Both?
Here's my build.gradle file:
group 'RegisteredUserFlow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = "1.1.2-2"
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "ru.d10xa:gradle-allure-plugin:0.5.5"
}
}
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'ru.d10xa.allure'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
allure {
aspectjweaver = true
testNG = true
}
repositories {
jcenter()
}
configurations {
agent
}
dependencies {
agent "org.aspectj:aspectjweaver:1.8.10"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2"
testCompile "com.codeborne:selenide:4.4.3"
testCompile "org.testng:testng:6.10"
testCompile "io.qameta.allure:allure-testng:2.0-BETA6"
testCompile "io.github.bonigarcia:webdrivermanager:1.6.2"
}
test.doFirst {
jvmArgs "-javaagent:${configurations.agent.singleFile}"
}
test {
useTestNG(){
suites 'src/test/kotlin/testng.xml'
}
systemProperty 'allure.results.directory', 'build/allure-results'
systemProperty 'allure.link.issue.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
systemProperty 'allure.link.tms.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
}
tasks.withType(Test)*.finalizedBy allureReport
Commands I used were: allure serve build/allure-results and gradlew clean test allureReport
Also, do I need Java plugin?
Appreciate any help!
Thanks!
P.S. Here's the error I get in console after gradlew clean test allureReport command:
Execution failed for task ':allureReport'.
> Could not resolve all dependencies for configuration ':allureReport'.
> Could not resolve org.slf4j:slf4j-api:1.7.12.
Required by:
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > org.slf4j:slf4j-simple:1.7.12
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-data:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-plugin-api:1.4.24.RC3 > ru.yandex.qatools.allure:allure-model:1.4.24.RC3

The problem is that ru.d10xa:gradle-allure-plugin:0.5.5 is not support Allure 2. We are working on brand new Allure Gradle plugin that available here https://github.com/allure-framework/allure-gradle
At the moment you can use allure-commandline to generate the report at local machine and Allure Jenkins/Teamcity plugin to generate the report on CI.
Update
New Allure Gradle plugin that supports Allure 2 is available now. See the docs https://docs.qameta.io/allure/2.0/#_gradle_3 for more details.

Related

The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin in instead

I´m trying to run a project using gradle but I´m getting the following error.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\ISEP\ODSOFT\Projects\odsoft-21-22-nmb-g311\odsoft-21-22-nmb-g311\project\build.gradle' line: 4
* What went wrong:
An exception occurred applying plugin request [id: 'fr.putnami.gwt', version: '0.4.0']
> Failed to apply plugin class 'org.gradle.api.plugins.MavenPlugin'.
> The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin instead. See https://docs.gradle.org/7.2/userguide/publishing_maven.html#publishing_maven for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
The command I´m using to run project is gradle gwtRun.
I leave below my gradle bulid file
plugins {
id "fr.putnami.gwt" version "0.4.0"
id "maven-publish"
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
//Java version compatibility to use when compiling Java source.
sourceCompatibility = 1.8
//Java version to generate classes for.
targetCompatibility = 1.8
//Script Version
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
//testCompile 'junit:junit:4.12'
//testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.easymock:easymock:2.5.2'
testImplementation 'com.google.gwt:gwt-dev:2.8.1'
implementation 'net.sourceforge.plantuml:plantuml:8001'
//compile 'net.sourceforge.plantuml:plantuml:8001'
}
javadoc {
options.addStringOption("sourcepath", "")
}
// If we woant to use the default ant build inside gradle
// ant.importBuild "build.xml"
putnami{
module 'pt.isep.cms.Showcase'
//module 'com.google.gwt.sample.contacts.Contacts'
/** add gwt nature on eclipse project. require apply plugin: 'eclipse' to work. default : false*/
googlePluginEclipse = true
gwtVersion='2.8.1'
compile {
sourceLevel = '1.8'
}
jetty {
/** enable debugging. */
debugJava = true
/** debug port to listen. */
debugPort = 8000
/** wait for debugger attachment. */
debugSuspend = false
}
}
// Jacoco
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
}
}
// This task generates the coverage report for the integration tests.
// Notice that it only includes data about the server code sice Jaccoco is not able to get data about cliente code that is transpiled to javascript
task jacocoIntegrationReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
sourceSets sourceSets.main
executionData = files("${buildDir}/jacoco/integrationTest.exec")
reports {
html.enabled = true
xml.enabled = false
csv.enabled = false
}
}
// Integration Tests
task integrationTest(type: Test) {
filter {
//all GWT unit tests, by naming convention
includeTestsMatching "*GWTTest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
excludes = ["com/steadystate/**"]
}
// These Properties are required to run gwt integration tests
systemProperties['gwt.args'] = "-devMode -logLevel WARN -war www-test"
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
// Unit Tests
test {
filter {
//all JRE unit tests, by naming convention
includeTestsMatching "*JRETest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
}
}
From what I understood the plugin maven was removed in the version 7 of gradle. Is this sentence correct? Or is the putnami plugin that was removed?
What should I do to make it to work?
The plugin fr.putnami.gwt applies the maven plugin internally:
https://github.com/Putnami/putnami-gradle-plugin/blob/master/src/main/java/fr/putnami/gwt/gradle/PwtLibPlugin.java#L47
Therefore, fr.putnami.gwt is not compatible with Gradle 7.
As stated in the README in the repo:
A fork of it that is still supported and has a newer release is available at https://github.com/esoco/gwt-gradle-plugin. Please use the new version if you need GWT support for Gradle.
So, then the following should work:
plugins {
id "de.esoco.gwt" version "1.1.1"
}

Allure report is empty when use Allure2+Junit5+Gradle+Selenide

My build.gradle is:
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'io.qameta.allure'
defaultTasks 'clean', 'test'
ext.junitJupiterVersion = '5.0.0-M4'
ext.selenideVersion = '4.4.3'
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
options.encoding = 'UTF-8'
options.compilerArgs += "-parameters"
}
compileJava.options.encoding = 'UTF-8'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
jcenter()
mavenCentral()
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4'
classpath 'io.qameta.allure:allure-gradle:2.3'
}
}
allure {
aspectjweaver = true
autoconfigure = true
version = '2.1.1'
}
configurations {
agent
}
dependencies {
// JUnit5
compile("org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}")
compile("org.junit.jupiter:junit-jupiter-engine:${junitJupiterVersion}")
// Selenide
compile("com.codeborne:selenide:${selenideVersion}") {
exclude group: 'junit'
}
// Allure
agent 'org.aspectj:aspectjweaver:1.8.10'
compile 'ru.yandex.qatools.allure:allure-junit-adaptor:1.4.23'
compile 'io.qameta.allure:allure-junit5:2.0-BETA6'
}
junitPlatform {
platformVersion = "1.0.0-M5"
enableStandardTestTask = true
}
task runJupiter(type: JavaExec) {
jvmArgs '-ea'
jvmArgs "-javaagent:${configurations.agent.singleFile}"
classpath = project.sourceSets.test.runtimeClasspath
main 'org.junit.platform.console.ConsoleLauncher'
args '--scan-class-path'
args "--reports-dir=${buildDir}/allure-results"
finalizedBy 'allureReport'
}
test.dependsOn runJupiter
Tests are finished successfully and three folders are created automatically:
{projectDir}\allure-results with .json file
{projectDir}\build\test-results\junit-platform with TEST-junit-jupiter.xml file
{projectDir}\build\reports\allure-report
I tried to open .json and .xml result locally via allure command line (CLI). The allure report is opened but it is blank:
this is a report view
I suppose my mistake in gradle dependencies. I quite confused which libraries and versions should be used for JUnit5+Allure2+Gradle+Selenide+Java8?
The JUnit Platform Gradle plugin does currently not use the test task (it needs changes in Gradle core in order to do so). Thus, things like test.doFirst {...} are not going to work.
Instead of using the plugin, you should be able to create your own task that runs the ConsoleLauncher and add the JVM agent there. See https://stackoverflow.com/a/43512503/6327046 for an example.

Gradle skipping jacoco coverage plugin

I know there are a lot of similar questions for this on stackexchange but this is driving me crazy and nothing from any other answers have helped me. I've used just about every force flag for gradle I can find.
My Gradle version is 2.2.1
My build.gradle
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("se.transmode.gradle:gradle-docker:1.2")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'
apply plugin: 'jacoco'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
ext {
springCloudVersion = 'Dalston.RELEASE'
}
test {
include 'src/test/java'
finalizedBy jacocoTestReport
}
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
html.enabled false
xml.destination "${buildDir}/jacoco"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
When I run gradle test or gradle clean test jacocoTestReport or gradle clean --re-run etc etc I get the same results.
gradle test
:compileJava
:processResources
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test UP-TO-DATE
:jacocoTestReport SKIPPED
I have only 1 test in the src/test/java location.
Why will it not generate the reports and run? I'm at a loss.
Remove the wrong include statement in your test configuration.
That seems to cause the test task to always be up-to-date (not executing any test as the include pattern isn't matched)
The jacocoTestReport will be skipped if there's no execution data available that is needed to generate the report. This execution data should be generated while the test task is executed. In your example we see that the test task is always marked as up-to-date (because of the invalid include statement) causing the build to never produce any input for the jacocoTestReport task.
For Spring 2.5 Users, who got stuck with it for hours -just like myself.
I was not having the exec file generated.
And because of that ,
I found that the jacocoTestReport was simply "skipped".
I got it fixed by adding :
test {
useJUnitPlatform()
finalizedBy jacocoTestReport // report is always generated after tests run
}
That's because I'm using Junit5 with spring boot 2.X
It was a bit tricky to find that JaCoCo by default skips every jacocoTestCoverageVerification task in case if tests are run trough a custom named task (not just test).
For example, tests were run via unitTest in my project, JaCoCo did create build/jacoco/unitTest.exec during their execution, yet it kept searching for test.exec during verification. ¯\_(ツ)_/¯
The workaround is to override executionData path for JaCoCo gradle tasks:
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.8"
}
def coverageFile = layout -> layout.buildDirectory.file('jacoco/coverage.exec').get()
tasks.named('jacocoTestCoverageVerification') {
getExecutionData().setFrom(files(coverageFile(layout)))
violationRules {
rule {
limit {
minimum = project.properties['testCoverageThreshold'] ?: 0.5
}
}
}
}
tasks.named('jacocoTestReport') {
getExecutionData().setFrom(files(coverageFile(layout)))
}
tasks.named('unitTest') {
jacoco {
destinationFile = coverageFile(layout).asFile
}
finalizedBy jacocoTestReport, jacocoTestCoverageVerification
}

jvmArgs settings for Allure reports

I'm trying to generate reports by ussing
gradlew clean test
command. It fails with error:
Error occured during intialization of VM
Error opening zip file or JAR nanifest missing : ${configurations.agent.singleFile}
Here's my build.gradle file:
group 'RegisteredUserFlow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1.2-2'
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
jcenter()
}
configurations {
agent
}
dependencies {
agent 'org.aspectj:aspectjweaver:1.8.10'
compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2'
testCompile 'com.codeborne:selenide:4.4.3'
testCompile 'org.testng:testng:6.10'
testCompile 'io.qameta.allure:allure-testng:2.0-BETA6'
testCompile 'io.github.bonigarcia:webdrivermanager:1.6.2'
}
test.doFirst {
jvmArgs '-javaagent:${configurations.agent.singleFile}'
}
test {
useTestNG(){
suites'src/test/resources/testng.xml'
}
systemProperty 'allure.results.directory', 'build/allure-results'
systemProperty 'allure.link.issue.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
systemProperty 'allure.link.tms.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
}
I've been thinking that the problems are with aspectJ but I'm not sure.
Do I miss something in gradle file? Or is it somewhere in my test files? Or maybe there's a problems with latest Allure version? I see that jvmArgs is highlighted with gray (never used) - maybe problem with that?
Sorry for that much of questions I've never worked with Allure and aspectJ.
Thanks for any help!
Your problem is that you used a String where you should have used a GString.
jvmArgs '-javaagent:${configurations.agent.singleFile}'
This line is taken literally. It should have been
jvmArgs "-javaagent:${configurations.agent.singleFile}"
to get the placeholder replaced. (single- vs. double-quotes).

Kotlin Quasar example not working

I am testing the Kotlin Quasar actor example.
Quasar and Kotlin – a Powerful Match
So the question is, is this example out of date and is there any documentation in which I can find out how to use Kotlin and Quasar?
This is my gradle.build file.
group 'no.inmeta.kotlin.akka'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.0.1'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "co.paralleluniverse:quasar-kotlin:0.7.4"
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
I'm part of the Quasar team.
The post cites Quasar tests which you can run by cloning the Quasar repo and running e.g. gradle :quasar-kotlin:build (requires Gradle installed) but for new projects/experiments I suggest to start instead from the Gradle template, kotlin branch which now uses the latest Kotlin 1.0.1-2 (and for simplicity the latest Quasar 0.7.5-SNAPSHOT that depends on it).
Starting from that template I built this project (more info about how to configure it and run it in the main README) that runs the same Quasar actor tests as normal programs rather than tests. Here's its build.gradle:
group 'no.inmeta.kotlin.akka'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlinVer = '1.0.1-2'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVer"
}
}
apply plugin: 'kotlin'
apply plugin: 'application'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceCompatibility = 1.8 // 1.7
targetCompatibility = 1.8 // 1.7
configurations {
quasar
}
configurations.all {
resolutionStrategy {
failOnVersionConflict()
}
}
repositories {
// mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/releases" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
// maven { url 'https://maven.java.net/content/repositories/snapshots' }
}
ext.classifier = ':jdk8' // ':'
ext.quasarVer = '0.7.5-SNAPSHOT'
dependencies {
compile "co.paralleluniverse:quasar-core:${quasarVer}${classifier}"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVer"
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlinVer"
compile "co.paralleluniverse:quasar-kotlin:${quasarVer}"
quasar "co.paralleluniverse:quasar-core:${quasarVer}${classifier}#jar"
}
applicationDefaultJvmArgs = [
"-Dco.paralleluniverse.fibers.verifyInstrumentation=true",
"-Dco.paralleluniverse.fibers.detectRunawayFibers=false",
"-javaagent:${configurations.quasar.singleFile}" // =v, =d
]
// mainClassName = 'co.paralleluniverse.kotlin.actors1.PingPongKt'
mainClassName = 'co.paralleluniverse.kotlin.actors2.PingPongWithDeferKt'
task wrapper(type: Wrapper) {
gradleVersion = '2.12'
}
defaultTasks 'run'
Some notes about the differences with your build file:
Since I converted the tests to programs, I'm including the application plugin and its configuration (here, applicationDefaultJvmArgs and mainClassName) as well as setting the default Gradle task to run.
In addition to the above, a gradle wrapper has been generated and pushed so that ./gradlew is all you need on the command line, with no need to have a local Gradle installation (how to run it in an IDE depends on the IDE).
You need to run the Quasar agent (or AoT instrumentation but using the agent here) so there's a quasar configuration pointing to the artifact that is then used to pass the -javaagent:${configurations.quasar.singleFile} JVM argument.
Using Java 8 as Quasar has a specific optimized build for it.
Also note that there is now a 1.0 branch of the quasar-kotlin-jetbrains-webinar project (which is now the HEAD one in fact), which contains the companion source code of this guest webinar with IntelliJ, ported to the latest Kotlin and Quasar as well.
Let me know if this helps.

Resources