Search code examples
javacucumberquarkus

quarkus-cucumber does not find step definitions


I'm trying to set up acceptance tests for a Quarkus app, using quarkus-cucumber 0.6.0 (on Quarkus platform version 2.15.2.Final), but it fails to find the step definitions.

My package structure looks as follows:

src
  main
    api
    backend
    gui
  test
    java 
      com.example.test
        AcceptanceTest.java
        steps
          BlahSteps.java
          BlubbSteps.java
    specifications
      blah.feature
      blubb.feature

The AcceptanceTest.java specifies the package for the glue:

package com.example.test

@CucumberOptions(
    features = "src/test/specifications",
    glue = "com.example.test.steps"
)
public class AcceptanceTest extends CucumberQuarkusTest {

    public static void main(String[] args) {
        runMain(AcceptanceTest.class, args);
    }
}

And the BlahSteps.java in that package contains methods for the steps in blah.feature. (It also ends up correctly in target/test-classes.)

Still, no matter whether I run mvn clean test in the terminal (or ./mvnw quarkus:test after annotating the AcceptanceTest with @QuarkusTest) or run the test in IntelliJ, it runs the blah feature and tells me:

You can implement missing steps with the snippets below:
...

Why is it not finding the glue? Am I missing something?


Solution

  • Configure surefire plugin like below

    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
            <includes>
                <include>**/AcceptanceTest*.java</include>
            </includes>
            <testFailureIgnore>true</testFailureIgnore>
            <systemPropertyVariables>
                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
            </systemPropertyVariables>
        </configuration>
    </plugin>
    

    below you can see how cucumber triggered.

    mintozzy@laptop:~/tmp/quarkus-cucumber-example$ mvn test
    [INFO] Scanning for projects...
    [WARNING] 
    [WARNING] Some problems were encountered while building the effective model for com.example:quarkus-cucumber-example:jar:1.0.0-SNAPSHOT
    [WARNING] 'build.plugins.plugin.version' for io.quarkus.platform:quarkus-maven-plugin is missing. @ line 56, column 15
    [WARNING] 
    [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
    [WARNING] 
    [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
    [WARNING] 
    [INFO] 
    [INFO] ----------------< com.example:quarkus-cucumber-example >----------------
    [INFO] Building quarkus-cucumber-example 1.0.0-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ quarkus-cucumber-example ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /home/mintozzy/tmp/quarkus-cucumber-example/src/main/resources
    [INFO] 
    [INFO] --- quarkus-maven-plugin:3.0.0.Alpha2:generate-code (default) @ quarkus-cucumber-example ---
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ quarkus-cucumber-example ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- quarkus-maven-plugin:3.0.0.Alpha2:generate-code-tests (default) @ quarkus-cucumber-example ---
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ quarkus-cucumber-example ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ quarkus-cucumber-example ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) @ quarkus-cucumber-example ---
    [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
    [INFO] 
    [INFO] -------------------------------------------------------
    [INFO]  T E S T S
    [INFO] -------------------------------------------------------
    [INFO] Running com.example.test.AcceptanceTestRunner
    2023-01-16 20:05:56,769 INFO  [io.quarkus] (main) quarkus-cucumber-example 1.0.0-SNAPSHOT on JVM (powered by Quarkus 2.15.2.Final) started in 2.091s. Listening on: http://localhost:8081
    2023-01-16 20:05:56,771 INFO  [io.quarkus] (main) Profile test activated. 
    2023-01-16 20:05:56,771 INFO  [io.quarkus] (main) Installed features: [cdi, cucumber, resteasy, resteasy-jackson, smallrye-context-propagation, vertx]
    
    Scenario: You're still alright   # specifications/everything_is_fine.feature:9
      Given you are having coffee    # com.example.test.steps.EverythingIsFineSteps.you_are_having_coffee()
      And there is a fire around you # com.example.test.steps.EverythingIsFineSteps.there_is_a_fire_around_you()
      When you are still alright     # com.example.test.steps.EverythingIsFineSteps.you_are_still_alright()
      Then everything is fine        # com.example.test.steps.EverythingIsFineSteps.everything_is_fine()
    
    Scenario: You start to feel it   # specifications/everything_is_fine.feature:14
      Given you are having coffee    # com.example.test.steps.EverythingIsFineSteps.you_are_having_coffee()
      And there is a fire around you # com.example.test.steps.EverythingIsFineSteps.there_is_a_fire_around_you()
      When you start to feel it      # com.example.test.steps.EverythingIsFineSteps.you_start_to_feel_it()
      Then panic                     # com.example.test.steps.EverythingIsFineSteps.panic()
    
    2 Scenarios (2 passed)
    8 Steps (8 passed)
    0m0.893s
    
    
    [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.11 s - in com.example.test.AcceptanceTestRunner
    2023-01-16 20:05:58,732 INFO  [io.quarkus] (main) quarkus-cucumber-example stopped in 0.035s
    [INFO] 
    [INFO] Results:
    [INFO] 
    [INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0
    [INFO] 
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  10.311 s
    [INFO] Finished at: 2023-01-16T20:05:58Z
    [INFO] ------------------------------------------------------------------------
    

    here is the full code.