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
720 stars 518 forks source link

import net.serenitybdd.junit.runners.SerenityRunner can not be resolved. #1235

Closed UtsaChakraborty closed 6 years ago

UtsaChakraborty commented 6 years ago

I am trying to create the runner class for Serenity BDD Cucumber project. But the SerenityRunner or CucumberWithSerenity classes can not be found even after importing the following packagesL

import net.serenitybdd.junit.runners.SerenityRunner; or import net.serenitybdd.cucumber.CucumberWithSerenity;

wakaleo commented 6 years ago

That would be an IDE issue - make sure you have imported the project as a Maven or Gradle project.

UtsaChakraborty commented 6 years ago

Hi , Thank you for your reply, I am using ecilpse oxygen IDE and imported the project as an existing Maven Project. Took the help of the POM in Github. PFB the POM am using: <?xml version="1.0" encoding="UTF-8"?> <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>net.serenitybdd.starter</groupId>
<artifactId>starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Sample Serenity BDD project using Cucumber</name>

<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.5</serenity.cucumber.version>
    <encoding>UTF-8</encoding>
    <tags></tags>
    <parallel.tests>4</parallel.tests>
    <webdriver.base.url></webdriver.base.url>
</properties>

<dependencies>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.7</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-jbehave-archetype</artifactId>
        <version>1.8.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit-archetype</artifactId>
        <version>1.8.4</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>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.11.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.20</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.21.0</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.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.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>
</build>

Please let me know how to solve this issue with net.serenitybdd.cucumber.CucumberWithSerenity package

wakaleo commented 6 years ago

Can you run it from the command line?

UtsaChakraborty commented 6 years ago

like validate or compile? because while validating I am getting compilation error for the runner class: package runners; import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions; import net.serenitybdd.cucumber.CucumberWithSerenity; //@RunWith(SerenityRunner.class) @RunWith(CucumberWithSerenity.class) @CucumberOptions(features="src/test/resources/features") public class TestRunner {

}

wakaleo commented 6 years ago

mvn verify

UtsaChakraborty commented 6 years ago

The error is gone...thank you so much :)

wakaleo commented 6 years ago

Sometimes IntelliJ doesn't download all the maven dependencies and you need to run mvn verify from the command line; maybe Eclipse is the same.

UtsaChakraborty commented 6 years ago

seems so

fransiskusak commented 5 years ago

Sometimes IntelliJ doesn't download all the maven dependencies and you need to run mvn verify from the command line; maybe Eclipse is the same.

Hi @wakaleo , i would like to know how to run mvn verify from the command line in IntelliJ on Windows? Is it will be same with just click the Verify lifecycle in Maven Project Toolbar here? Thank you very much for your kindness Capture

fransiskusak commented 5 years ago

The error is gone...thank you so much :)

Hi @UtsaChakraborty it is really gone because of you are running mvn verify in command line ? Thankyou very much. I'm also having a problem in making jbehave test running in parallel, and im trying to add SerenityRunner.class to my code just like the docs in http://thucydides.info/docs/serenity-staging/#_configuration_parallel_executing_with_jenkins Thank you, have a good day

wakaleo commented 5 years ago

Yes, that will work

fransiskusak commented 5 years ago

Hi @wakaleo , thank you for your help. I would like to know does running serenity test in parallel batches (as in the docs here http://thucydides.info/docs/serenity-staging/#_running_serenity_tests_in_parallel_batches ) still working with the serenity-jbehave-archetype version here? Thank you very much for your kindness Capturee

hu-balci commented 2 years ago

Hi, I try to run my serenity project but SerenityRunner class gives me error. I tried mvn verify through terminal than I got compilation error cannot find symbol: class SerenityRunner error.

Screen Shot 2022-01-07 at 10 04 38

I hope someone could help me soon? Thank you

manuel920802 commented 1 year ago

Add this block of dependency to pom.xml file, then click on a little blue icon(m) on the right top corner to update the maven dependencies

    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>

it fixed it for me, hope it works for you too!!

danutailiesei commented 1 year ago

Hello, I cloned the repository: https://github.com/serenity-bdd/serenity-junit-starter and the Intellij doesn't find the class Ensure (import net.serenitybdd.screenplay.ensure.Ensure; ), in pom.xml I added the dependency:

net.serenity-bdd
        <artifactId>serenity-ensure</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>

How can be solved this issue? Thanks

wakaleo commented 1 year ago

Hello, I cloned the repository: https://github.com/serenity-bdd/serenity-junit-starter and the Intellij doesn't find the class Ensure (import net.serenitybdd.screenplay.ensure.Ensure; ), in pom.xml I added the dependency: net.serenity-bdd serenity-ensure ${serenity.version} test

How can be solved this issue? Thanks

Try refreshing your IntelliJ indexes.

Prashanthivelpulaa commented 1 month ago
Screenshot 2024-09-20 at 4 24 35 PM