serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
719 stars 516 forks source link

Actions, results, steps are not displayed in console using serenity.logging=VERBOSE #2785

Open DiegoPinzon20 opened 2 years ago

DiegoPinzon20 commented 2 years ago

I am trying to show the execution information through the console, such as the Serenity BDD banner, the status of the steps, TEST STARTED, TEST PASSED,..., and the other messages.

In my serenity.properties I have the following configuration:

serenity.test.root=co.com.challenge.automation.runners serenity.project.name=Automation Web Serenity DB serenity.logging=VERBOSE serenity.console.headings=normal serenity.console.colors=true

I have read this behavior is associated with the ConsoleHeading.java class, but when executing I get the following console output:

Task :compileJava UP-TO-DATE Task :processResources NO-SOURCE Task :classes UP-TO-DATE Task :compileTestJava UP-TO-DATE Task :processTestResources UP-TO-DATE Task :testClasses UP-TO-DATE Task :test

Scenario: Search by keyword # src/test/resources/features/search_terms_wikipedia.feature:7 |-- Given Pablo navigates to the Wikipedia page |---- Pablo navigate to web page |------ Pablo opens the https://www.wikipedia.org/ 11:56:01.196 [Test worker] INFO n.s.c.w.d.ChromeDriverProvider - Using automatically driver download 11:56:03.260 [Test worker] INFO n.s.c.w.d.ProvideNewDriver - Instantiating driver 11:56:03.261 [Test worker] INFO n.s.c.w.d.ProvideNewDriver - Driver capabilities: Capabilities {acceptInsecureCerts: false, autodownload: true, browserName: chrome, driver: chrome, goog:chromeOptions: {args: [--start-maximized, --test-type, --no-sandbox, --ignore-certificate-errors, \r\n --di..., --disable-default-apps, --disable-extensions-file-a..., \r\n --in..., --disable-infobars, --disable-gpu, --window-size=1920,1080, --headless], extensions: []}, loggingPrefs: org.openqa.selenium.logging...} Starting ChromeDriver 100.0.4896.60 (6a5d10861ce8de5fce22564658033b43cb7de047-refs/branch-heads/4896@{#875}) on port 47966 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Apr 19, 2022 11:56:04 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Given Pablo navigates to the Wikipedia page # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.pabloNavigatesToTheWikipediaPage(java.lang.String) |-- When searching for the word Everest |---- Pablo searches for articles containing they word |------ Pablo enters 'Everest' then hits [ENTER] into Campo para ingresar la palabra a buscar When searching for the word Everest # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.searchingForTheWordEverest(java.lang.String) |-- Then should see Everest in the page title |---- Then the displayed titulo de la pagina principal de busqueda de Wikipedia should be a string containing 'Everest' Then should see Everest in the page title # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.shouldSeeEverestInThePageTitle(java.lang.String)

1 Scenarios (1 passed) 3 Steps (3 passed) 0m15.565s

Task :aggregate Generating Serenity Reports for reto-tecnico-automatizador-serenity to directory file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/target/site/serenity/ BUILD SUCCESSFUL in 23s 5 actionable tasks: 2 executed, 3 up-to-date 11:56:17 AM: Task execution finished ':test --tests "co.com.challenge.automation.runners.wikipedia_runners.WhenSearchingForItemsWikipedia"'.

I share the information of the gradle of the project, in which I use Serenity Core Version 3.0.2. buildscript { ext.serenityCoreVersion = '3.0.2' repositories { mavenCentral() } dependencies { classpath("net.serenity-bdd:serenity-gradle-plugin:$serenityCoreVersion") classpath "net.serenity-bdd:serenity-single-page-report:$serenityCoreVersion" } }

plugins { id 'java' id 'eclipse' id 'idea' }

repositories { mavenCentral() }

defaultTasks 'clean', 'test', 'aggregate' apply plugin: 'net.serenity-bdd.aggregator'

sourceCompatibility = 1.8 targetCompatibility = 1.8

ext { slf4jVersion = '1.7.7' junitVersion = '5.8.2' assertJVersion = '3.22.0' logbackVersion = '1.2.10' lombokVersion = '1.18.22' }

sourceCompatibility = 1.8 targetCompatibility = 1.8

dependencies { implementation "net.serenity-bdd:serenity-core:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-ensure:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-junit5:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-cucumber:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-screenplay:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-screenplay-webdriver:${serenityCoreVersion}" implementation "net.serenity-bdd:serenity-screenplay-rest:${serenityCoreVersion}"

implementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
implementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
implementation "org.assertj:assertj-core:${assertJVersion}"
implementation "ch.qos.logback:logback-classic:${logbackVersion}"

implementation "org.projectlombok:lombok:${lombokVersion}"

}

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

