serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

Index.html is not generating and different name reports are generating in target folder #207

Closed RajatCodeRepo closed 4 years ago

RajatCodeRepo commented 5 years ago

Issue Description - Index.html is not generating after successful run of test cases and instead of that 4 different reports for every feature file are generating. Also, on clicking requirements section in report it is giving the below error - image

gradle.properties file - serenityCoreVersion =2.0.40 serenityCucumberVersion=1.0.6 cucumberJVMVersion=4.2.0 junitVersion = 4.12 assertCoreVersion = 3.12.0 slf4jVersion = 1.7.26 jacksonVersion=2.9.8 lombokVersion=1.18.6

build.gradle file - repositories { mavenLocal() jcenter() }

buildscript { repositories { mavenLocal() jcenter() } dependencies { classpath("net.serenity-bdd:serenity-gradle-plugin:${serenityCoreVersion}") } } //apply plugin: 'application' apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'net.serenity-bdd.aggregator'
apply plugin: 'org.ajoberstar.git-publish'

//application{ // applicationDefaultJvmArgs = ["-Duser.timezone=EDT"] //}

configurations.all { resolutionStrategy { force "io.cucumber:cucumber-core:${cucumberJVMVersion}" } }

dependencies { testCompile "net.serenity-bdd:serenity-core:${serenityCoreVersion}" testCompile "net.serenity-bdd:serenity-junit:${serenityCoreVersion}" testCompile "net.serenity-bdd:serenity-cucumber4:${serenityCucumberVersion}" testCompile "net.serenity-bdd:serenity-rest-assured:${serenityCoreVersion}" testCompile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" testCompile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" testCompile "io.cucumber:cucumber-java:${cucumberJVMVersion}" testCompile "io.cucumber:cucumber-junit:${cucumberJVMVersion}" testCompile "io.cucumber:cucumber-core:${cucumberJVMVersion}" testCompileOnly "org.projectlombok:lombok:${lombokVersion}" testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}" testCompile "io.cucumber:cucumber-expressions:6.2.0" testCompile "junit:junit:${junitVersion}" testCompile "org.assertj:assertj-core:${assertCoreVersion}" testCompile "org.slf4j:slf4j-simple:${slf4jVersion}" testCompile "net.serenity-bdd:serenity-jira-requirements-provider:1.11.0" testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.0.0'

}

serenity.properties file - serenity.project.name=ABC API Automation serenity.reports.show.step.details=true json.pretty.printing=true serenity.compress.filenames=false serenity.test.root=src/test/resources/features

Command used - clean test aggregate

wakaleo commented 5 years ago

Make sure you are using the latest versions of serenity-core and serenity-cucumber (see the serenity-cucumber-starter project for recent examples)

RajatCodeRepo commented 5 years ago

Used latest versions of serenity-core and serenity-cucumber from https://github.com/serenity-bdd/serenity-cucumber4-starter/blob/master/gradle/libraries.gradle and still facing the same issue -

serenityCoreVersion =2.0.48 serenityCucumberVersion=1.0.12 cucumberJVMVersion=4.2.0 junitVersion = 4.12 assertCoreVersion = 3.12.0 slf4jVersion = 1.7.26 jacksonVersion=2.9.8 lombokVersion=1.18.6

wakaleo commented 5 years ago

This is usually due to conflicting dependencies - can you provide a sample project that reproduces the issue?

RajatCodeRepo commented 5 years ago

@wakaleo Thanks for your quick support. I am working in a restricted network and sharing sample project is not possible. I had provided the dependency file and version in above comments, please check if that can help. Can you please share some workaround so that I can try on my own. Thanks

RajatCodeRepo commented 5 years ago

@wakaleo I have tried to run 3 feature files separately and index.html is generating but on running 4th feature file separately, report is generating by feature name and index.html is not generating. Every feature file is using same format and I am not able to find the reason why index.html is not working for 4th feature file. Please help.

nbarrett commented 5 years ago

