serenity-bdd / serenity-cucumber4

Other
13 stars 10 forks source link

com.automation.test.RunnerTest.initializationError while using CucumberWithSerenity.class i.s.o Cucumber.class #32

Closed raktim1988 closed 3 years ago

raktim1988 commented 3 years ago

image

Runner Class:

package com.automation.test;

import cucumber.api.junit.Cucumber; import net.serenitybdd.cucumber.CucumberWithSerenity; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.SnippetType; import org.junit.runners.model.InitializationError;

@RunWith(CucumberWithSerenity.class) @CucumberOptions(

    features = {"src/test/resources/"},
    plugin = {"pretty"},
    glue = {"com/automation/test/"}, strict = true,
    dryRun = false, monochrome = true, snippets = SnippetType.CAMELCASE)

public class RunnerTest { public static void generateReport(){

}

}

Pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<groupId>com.sample.automation</groupId>
<artifactId>Adidas</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Adidas</name>

<properties>
    <cucumber.version>4.2.0</cucumber.version>
    <serenity.version>2.0.41</serenity.version>
    <serenity.cucumber.version>1.0.15</serenity.cucumber.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.0</version>
    </dependency>
    <!--Dependency For Cucumber Java -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>1.2.5</version>
    </dependency>
    <!-- Dependency For Cucumber JUnit Runner -->
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>1.2.5</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay-webdriver</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
        <exclusions>
            <exclusion>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber4</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 For SLF4J and Log4j -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.12</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- Dependency For Apache POI for .xlsx -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.8-beta4</version>
    </dependency>
    <!-- Dependency For Apache POI -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.9</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                 <includes>
                     <include>**/RunnerTest.java</include>
                 </includes>
                <testFailureIgnore>true</testFailureIgnore>
                <forkCount>1</forkCount>
                <parallel>methods</parallel>
                <threadCount>3</threadCount>
                <useUnlimitedThreads>false</useUnlimitedThreads>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.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.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>
</build>
<description>Adidas</description>

Please help!

wakaleo commented 3 years ago

You have a mix of conflicting dependency versions. Have a look at https://github.com/serenity-bdd/serenity-cucumber-starter

raktim1988 commented 3 years ago

Thanks, looks better now with small adjustments in the pom.xml , however what I see now is : Test results for 0 tests generated in 2.2 secs in directory: that means the tests are not creating a report or being captured. Could you help ?

wakaleo commented 3 years ago

This seems like a usage problem - http://gitter.im/serenity-bdd/serenity-core is probably a better place to ask.

raktim1988 commented 3 years ago

I fixed the issue , for reference pls look in to : https://github.com/raktim1988/MyTestSerenitywithCucumberBDD6.git