serenity { reports = ["single-page-html"] // Esta tarea genera un reporte en una unica pagina - como un resumen de los resultados para enviar por email // No tiene relacion con la generacion de los reportes generados durante las pruebas // Puedes ejecutar esta tarea con: gradle reports dando como salida un archivo llamado serenity-summary.html }

gradle.startParameter.continueOnFailure = true test.finalizedBy(aggregate)

Do I need to do any additional configuration in my properties or build.gradle files?

DiegoPinzon20 commented 2 years ago

It is important to mention that when a step fails (then), if the heading text of TEST FAILED is shown if in the serenity.properties file I comment the line '#serenity.console.headings=normal', having the following output:

Task :compileJava UP-TO-DATE Task :processResources NO-SOURCE Task :classes UP-TO-DATE Task :compileTestJava UP-TO-DATE Task :processTestResources UP-TO-DATE Task :testClasses UP-TO-DATE Task :test

Scenario: Search by keyword # src/test/resources/features/search_terms_wikipedia.feature:7 13:05:26.911 [Test worker] INFO n.s.c.w.d.ChromeDriverProvider - Using automatically driver download 13:05:28.713 [Test worker] INFO n.s.c.w.d.ProvideNewDriver - Instantiating driver 13:05:28.713 [Test worker] INFO n.s.c.w.d.ProvideNewDriver - Driver capabilities: Capabilities {acceptInsecureCerts: false, autodownload: true, browserName: chrome, driver: chrome, goog:chromeOptions: {args: [--start-maximized, --test-type, --no-sandbox, --ignore-certificate-errors, \r\n --di..., --disable-default-apps, --disable-extensions-file-a..., \r\n --in..., --disable-infobars, --disable-gpu, --window-size=1920,1080, --headless], extensions: []}, loggingPrefs: org.openqa.selenium.logging...} Starting ChromeDriver 100.0.4896.60 (6a5d10861ce8de5fce22564658033b43cb7de047-refs/branch-heads/4896@{#875}) on port 26641 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Apr 19, 2022 1:05:30 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Given Pablo navigates to the Wikipedia page # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.pabloNavigatesToTheWikipediaPage(java.lang.String) When searching for the word Everest # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.searchingForTheWordEverest(java.lang.String) 13:05:38.898 [Test worker] ERROR -


| | | | / | | | | | /\ | _| | | | _| | \ | | | | _ \ | | | | / _ \ | | | |_ | | | |) | || || |/ || || // _\ |_| |__| |_| |___/

Search by keyword

13:05:38.902 [Test worker] ERROR - Test failed at step: Then the displayed titulo de la pagina principal de busqueda de Wikipedia should be a string containing 'Evereste' 13:05:38.905 [Test worker] ERROR - Expected: a string containing "Evereste" but: was "Mount Everest" Then should see Evereste in the page title # co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.shouldSeeEverestInThePageTitle(java.lang.String) java.lang.AssertionError: Expected: a string containing "Evereste" but: was "Mount Everest" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at net.serenitybdd.screenplay.QuestionConsequence.evaluateFor(QuestionConsequence.java:49) at net.serenitybdd.screenplay.Actor.check(Actor.java:367) at net.serenitybdd.screenplay.Actor.should(Actor.java:339) at co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.shouldSeeEverestInThePageTitle(SearchingItemsWikipediaStepDefinitions.java:41) at ✽.should see Evereste in the page title(file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/src/test/resources/features/search_terms_wikipedia.feature:10)

13:05:39.729 [Test worker] ERROR -


| | | | / | | | | | /\ | _| | | | _| | \ | | | | _ \ | | | | / _ \ | | | |_ | | | |) | || || |/ || || // _\ |_| |__| |_| |___/

Search by keyword

13:05:39.742 [Test worker] ERROR - Test failed at step: Then the displayed titulo de la pagina principal de busqueda de Wikipedia should be a string containing 'Evereste' 13:05:39.744 [Test worker] ERROR - Expected: a string containing "Evereste" but: was "Mount Everest"

Expected: a string containing "Evereste" but: was "Mount Everest" java.lang.AssertionError: Expected: a string containing "Evereste" but: was "Mount Everest" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at net.serenitybdd.screenplay.QuestionConsequence.evaluateFor(QuestionConsequence.java:49) at net.serenitybdd.screenplay.Actor.check(Actor.java:367) at net.serenitybdd.screenplay.Actor.should(Actor.java:339) at co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.shouldSeeEverestInThePageTitle(SearchingItemsWikipediaStepDefinitions.java:41) at ✽.should see Evereste in the page title(file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/src/test/resources/features/search_terms_wikipedia.feature:10)

Failed scenarios: file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/src/test/resources/features/search_terms_wikipedia.feature:7 # Search by keyword

1 Scenarios (1 failed) 3 Steps (1 failed, 2 passed) 0m14.100s

java.lang.AssertionError: Expected: a string containing "Evereste" but: was "Mount Everest" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at net.serenitybdd.screenplay.QuestionConsequence.evaluateFor(QuestionConsequence.java:49) at net.serenitybdd.screenplay.Actor.check(Actor.java:367) at net.serenitybdd.screenplay.Actor.should(Actor.java:339) at co.com.challenge.automation.stepdefinitions.wikipedia.SearchingItemsWikipediaStepDefinitions.shouldSeeEverestInThePageTitle(SearchingItemsWikipediaStepDefinitions.java:41) at ?.should see Evereste in the page title(file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/src/test/resources/features/search_terms_wikipedia.feature:10)

WhenSearchingForItemsWikipedia > User searchs keyword in Wikipedia web page > co.com.challenge.automation.runners.wikipedia_runners.WhenSearchingForItemsWikipedia.Search by keyword FAILED java.lang.AssertionError at MatcherAssert.java:20 1 test completed, 1 failed

Task :test FAILED Task :aggregate Generating Serenity Reports for reto-tecnico-automatizador-serenity to directory file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/target/site/serenity/ FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':test'. There were failing tests. See the report at: file:///C:/Users/Administrador/Documents/SerenityProjects/2022/reto-tecnico-automatizador-serenity/build/reports/tests/test/index.html
  • 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.
  • Get more help at https://help.gradle.org BUILD FAILED in 21s 5 actionable tasks: 2 executed, 3 up-to-date

But the other heading text of the steps is not displayed.

anhphan-cwvn commented 2 years ago

@DiegoPinzon20 Did you solve this issue?