have you tried mvn serenity:aggregate?

RajatCodeRepo commented 5 years ago

@nbarrett I am using gradle and using clean test aggregate

nbarrett commented 5 years ago

Oops, sorry, I should read the earlier posts better!, Whenever I have problems with reporting not doing what I expect, I turn up the logging by adding the following to my logback.xml as follows:

    <logger name="net.serenitybdd" level="debug"/>
    <logger name="net.thucydides" level="debug"/>

That can often show things that can point you to the source of the problem.

RajatCodeRepo commented 5 years ago

@nbarrett Thanks for your suggestion. Below are the steps I have tried : 1) Added logback gradle dependency testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '0.9.26' 2) Added a logback.xml file

%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
  1. Run 2 different features file - a. 1st Feature file - Index.html is generating and last few lines of console are like -

21:27:49.718 [Test worker] DEBUG n.t.core.reports.ReportService - Shutting down executor service 21:27:49.718 [Test worker] DEBUG n.t.core.reports.ReportService - Reports generated in: 5974 ms > Task :aggregate Generating Serenity Reports for mcap-api-automation to directory C:\Users\Rajat Goel\Pictures\test\mcap-api-automation\target\site\serenity Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0. Use '--warning-mode all' to show the individual deprecation warnings. See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings BUILD SUCCESSFUL in 37s 6 actionable tasks: 6 executed 9:27:51 PM: Tasks execution finished 'clean test aggregate'.

a. 2nd Feature file - Report is generating but Index.html is not generating and last few lines of console are like -

21:37:22.805 [Test worker] DEBUG n.t.core.reports.ReportService - Shutting down executor service 21:37:22.805 [Test worker] DEBUG n.t.core.reports.ReportService - Reports generated in: 5503 ms

So for file 2 task aggregate is not executed in last and that's why index.html is not generation. Can you please help me in finding the reason for this behavior, I am using same command both time for running files.

nbarrett commented 5 years ago

Hi again @RajatCodeRepo - I got an email from you but best to respond here. Your logback settings seem okay and as long as you put your file in the root it should be picked up. You'll know whether its working as you'll have a lot of debug messages in the console that weren't there before. Regarding arriving at a running configuration, It's normally best to use the a known combination of libraries - e.g. the ones that @wakaleo reccomended in his post above. I see you are using the following:

serenityCoreVersion =2.0.40
serenityCucumberVersion=1.0.6
cucumberJVMVersion=4.2.0

These seem like a mixture of old and new, but the versions in the serenity-cucumber-starter-project are as follows:

serenityCoreVersion = '2.0.45'
serenityCucumberVersion = '1.9.35'

Personally, I've not touched Cucumber version 4 yet as have been too busy with other priorities but my inclination is to stick with cucumberJVMVersion = 2.4.0 as that's out there and being used by many people (me included 😄 ). Hope this helps!

RajatCodeRepo commented 5 years ago

@nbarrett

Sorry for reaching out directly.Thanks for your suggestion and help.

As suggested by @wakaleo , I had already updated dependencies as per serenity-cucumber-starter project and using below dependencies

serenityCoreVersion =2.0.48 serenityCucumberVersion=1.0.12

I had debugged more and came to know that task test was failing. Due to Null pointer exception build was failing and that's why aggregate task was not performed in last and may be that can be the reason of not generating index.html See below console log-

java.lang.NullPointerException 3 tests completed, 3 failed

Task :test FAILED FAILURE: Build failed with an exception. What went wrong: Execution failed for task ':test'.

