Test is getting ignored but shown as passed
Opened this issue · 1 comments
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!!
This is a usage question rather than a defect, could you raise it on https://serenity-bdd.rocket.chat instead?