spring-bootcucumbermaven-pluginspring-boot-test

Maven & Cucumber integration tests reporting


I have this cucumber integration testing suit for a spring-boot application, I'm trying to generate a visualization report for it and I'm not able to.

this is my folder structure

|_ src
  |_ main
  |_ test
    |_ java
      |_ common
      |_ steps
      |_ CucumberIntegrationRunnerTest.java
    |_ resources
      |_ data
        |_ [json files]
      |_ [feature files]
  |_ target

pom.xml looks like the following

<dependencies>
    <!-- cucumber for integration tests-->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>7.18.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>7.18.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-spring</artifactId>
        <version>7.18.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>maven-cucumber-reporting</artifactId>
        <version>5.8.1</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <version>7.18.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <testFailureIgnore>true</testFailureIgnore>
            <includes>
                <include>**/*Test.java</include>
            </includes>
        </configuration>
    </plugin>
    <plugin>
        <groupId>net.masterthought</groupId>
        <artifactId>maven-cucumber-reporting</artifactId>
        <version>5.8.1</version>
        <executions>
            <execution>
                <id>execution</id>
                <phase>verify</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
                <configuration>
                    <projectName>optumcare-individual-azure-sink</projectName>
                    <outputDirectory>${project.build.directory}</outputDirectory>
                    <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                    <checkBuildResult>false</checkBuildResult>
                    <jsonFiles>
                        <param>**/cucumber.json</param>
                    </jsonFiles>
                    <buildNumber>1</buildNumber>
                    <checkBuildResult>false</checkBuildResult>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>

my test runner configuration looking like the following

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("cucumber/integration")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "path_to_integration_folder")
@CucumberOptions(plugin = {"pretty", "json:target/cucumber.json"}, monochrome = true)
@CucumberContextConfiguration
@SpringBootTest
public class CucumberIntegrationRunnerTest { ... }

running mvn clean verify completes fine with the tests running successfully & the report html is being generated, but I'm getting a No JSON report file was found error.

enter image description here enter image description here

I've tried multiple changes to the path inside the pom or the test running, but nothing seem to work.

not sure what am I doing wrong here... any help would be appreciated.


Solution

  • You are using both cucumber-junit (JUnit 4) and cucumber-junit-platform-engine (JUnit 5). Both can be used to run Cucumber, so you only need one of these.

    Secondly, you are using @CucumberOptions which is how you would configure Cucumber when using JUnit 4.

    But you are using a declarative suite from JUnit 5. So to configure Cucumber you should use @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty, json:target/cucumber.json").