Workaround - I have added below code as per (https://www.mkyong.com/gradle/gradle-how-to-continue-build-if-test-is-failed/) in build.gradle file and now it is working fine and also index.html is generating now but build is successful.

test { ignoreFailures = true }

Can you please suggest, is there any way so that my build will fail in case of exceptions and task test and aggregate will run successfully and result in generating index.html.

Again, thanks a lot for showing me right direction and helping me in getting the issue resolved.

kpkalyan commented 4 years ago

Serenity report is showing the features and specifications details after updating the dependencies as below,

============ build.gradle

repositories { mavenCentral() jcenter() }

buildscript { repositories { mavenLocal() jcenter() } dependencies { classpath("net.serenity-bdd:serenity-gradle-plugin:2.0.91") classpath("net.serenity-bdd:serenity-emailer:2.0.91") } }

apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'net.serenity-bdd.aggregator' apply plugin: 'maven-publish' apply plugin: 'groovy'

sourceCompatibility = 1.8 targetCompatibility = 1.8

configurations.all { resolutionStrategy { force "io.cucumber:cucumber-core:4.8.0" } }

dependencies { //JUnit implementation 'com.google.guava:guava:28.0-jre' implementation 'ch.qos.logback:logback-classic:1.2.3' implementation 'ch.qos.logback:logback-core:1.2.3' implementation 'org.slf4j:slf4j-api:1.7.7' testImplementation 'junit:junit:4.12' testImplementation 'org.assertj:assertj-core:3.8.0'

//selenium
implementation 'org.seleniumhq.selenium:selenium-java:3.141.59' 

//Cucumber
implementation 'io.cucumber:cucumber-core:4.8.0'
implementation 'io.cucumber:cucumber-java:4.8.0'
implementation 'io.cucumber:cucumber-jvm:4.8.0'
implementation 'io.cucumber:cucumber-junit:4.8.0'
implementation 'io.cucumber:cucumber-testng:4.8.0'
implementation 'io.cucumber:gherkin:5.1.0'
implementation 'io.cucumber:cucumber-gherkin:5.1.0'
implementation 'io.cucumber:cucumber-jvm-deps:1.0.6'

//SerenityBDD
implementation ('net.serenity-bdd:serenity-core:2.0.91') {
    exclude group:'io.cucumber'
    exclude module:'cucumber-core'
}
implementation 'net.serenity-bdd:serenity-junit:2.0.91'
implementation 'net.serenity-bdd:serenity-rest-assured:2.0.91'
implementation 'net.serenity-bdd:serenity-screenplay:2.0.91'
implementation 'net.serenity-bdd:serenity-screenplay-webdriver:2.0.91'
implementation 'net.serenity-bdd:serenity-screenplay-rest:2.0.91'
implementation 'net.serenity-bdd:serenity-report-resources:2.0.91'
implementation 'net.serenity-bdd:serenity-reports:2.0.91'
implementation 'net.serenity-bdd:serenity-cucumber4:1.0.30'

//Maven
implementation 'org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M4'
implementation 'net.serenity-bdd.maven.plugins:serenity-maven-plugin:2.0.91'
implementation 'org.codehaus.mojo:build-helper-maven-plugin:3.0.0'

//RestServices
implementation 'io.rest-assured:rest-assured:3.0.0'
implementation 'javax.servlet:servlet-api:2.5'
implementation 'com.google.code.gson:gson:2.6.2'

//DB
implementation 'mysql:mysql-connector-java:8.0.18'

//Jira
//implementation 'net.serenity-bdd:serenity-jira-plugin:1.12.0'

}

test { ignoreFailures = true testLogging.showStandardStreams = true systemProperties System.getProperties() }

gradle.startParameter.continueOnFailure = true

test.finalizedBy(aggregate)

=============== Serenity.properties:

serenity.test.root=src/test/resources/features serenity.requirement.types=feature

kpkalyan commented 4 years ago

index.html, capabilities.html & Feature file html (576***.html) is getting generated only after executing below command

gradle clean build --refresh-dependencies

If I execute single feature file thru Junit runner I could still see that any of index.html, capabilities.html or feature file report (something states with 576***.html) is not generating

wakaleo commented 4 years ago

This is expected behaviour - the index.html file is generated when you run the aggregate goal. Is this related to the original issue (which I’m unclear as to whether it is still present)?

kpkalyan commented 4 years ago

this worked fine when aggregate goal is completed.

thank you @wakaleo