0

Is it possible to generate reports while test still executing. Passed Panding

My pom.xml looks like this

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


    <modelVersion>4.0.0</modelVersion>


    <groupId>com.insurance.abc</groupId>
    <artifactId>insurance</artifactId>
    <version>1.0-SNAPSHOT</version>



    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>



    <dependencies>

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-jbehave</artifactId>
            <version>1.13.0</version>
        </dependency>

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>1.1.37-rc.6</version>
        </dependency>

    </dependencies>



    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.9.1</version>
                <!--<executions>
                    <execution>
                        <id>add-integration-test-source-as-test-sources</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src/it/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>-->
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.18</version>
                <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>1.1.37-rc.6</version>
                <dependencies>
                    <dependency>
                        <groupId>net.serenity-bdd</groupId>
                        <artifactId>serenity-core</artifactId>
                        <version>1.1.37-rc.6</version>
                    </dependency>
                </dependencies>
                 <executions>
                    <execution>
                        <phase>post-integration-test</phase>
                        <goals>
                            <goal>aggregate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

If I set <phase>post-integration-test</phase> to <phase>pre-integration-test</phase> then my report generated before test and this is it. No test in reports. Can you please help me to figureout why?

java_user
  • 929
  • 4
  • 16
  • 39

1 Answers1

0

The reason for the behaviour you are seeing is fairly simple: As tests are being run Jbehave saves results of each test in target/jbehave/ as storyclass.html and storyclass.stats. When the report generation runs, it consumes those files to generate your report under target/jbehave/reports. By attempting to generate your reports before running the tests, you are generating reports with no input.

With regards to how to achieve your desired outcome, I don't think there is any official way provided by Jbehave.

I wouldn't recommend doing this but if I had to do it I would start by trying to add an @AfterStory step that runs report generation to update the reports each time a story finishes. Problem with this is that even if it works, each time this happens the whole report is re-generated which will get slower and slower with each story run in your test suite, so if you have a big suite you will end up adding a bit to your execution time. You could then take it a step further and have your step do some custom light-weight report generation to give you a temporary status report that appends rather then re-creates the reports which can be replaced by the full report generated by Jbehave post execution.