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
718 stars 515 forks source link

When I run test as maven build no html report gets generated #2850

Open softwaredev999 opened 2 years ago

softwaredev999 commented 2 years ago

Hello,

Serenity + Cucumber

When I run as maven build, no html report get generated. Folder "target" is completely blank. I do not see anything in target folder even after I refresh the project in eclipse.

When I run the runner file as jUnit test html reports get generated. I see all the contents under target folder.

POM.xml


    <properties>
        <serenity.version>3.2.0</serenity.version>
        <serenity.maven.version>3.2.0</serenity.maven.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.cucumber.version> 1.9.45</serenity.cucumber.version>
        <encoding>UTF-8</encoding>
    </properties>

    <dependencies>

        <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-core -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-cucumber -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-cucumber</artifactId>
            <version>${serenity.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-single-page-report -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-single-page-report</artifactId>
            <version>${serenity.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.serenity-bdd/serenity-junit -->
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-junit</artifactId>
            <version>${serenity.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/net.serenity-bdd.maven.plugins/serenity-maven-plugin -->
        <dependency>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.version}</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M6</version>
            </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>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.1</version>
                <configuration>
                    <includes>

                        <!-- <include>**/testcases/Parameterization.java</include> -->
                        <include>**/runner/**/*.java</include>
                        <include>**/runner/*.java</include>

                    </includes>

                    <parallel>classes</parallel>
                    <threadCount>2</threadCount>
                    <forkCount>2C</forkCount>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

Runner file

package runner;

import org.junit.runner.RunWith;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features="src/test/resources/features/createaccounts.feature",glue="stepDefinitions")
public class RunCuke {

}

May I know why "target" directory is blank when I run tests as maven build?

softwaredev999 commented 2 years ago
Console:
INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 93.262 s - in Story description
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- maven-failsafe-plugin:2.22.1:verify (default) @ SerenityCucumberPageObjects ---
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ SerenityCucumberPageObjects ---
[INFO] Deleting C:\Users\.......\Serenity_Project\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:15 min
[INFO] Finished at: 2022-06-18T21:35:25-04:00
[INFO] ------------------------------------------------------------------------

Not sure why it says "[INFO] Deleting C:\Users.......\Serenity_Project\target"?

guptadeepak0687 commented 2 years ago

Maven command used too run this?

beyond-danube commented 2 years ago

There is <serenity.maven.version>3.2.0</serenity.maven.version> property in your POM, while no serenity maven plugin, so it's no one to generate this HTML report.

Add a plugin and configure its stage, then should work as expected, e.g. as in the example project https://github.com/serenity-bdd/serenity-cucumber-starter

            <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>