Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

net.masterthought.cucumber.ValidationException: No report file was added

Report is not getting generated When i am using cucumber-maven reporting plugin see image here

like image 218
vasudev.p Avatar asked Nov 07 '22 16:11

vasudev.p


2 Answers

Primary Thing: Message "net.masterthought.cucumber.ValidationException: No report file was added!" generally comes when there is something wrong in the configuration of Maven Cucumber Html Report Plugin. (configuration example below)

<plugin>
    <groupId>net.masterthought</groupId>
    <artifactId>maven-cucumber-reporting</artifactId>
    <version>4.2.3</version>
    <executions>
        <execution>
            <id>execution</id>
            <phase>verify</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <projectName>TheDayAfterTomorrow</projectName>
                <!-- output directory for the generated report -->
                <outputDirectory>${project.build.directory}/cucumber-maven-report</outputDirectory>
                <inputDirectory>${project.build.directory}/cucumber-json</inputDirectory>
                <jsonFiles>
                    <!-- supports wildcard or name pattern -->
                    <param>**/*.json</param>
                </jsonFiles>
                <skippedFails>true</skippedFails>
                <enableFlashCharts>true</enableFlashCharts>
                <buildNumber>10.2.1</buildNumber>
                <parallelTesting>false</parallelTesting>
            </configuration>
        </execution>
    </executions>
</plugin>

Secondary Thing, in case you are still using old version of cucumber (1.2.5) so update your POM file with latest available cucumber version or anything above >=4.0.0 in order to have better outcome.

Cucumber Execution via JUnit:

 <dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>4.2.6</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.6</version>
</dependency>

Cucumber Execution via TestNG:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>4.2.6</version>
</dependency>

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-testng</artifactId>
    <version>4.2.6</version>
</dependency>
like image 108
TheSociety Avatar answered Nov 29 '22 20:11

TheSociety


The root cause of this issue is that maven-cucumber-reporting can't find any JSON file in the directory that was defined in the POM. This JSON file is generated using @CucumberOptions annotation in the runner class. So the problem that you see is because you have defined a different directory in @CucumberOptions and in the inputDirectory field within the configuration of the plugin in the POM file.

To solve it, make sure that both directories match. For example:

In the runner file you should have target/cucumber/cucumber.json

@CucumberOptions(features = "classpath:feature", tags = "@component-test",
        glue = {"feature.component"},
        plugin = {"json:target/cucumber/cucumber.json")

So in the POM you should have <inputDirectory>${project.build.directory}/cucumber</inputDirectory> and you should make sure that jsonFiles property is correctly defined:

<jsonFiles>
  <param>**/*.json</param>
</jsonFiles>

So at the end the configuration should look like:

        <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>${maven-cucumber-reporting.version}</version>
            <executions>
                <execution>
                    <id>generate-cucumber-reports</id>
                    <phase>test</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <jsonFiles>
                            <param>**/*.json</param>
                        </jsonFiles>
                        <outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
                        <inputDirectory>${project.build.directory}/cucumber</inputDirectory>
                        <checkBuildResult>false</checkBuildResult>
                    </configuration>
                </execution>
            </executions>
        </plugin>
like image 44
hfc Avatar answered Nov 29 '22 21:11

hfc