serenity-bdd / serenity-cucumber-starter Goto Github PK
View Code? Open in Web Editor NEWA skeleton project for Serenity BDD and Cucumber JVM
License: Apache License 2.0
A skeleton project for Serenity BDD and Cucumber JVM
License: Apache License 2.0
When I run my tests in IntelliJ, it works fine.
When I run the test from commandline, my provided webdriver "MyCustomDriver" is not being triggered .
What changes must I do in the gradle.build file?
serenity.conf:
webdriver {
driver = provided
provided.type= mydriver
provided.mydriver = net.persgroep.targetqa.MyCustomDriver
se.driver.service.pool = false
thucydides.driver.capabilities = mydriver
}
Gradle build file:
defaultTasks 'clean','test','aggregate'
repositories {
mavenLocal()
jcenter()
}
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:2.0.70")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply from: "$rootDir/gradle/libraries.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
/**
* This is needed to make sure there are no Cucumber 2 dependencies in the classpath.
*/
configurations.all {
resolutionStrategy {
force "io.cucumber:cucumber-core:${cucumberVersion}"
}
}
dependencies {
compile libs.logback
testCompile libs.test.cucumber.java,
libs.test.cucumber.junit,
libs.test.serenity.core,
libs.test.serenity.screenplay,
libs.test.serenity.junit,
libs.test.serenity.screenplayWebdriver,
libs.test.serenity.cucumber,
libs.test.junit,
libs.test.assertj
compile group: 'net.lightbody.bmp', name: 'browsermob-proxy', version: '2.1.5', ext: 'pom'
compile group: 'net.lightbody.bmp', name: 'browsermob-core', version: '2.1.5'
compile group: 'de.sstoehr', name: 'har-reader', version: '2.1.4'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}
test {
testLogging.showStandardStreams = true
systemProperties System.getProperties()
exclude '**/starter/examples/**'
}
gradle.startParameter.continueOnFailure = true
test.finalizedBy(aggregate)
configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}
task cucumber() {
dependsOn assemble
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = 'src/test'
args = ['--plugin', 'pretty', '--glue net.serenitybdd.cucumber.actors net.persgroep.targetqa.starter.stepdefinitions', 'src/test/java/net/persgroep/targetqa', 'src/test/resources/features']
}
}
}
//Ensure the cucumber tests are executed as part of the build. Makes for a very pretty output.
build.dependsOn cucumber
IntelliJ runconfig:
Hi @wakaleo ,
Just want to ask because I am developing serenity-cucumber framework and it seems that is does not read any of the beans within the @componentscan({"dao", "services"}) package. In order to retrieve results from database. Especially it throws NullPointerException also, because it does not read environment variables. The framework is supposed to read the connection strings from a separate properties file. But unfortunately it does not read any of it during compile.
My other question is, is their a way for cucumber to read those properties during compile and connect to the database? Thank you in advance.
Hi,
We have more than 2 feature and step definitions file, When running the code, first step definition code is running successfully but after complete the code, the browser has restarted with an empty page and the second step definition file is not running cause of restarting.
Kindly provide the solution.
Is cucumber not compatible with Assert of Junit?
Because when I use Assert, it results to 0 scenarios and 0 steps.
Hallo daar,
We are using Serenity with Kotlin with version 4.8.0; however recently I started to upgrade it to Cucumber 6.6.0. And I am indeed following version compatibility table from here.
I have also tried with starter project(using screenplay) in kotlin and yes, it works like charm. However, with our classic step definitions project it is throwing us this error.
22:47:47.236 [main] INFO - Test Suite Started: This is a demo feature to run Serenity With Kotlin
22:47:48.525 [main] ERROR n.thucydides.core.steps.StepEventBus - No base step listener registered - this is generally a bad sign.
Oct 05, 2020 10:47:48 PM io.cucumber.core.runtime.Runtime run
SEVERE: Exception while executing pickle
java.util.concurrent.ExecutionException: java.lang.NullPointerException: No BaseStepListener has been registered
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:93)
at net.serenitybdd.cucumber.cli.Main.run(Main.java:27)
at net.serenitybdd.cucumber.cli.Main.main(Main.java:18)
Caused by: java.lang.NullPointerException: No BaseStepListener has been registered
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:900)
at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:137)
at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:77)
at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:58)
at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:48)
at io.cucumber.java8.Java8Backend.buildWorld(Java8Backend.java:64)
at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:99)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:65)
at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1631)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
... 2 more
Exception in thread "main" io.cucumber.core.exception.CucumberException: java.lang.NullPointerException: No BaseStepListener has been registered
at io.cucumber.core.runtime.CucumberExecutionContext.getException(CucumberExecutionContext.java:82)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:103)
at net.serenitybdd.cucumber.cli.Main.run(Main.java:27)
at net.serenitybdd.cucumber.cli.Main.main(Main.java:18)
Caused by: java.lang.NullPointerException: No BaseStepListener has been registered
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:900)
at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:137)
at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:77)
at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:58)
at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:48)
at io.cucumber.java8.Java8Backend.buildWorld(Java8Backend.java:64)
at io.cucumber.core.runner.Runner.buildBackendWorlds(Runner.java:99)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:65)
at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1631)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
... 2 more
Before raising I did searched in the existing issues; there are some issues raised for same error but none of them really helped. Along with this I am attaching a zip file; which is very much relevant to the project we are working on.
serenity.demo.zip
Looking for any help, thanks !
Remote Driver - Is there any implementation to verify the remote driver file download?
Something like:
https://www.gridlastic.com/selenium-grid-download-file.html
I am using zalenium and commented here zalando/zalenium#1075 as this a related issue.
I followed pom.xml to create my scripts
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = {"src/test/resources/youTube/"}, glue = {"stepdefinitons"},format={"pretty"})
public class RunCukesTest {
}
here is my pom.xml
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.0.23</serenity.version>
<serenity.maven.version>2.0.23</serenity.maven.version>
<serenity.cucumber.version>1.9.20</serenity.cucumber.version>
UTF-8
<parallel.tests>4</parallel.tests>
<webdriver.base.url></webdriver.base.url>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/*TestSuite.java</include>
<include>**/When*.java</include>
</includes>
<systemPropertyVariables>
<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
</systemPropertyVariables>
<parallel>classes</parallel>
<threadCount>${parallel.tests}</threadCount>
<forkCount>${parallel.tests}</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Hi All i am getting bellow error
java.lang.NoSuchMethodError: cucumber.runtime.RuntimeOptions.addPlugin(Ljava/lang/Object;)V
at net.serenitybdd.cucumber.CucumberWithSerenity.createSerenityEnabledRuntime(CucumberWithSerenity.java:45)
at net.serenitybdd.cucumber.CucumberWithSerenity.createSerenityEnabledRuntime(CucumberWithSerenity.java:39)
at net.serenitybdd.cucumber.CucumberWithSerenity.createRuntime(CucumberWithSerenity.java:34)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:58)
at net.serenitybdd.cucumber.CucumberWithSerenity.<init>(CucumberWithSerenity.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
POM i am using:
4.0.0
com.test.automation
test-automation-capability
1.0.0
pom
<properties>
<selenium.version>4.0.0-alpha-2</selenium.version>
<mvncompiler.version>3.5.1</mvncompiler.version>
<javasource.version>1.8</javasource.version>
<javatarget.version>1.8</javatarget.version>
<serenity.maven.version>2.0.52</serenity.maven.version>
<serenity.version>2.0.52</serenity.version>
<serenity.cucumber.version>1.0.15</serenity.cucumber.version>
<cucumber.version>4.2.0</cucumber.version>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-java-integration</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
import io.cucumber.java.ParameterType;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.actors.OnStage;
public class ParameterDefinitions {
@ParameterType(".*")
public Actor actor(String actorName) {
return OnStage.theActorCalled(actorName);
}
}
@given("{actor} open(s) a browser and launch Web portal")
public void logsWebPortal(Actor actor) {
actor.wasAbleTo(GoTo.theWebPortalLoginPage());
actor.wasAbleTo(GoTo.clickLogin());
}
Error:
Undefined Parameter type {actor}, Please register a Parameter Type for {actor}
Hi
I am having issue with
13:21:32.540 [pool-2-thread-1] DEBUG n.t.c.r.m.cucumber.CucumberParser - Found no Cucumber 4.x.x class cucumber.runtime.model.FeatureLoader try Cucumber 2.x.x
4.0.0
com.XXXXX
XXXXXXX
0.0.1-SNAPSHOT
com.XXXXXX.sp
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<encoding>UTF-8</encoding>
<tags></tags>
<parallel.tests>4</parallel.tests>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>2.0.23</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>2.0.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>1.9.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>fluent-hc</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>1.53</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.0-jre</version>
</dependency>
<!-- Selenium dependency -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.12.0</version>
</dependency>
<!-- Junit -->
<dependency>
<groupId>Junit</groupId>
<artifactId>Junit</artifactId>
<version>4.12</version>
</dependency>
<!-- Cucumber dependencies -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<!-- Dependencies for API testing -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.5</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-path</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.7.0</version>
</dependency>
<!-- Dependecy for excel sheet -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<!-- Extended report -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<includes>
<include>**/*MainRunner.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/Test*.java</include>
<include>**/*TestSuite.java</include>
<include>**/When*.java</include>
<include>**/*MainRunner.java</include>
</includes>
<parallel>classes</parallel>
<threadCount>${parallel.tests}</threadCount>
<forkCount>${parallel.tests}</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>2.0.16</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@wakaleo: master branch has the screenplay pattern rather the classic one.
Can you update the code.
Can see you updated screenplay pattern on master branch in this commit :
7e1bb0f86eb9817aebb3d28ce30370a7a81cd8c8
Any specific reason as screenplay is already on different branch ?
I don't know if this is an issue or I am just using the wrong format. but supplying multiple tags to the command -Dcucumber.filter.tags doesn't work
For example:
-Dcucumber.filter.tags="@TCA-335 and @TCA-333"
Hello everyone, I have a question.
Download and run the project with the command mvn clean verify and the report appears very well. What caught my attention was that in the feature in the step definitions, even though they are already created, they are still shaded yellow and it appears as if I had not created them.
but the step definitions are already created
and even if I recreate the step definitions, they continue with the yellow shadow showing that they have not been created.
I have not made any modification to the pom.
thanks.
Like -Dcucumber.options.features=folder
I'm using a provided type webdriver (MyCustomDriver).
I put the use of this in my serenity.properties file:
webdriver.driver = provided
webdriver.provided.type = mydriver
webdriver.provided.mydriver = net.persgroep.targetqa.MyCustomDriver
serenity.driver.capabilities = mydriver
But when I run graldle test -Dfirefox
The webdriver is not initialized and MyCustomDriver is never reached.
This is my gradle.build file:
defaultTasks 'clean','test','aggregate'
repositories {
mavenLocal()
jcenter()
}
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:2.0.70")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'
apply from: "$rootDir/gradle/libraries.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
/**
* This is needed to make sure there are no Cucumber 2 dependencies in the classpath.
*/
configurations.all {
resolutionStrategy {
force "io.cucumber:cucumber-core:${cucumberVersion}"
}
}
dependencies {
compile libs.logback
testCompile libs.test.cucumber.java,
libs.test.cucumber.junit,
libs.test.serenity.core,
libs.test.serenity.screenplay,
libs.test.serenity.junit,
libs.test.serenity.screenplayWebdriver,
libs.test.serenity.cucumber,
libs.test.junit,
libs.test.assertj
compile group: 'net.lightbody.bmp', name: 'browsermob-proxy', version: '2.1.5', ext: 'pom'
compile group: 'net.lightbody.bmp', name: 'browsermob-core', version: '2.1.5'
compile group: 'de.sstoehr', name: 'har-reader', version: '2.1.4'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
compile group: 'com.browserstack', name: 'browserstack-local-java', version: '1.0.3'
compile group: 'net.serenity-bdd', name: 'serenity-gradle-plugin', version: '2.0.70'
}
test {
testLogging.showStandardStreams = true
systemProperties System.getProperties()
exclude '**/starter/examples/**'
}
gradle.startParameter.continueOnFailure = true
test.finalizedBy(aggregate)
configurations {
cucumberRuntime {
extendsFrom testImplementation
}
}
//Ensure the cucumber tests are executed as part of the build. Makes for a very pretty output.
I want to execute all features in one brower instance for debug reasons, or at least one after another.
By default serenity starts an browser instance for every feature file. This leads to problems.
Thankfully some switches are already implemented like (restart.browser.each.scenario):
The documentations need to be updated and maybe the implementation too its not working at all. setting the switch to true and false does not change one thing.
Doc says default falue is false and it gets activated by false altho that sounds strange to me.
I altho wanted to use serenity.use.unique.browser but it seems not to work or make and change eather:
Without headless i see browser instances for ever feature:
heres my configuration:
Hello, I would like to know if on my Scenario Outline I can do parallel executions.
what I mean is being able to open a browser for each example line that I have.
I would like to be able to open at least 3 or 4 browsers
This is my Runnerclass
and this is my pom , I would appreciate your help
4.0.0
net.serenitybdd.starter
cucumber-starter
1.0.0-SNAPSHOT
jar
<name>Sample Serenity BDD project using Cucumber</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.2.9</serenity.version>
<serenity.maven.version>2.2.9</serenity.maven.version>
<serenity.cucumber.version>2.2.5</serenity.cucumber.version>
<encoding>UTF-8</encoding>
<tags></tags>
<parallel.tests>4</parallel.tests>
</properties>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<!--
- To use Cucumber 4, exclude the old Cucumber 2 cucumber-core dependency from the serenity-core dependency
- and include the Cucumber 4 cucumber-java and cucumber-junit dependencies.
-->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>2.2.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>2.2.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>2.2.9</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-rest</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-ensure</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber5</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.1.2.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>3.141.59</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<includes>
<include>**/*WebTest*.java</include>
</includes>
<parallel>classes</parallel>
<threadCount>${parallel.tests}</threadCount>
<forkCount>${parallel.tests}</forkCount>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Sometimes it is helpful to be able to run a test suite as an executable jar on a machine with only a JVM and no maven or other tooling installed.
Can you please provide an example of how to do this?
I imagine it is as simple as running the appropriate test runner somehow. For example:
public static void main(String args[]) {
org.junit.runner.JUnitCore.main("junitfaq.SimpleTest");
}
Is there a Serenity with Cucumber equivalent?
I am using your template to build my automation suite. The requirement is to run on any VM's . I was trying to use the approach of exporting this maven project as a Jar file and running it using batch command on the respective machine. But I am finding issues running this as a Jar as this a java test project with no main class.
can you please let me know how to run this is as a Jar or is there any better way to run this from CI tool like Jenkins. Thank you
Hi,
We have an existing project which has 100+ Script automated for Rest API testing using Rest Assured/Java framework. We saw serenity reports samples and found interesting and wanted to implement it in our project.
We tried maven setup,but we could get report for our scripts only running as maven test.
Since our project never had any feature file to run ,we always ran as junit.
Can you please suggest how can I run my existing java classes as junit, by implementing any runner class with out any feature file to get serenity reports.
I tried to use @WithTag name, @with tag color but it didn't work.
There was no table entry or table row transformer registered for com.celsia.cpo.models.Charger.
Please consider registering a table entry or row transformer.
There was no default table entry transformer registered to transform com.celsia.cpo.models.Charger.
Please consider registering a default table entry transformer.
please and example on this version.
Hello everyone, a i am trying to resolve this issue last few days but without any luck. So when i run tests with:
mvn clean verify serenity:aggregate
I am getting following errors:
[ERROR] WARNING: An illegal reflective access operation has occurred
[ERROR] WARNING: Illegal reflective access by net.thucydides.core.steps.StepInterceptor (file:/C:/Users/n.radic/.m2/repository/net/serenity-bdd/serenity-core/2.4.34/serenity-core-2.4.34.jar) to field java.lang.reflect.Method.root
[ERROR] WARNING: Please consider reporting this to the maintainers of net.thucydides.core.steps.StepInterceptor
[ERROR] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[ERROR] WARNING: All illegal access operations will be denied in a future release
I am using Java jdk 11.0.11 , Maven 3.8.1
--
This is my pom.xml
4.0.0
cucumber-serenity
cucumber-serenity
1.0.0-SNAPSHOT
jar
<name>cucumber-serenity</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>2.4.34</serenity.version>
<serenity.maven.version>2.4.34</serenity.maven.version>
<serenity.cucumber.version>2.4.34</serenity.cucumber.version>
<encoding>UTF-8</encoding>
</properties>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber6</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-rest-assured</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-ensure</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<skip>true</skip>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/starter/**/*.java</include>
<include>**/starter/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
--
Also i am having troubles executing only tagged scenarios.
command:
mvn clean verify "-Dcucumber.options=--tags @type=smoke" serenity:aggregate
executes all tests and in serenity report displays only tagged ones. My question is why it is running all the tests anyway? Is it related to the first issue described in this post?
Thanks in advance any help is much appreciated :)
I assume that answer is very obvious, but i depleted google search for this issue so i am asking you :)
I have gone through my code several times but still not sure what's is the issue. Getting build success but my tests are getting ignored and shown as passed in build log. I am using custom WebDriver. Not sure what is the issue but got a feeling something is wrong with webdriver. it seems like it is not intialized.
Please find the below code snippet for my custom WebDriver:
`
public class localDriver implements DriverSource {
@OverRide
public WebDriver newDriver() {
System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("disable-infobars");
WebDriver _driver = new ChromeDriver(options);
System.out.println("Driver has been initialized");
return _driver;
}
@Override
public boolean takesScreenshots() {
return true;
}
}
`
My pom.xml
`
4.0.0
au.com.nab
author-test
jar
1.0-SNAPSHOT
<name>automation-test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serenity.version>1.9.12</serenity.version>
<serenity.maven.version>1.9.12</serenity.maven.version>
<serenity.cucumber.version>1.9.4</serenity.cucumber.version>
<cucumber.version>2.3.0</cucumber.version>
<surefire.fork.count>1</surefire.fork.count>
<cucumber.jvmdeps.version>1.0.6</cucumber.jvmdeps.version>
<gherkin.version>5.0.0</gherkin.version>
<jdk.source.version>1.8</jdk.source.version>
<jdk.target.version>1.8</jdk.target.version>
<webdriver.driver>chrome</webdriver.driver>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<!--serenity-->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber</artifactId>
<version>${serenity.cucumber.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<!--Cucumber-->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>${cucumber.jvmdeps.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>${gherkin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${jdk.source.version}</source>
<target>${jdk.target.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<includes>
<include>**/automatedAuthorTests/support/test_runner/testRunner.java</include>
</includes>
<forkCount>${surefire.fork.count}</forkCount>
<reuseForks>false</reuseForks>
<argLine>-Duser.language=en</argLine>
<argLine>-Xmx1024m</argLine>
<argLine>-XX:MaxPermSize=256m</argLine>
<argLine>-Dfile.encoding=UTF-8</argLine>
<useFile>false</useFile>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
`
public class hooks {
String testName;
@Managed
WebDriver _driver;
public hooks() throws Throwable {
System.out.println("_____________ INITIALIZE HOOKS _____________");
}
@Before
public void initiate(Scenario scenario) throws Throwable {
System.out.println("_____________ BEFORE SCENARIO _____________");
System.out.println("SCENARIO ID AND NAME:" + scenario.getId() + "/" + scenario.getName());
testName = scenario.getId() + "/" + scenario.getName();
Serenity.setSessionVariable("scenarioName").to(scenario.getName());
}
@After
public void terminate(Scenario scenario) throws Throwable {
System.out.println("_____________ AFTER SCENARIO _____________");
String status = scenario.getStatus().toString();
System.out.println("SCENARIO NAME: " + testName + " : STATUS: " + status);
if (_driver != null) {
_driver.close();
_driver.quit();
}
Serenity.getCurrentSession().clear();
}
}
`
Test runner:
`@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
features = {"src/test/resources/features/"},
glue = {"automatedAuthorTests.support.hooks","automatedAuthorTests.step_definitions" },
tags = {"@test"}
)
public class testRunner{
@BeforeClass
public static void startTestExecution() throws Exception {
System.out.println("------Execution Start-----------");
}
@AfterClass
public static void stopTestExecution() throws Exception {
System.out.println("------ Execution Finished-------");
}
}`
serenity.properties:
webdriver.driver=provided webdriver.provided.type = mydriver webdriver.provided.mydriver = automatedAuthorTests.localDriver thucydides.driver.capabilities = mydriver
Another issue is with serenity.properties file. I have defined the WebDriver specific properties but it's showing me the properties as unused. I am struck with my POC. Please help me to resolve the given issues.
Thanks in advance!!
I am trying to run the tests with -Dcontext=chrome parameter on Gradle but seems that the Serenity reports does not display the chrome icon rather it displays nothing. Does anyone know if I am doing it right ?
My build command:
gradle test -Dwebdriver.remote.driver=chrome -Dwebdriver.driver=remote -Dwebdriver.remote.url=http://localhost:4444/wd/hub -Dcontext=chrome -Dtags=@desktop
When i used the below mvn command for execution and below code is my feature file rerun is done successfully, With reports not showing for earlier pass cases
Issue : : When example test case 1 fails and test case 2 passed, Test case 1 retry and pass
In the report
\target\site\serenity\index.html
mvn clean verify -Dcucumber.options="--tags @testRun" -Dfailsafe.rerunFailingTestsCount=2
My Test is in the following format
`Feature: Sample Test
Scenario Outline: Scenario Outline name
Given Test start <Header 1>
When test pre condition <Header 2>
And Steps added
Then validate result <Header 3>
Examples:
| testcase | Header 2 | Header 3 |
| testcase_1 | Value 2 | Value 3 |
| testcase_1 | Value 5 | Value 6 |`
Hello I am suddenly getting this exception for the code which was working 10 minutes ago. .Please help. Please find the attached related files.
java.zip
net.thucydides.core.steps.RecursiveOrCyclicStepLibraryReferenceException: A recursive or cyclic reference was detected for the @Steps-annotated field report in class utilities.ReportMessege. You may need to use @steps(shared=true) to ensure that the same step library instance is used everywhere.
I have used shared=true .
Please help me.
Hi @wakaleo ,
Good day sir, I would like to ask on how can I configure parallel execution with defined thread.count and fork.count. On my end it is not working when I execute eh. I am using profile when I'm running in parallel. Although it is executing in parallel but the it does not recognize the defined thread and fork. Thank you.
Here is my config:
I have a fairly large suite of tests that I want to be able to speed up by running in parallel batches, but I can't seem to figure out a way to get that to actually work using the parallel
and/or serenity.batch...
properties - is there something I'm doing wrong?
I tried to make a simplified example based on the latest stable version as specified by the serenity-core repo:
the features are not identical, but are highly similar
cucumber 'glue' steps
@Given("Something happens")
public void Something_happens ()
{
int batch = Integer.parseInt(System.getProperty("serenity.batch.number"));
System.out.println("Doing something for batch [" + batch + ']');
boolean something = Wait.on("Some sort of thing")
.until(step::doSomething);
assert something : "Something went wrong";
}
@Given("Something else happens")
public void Something_else_happens ()
{
int batch = Integer.parseInt(System.getProperty("serenity.batch.number"));
System.out.println("Doing something else for batch [" + batch + ']');
boolean somethingElse = Wait.on("Some OTHER sort of thing")
.until(step::doSomethingElse);
assert somethingElse : "Something else went wrong";
}
corresponding steps library
@Step
public boolean doSomething ()
{
int something = Integer.parseInt(System.getProperty("serenity.batch.number"));
return (something + 1) % 2 == 0;
}
@Step
public boolean doSomethingElse ()
{
int somethingElse = Integer.parseInt(System.getProperty("serenity.batch.number"));
return (somethingElse - 1) > 0;
}
contents of pom.xml
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<encoding>UTF-8</encoding>
<serenity.version>2.4.34</serenity.version>
<serenity.maven.version>2.4.34</serenity.maven.version>
<serenity.cucumber.version>2.4.34</serenity.cucumber.version>
<tags/>
<webdriver.base.url/>
<batches>2</batches>
</properties>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber6</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-ensure</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Kotlin Stuff -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>compile</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<include>**/*Runner.java</include>
</includes>
<systemPropertyVariables>
<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
<serenity.batch.size>0${batches}</serenity.batch.size>
<serenity.batch.number>0${surefire.forkNumber}</serenity.batch.number>
</systemPropertyVariables>
<parallel>classes</parallel>
<threadCount>${batches}</threadCount>
<forkCount>${batches}</forkCount>
<reuseForks>false</reuseForks>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<configuration>
<tags>${tags}</tags>
</configuration>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
'Wait' utility using Kotlin
class Wait
{
private lateinit var reason : String
private var created : Long = System.nanoTime()
private var patience : Long = 5
private var timedAs : TimeUnit = SECONDS
private fun expired () : Boolean = System.nanoTime() - created > NANOSECONDS.convert(patience, timedAs)
companion object
{
@JvmStatic
fun on (reason: String) : Wait
{
val wait = Wait()
wait.reason = reason
return wait
}
}
fun until (check: Supplier<Boolean>) : Boolean
{
var passed : Boolean
println("Waiting on: [$reason] for up to [$patience $timedAs]")
do passed = check.get()
while (!passed && !expired())
return passed
}
}
Hi Team,
I am trying to run the selected scenarios using tags from command line but its triggering all the test suites.
I am using the below tag
mvn clean verify -P UatEllipse -P local -Dcucumber.options="--tags @SVRegression"
Please help me to resolve this issue.
Thanks,
Chakri
While attempting to run cucumber scenarios in parallel I found that parallel=classes or methods has no control over parallelism.
Below are some scenarios; I tried. Along with I am also attaching two projects in Kotlin.
serenity-cucumberj8-starter.zip
serenity-cucumber-starter.zip
Case 1:
<parallel>methods</parallel>
<threadCount>2</threadCount>
<useUnlimitedThreads>false</useUnlimitedThreads>
Results of case 1:
All 5 scenarios marked with tag '@Runforestrun' starts running.
Case 2:
<parallel>classes</parallel>
<parallel>methods</parallel>
<threadCount>2</threadCount>
<useUnlimitedThreads>false</useUnlimitedThreads>
or
<parallel>classes</parallel>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
Results of case 2: Scenarios executed sequentially; no parallelism achieved
Case 3:
<parallel>classes</parallel>
<threadCount>2</threadCount>
or
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
Results of case 3: Test cases are executed sequentially; no parallelism achieved
Hello
I cloned this starter, got dependencies by Maven, and tried to run search_by_keyword.feature in InteliJ IDEA, but received:
[main] ERROR n.thucydides.core.steps.StepEventBus - No base step listener registered
How to customize the list of application specific exceptions in serenity BDD and to add those exceptions in report.
Hello, everyone.
I have a feature with various scenarios:
#language: pt
@all @uc11
Funcionalidade: UC11 - Acessar "Landing Page" no App
Contexto:
Dado que sou um Usuário Público
@ct1 @cp
Cenário: CT1v2 - Verificar que o aplicativo solicita acessar o local do dispositivo quando é iniciado
Quando o sistema solicita acessar o local do dispositivo
Então o sistema apresenta as opções de acesso estão disponíveis para seleção
@ct2 @ca1
Cenário: CT2v2 - Verificar que o aplicativo fecha quando o acesso à localização é negado
Quando o sistema solicita acessar o local do dispositivo
E escolho a ação negar para o acesso do local do dispositivo
Então o sistema fecha
@ct3 @ca3
Cenário: CT3v2 - Verificar que o aplicativo solicita a mudança de idioma quando é iniciado
Quando o sistema solicita acessar o local do dispositivo
E escolho a ação permitir durante o uso do aplicativo para o acesso do local do dispositivo
Então o sistema apresenta o modal de solicitação de mudança de idioma é apresentado com suas respectivas opções
@ct4 @ce1 @testeMudarIdioma
Cenário: CT4v2 - Verificar que o aplicativo mantém o idioma padrão quando o usuário escolhe a opção PRONTO
Quando o dispositivo encontra-se com idioma diferente do padrão da aplicação
| language | en |
| locale | US |
E o sistema solicita acessar o local do dispositivo
E escolho a ação permitir uma vez para o acesso do local do dispositivo
E escolho manter o idioma da aplicação
Então o sistema apresenta a landing page no idioma padrão
And I want to run just "@testeMudarIdioma" tag. I run my tests from maven command line: clean verify -Dcucumber.filter.tags="@testeMudarIdioma"
, but ALL tests in ALL features got runned.
This is in my POM:
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.13.1</junit.version>
<appium.version>7.3.0</appium.version>
<serenity.version>2.3.8</serenity.version>
<serenity.cucumber.version>2.3.6</serenity.cucumber.version>
<cucumber.version>6.9.0</cucumber.version>
<slf4j.version>1.7.30</slf4j.version>
<maven.surefire.failsafe.version>2.22.2</maven.surefire.failsafe.version>
</properties>
<dependencies>
<!-- Appium -->
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>${appium.version}</version>
</dependency>
<!-- Serenity BDD -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-screenplay-webdriver</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-ensure</artifactId>
<version>${serenity.version}</version>
<scope>test</scope>
</dependency>
<!-- Cucumber -->
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-cucumber6</artifactId>
<version>${serenity.cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-core</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>junit</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>datatable-matchers</artifactId>
<version>1.1.14</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.failsafe.version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.surefire.failsafe.version}</version>
<configuration>
<includes>
<include>**/suites/CucumberSuiteTests.java</include>
</includes>
<argLine>-Xmx512m</argLine>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
And this is my CucumberSuiteTests.java suite :
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(
glue = "com.xx.steps",
features = "src/test/resources/features"
)
public class CucumberSuiteTests {
static AppiumDriverLocalService appiumService = null;
@BeforeClass
public static void startAppiumServer() {
appiumService = AppiumDriverLocalService.buildDefaultService();
appiumService.start();
}
@AfterClass
public static void stopAppiumServer() {
appiumService.stop();
}
}
Anyone can help how to overcome this problem?
My best regards.
I upgraded my project to the latest version of serenity+cucumber (serenity core 2.3.4) and have a problem when running .feature file from eclipse. I have spend more time on research but it just get a solution for IntelliJ (https://johnfergusonsmart.com/running-cucumber-serenity-feature-files-directly-intellij). Please help me with that.
[main] ERROR net.thucydides.core.steps.StepEventBus - No base step listener registered - this is generally a bad sign.
java.lang.NullPointerException: No BaseStepListener has been registered
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:900)
at net.thucydides.core.steps.StepEventBus.getBaseStepListener(StepEventBus.java:137)
at cucumber.runtime.SerenityObjectFactory.newInstance(SerenityObjectFactory.java:77)
at cucumber.runtime.SerenityObjectFactory.cacheNewInstance(SerenityObjectFactory.java:58)
at cucumber.runtime.SerenityObjectFactory.getInstance(SerenityObjectFactory.java:48)
at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:46)
at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
at io.cucumber.core.runner.TestStep.run(TestStep.java:63)
at io.cucumber.core.runner.TestCase.run(TestCase.java:103)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:71)
at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.stream.SliceOps$1$1.accept(Unknown Source)
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.collect(Unknown Source)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
at io.cucumber.core.cli.Main.run(Main.java:79)
at cucumber.api.cli.Main.run(Main.java:30)
at cucumber.api.cli.Main.main(Main.java:15)
In order to use the serenity gradle plugin, I need to use the legacy plugin mechanism in gradle.
Can serenity register as a DSL plugin with gradle?
https://plugins.gradle.org/search?term=serenity
So I can do this:
plugins {
...
id "net.serenity-bdd.aggregator" version="2.3.4"
}
Can I create a feature file where it has a Scenario, Scenario Outline, and Examples where it would loop to the Scenario outline only and have one MAIN tag for the feature, for example I have the @red for the feature tag.
e.g
@red
Scenario: Login to System
Given I Login to System
(After disabling a profile, loop back here so I don't need to Logout and Login to the system again)
Scenario Outline: Go to profiles and disable each profile
Given Click Profiles tab
Given Click and click disable
Examples:
||
|Edrick Lacbayo|
|Carl Nera|
|Brent Suarez|
Given Logout to System
Hi,
I have a situation where I need to embed/log the failures in Serenity HTML report which can arise at runtime from @BeforeClass/AfterClass JUnit annotations code
Is there any way this can be achieved.
Please help me on the same.
I have an customized cucumber project(Developed from Cucumber JUnit) with Gosu script. I want to integrate Serenity with it as I need a good reporting.
Can you suggest any method of doing it.
Thanks in Advance.
I am not able to run my tests with that pom and libraries. im using that configuration in intellij
-ea -Dwebdriver.driver=chrome -Dcucumber.options="--tags @XR-xxxx"
Also when i run test via mvn command then i have opened multiples browser windows .
Serenity Reports(/site/serenity/index.html) generated after execution has less number of tests than what was executed.
Serenity Cucumber Configs :
ext { slf4jVersion = '1.7.7' serenityCoreVersion = '2.2.9' serenityCucumberVersion = '2.2.5' serenityRestAssuredVersion = '2.2.10' junitVersion = '4.12' assertJVersion = '3.8.0' logbackVersion = '1.2.3' }
Screens for reference
Actual Test count :
Reported Tests in index.html file:
@wakaleo Can you check this. Please let me know incase any further info is required. Thanks
I just found this method online and I use with @before hook and gives me the TAGS inside a feature/Scenario.
But how do I call this method inside another method, What am I suppose to put inside the parameter?
Don't get me wrong I know how to call a method inside another method but I don't know to use these kind of methods with this kind of parameter.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.