Java Project Run Cucumber IT in different module

I have a Java, spring project structure like so:

├── src
│   ├── integrationTest
│   │   ├── java
│   │   │   ├── foo.bar.cuke.project
│   │   │   │   ├── controller
│   │   │   │   │   ├── TestControllerIT.java
│   │   │   │   ├── CucumberSpringConfiguration.java
│   │   │   │   ├── CucumberTest.java
│   │   ├── resources
│   │   │   ├── features
│   │   │   │   ├── test.feature
│   │   │   ├── junit-platform.properties
│   ├── main
│   ├── test

Here is what the various files look like:

CucumberSpringConfiguration.java:

@SpringBootTest(webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT)
@CucumberContextConfiguration
public class CucumberSpringConfiguration {
    @Autowired
    protected TestRestTemplate testRestTemplate;
}

CucumberTest.java:

@Suite
@SelectClasspathResource("src/integrationTest/resources/features")
public class CucumberTest {
}

TestControllerIT.java:

public class TestControllerIT extends CucumberSpringConfiguration {
    @Given("random given text")
    public void testGiven() {
        System.out.println("test");
    }
}

test.feature:

Feature: This is a test feature

  Scenario: Test scenario
    Given random given text
    When a condition is met
    Then do something

junit-platform.properties:

cucumber.plugin=junit:target/cucumber-reports/cucumber.xml
cucumber.glue=foo.bar.cuke.project.controller

I am using IntelliJ with the cucumber and gherkin plugins. I don’t know exactly what file to run but when I run the feature file I get this error:

Suppressed: java.lang.SecurityException: class "org.bouncycastle.jcajce.provider.asymmetric.edec.KeyFactorySpi$Ed448"'s signer information does not match signer information of other classes in the same package
        at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1156)
        at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:911)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1020)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)

When I run the CucumberTest class, I get this error:

> Task :integrationTest
  0 passing (1.9s)
> Task :integrationTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':integrationTest'.
> No tests found for given includes: [foo.bar.cuke.project.CucumberTest](--tests filter)

What is the issue with my setup? Why is cucumber unable to find my IT file and run the test?

My tech stack is:

  • Java 11
  • Spring framework 5.3
  • JUnit 5
  • Cucumber 7.18
  • Gradle 7.3

I have tried adding the following to my build.gradle to no success:

testSets {
    integrationTest
}

test {
    systemProperty 'server.ssl.enabled', false
}

Also tried changing the directory structure to have the controller IT under a directory called StepDefintions.

Directory Structure

Ensure your directory structure looks like this:

├── src
│   ├── integrationTest
│   │   ├── java
│   │   │   ├── foo.bar.cuke.project
│   │   │   │   ├── controller
│   │   │   │   │   ├── TestControllerIT.java
│   │   │   │   ├── CucumberSpringConfiguration.java
│   │   │   │   ├── CucumberTest.java
│   │   ├── resources
│   │   │   ├── features
│   │   │   │   ├── test.feature
│   │   │   ├── junit-platform.properties

CucumberSpringConfiguration.java

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@CucumberContextConfiguration
public class CucumberSpringConfiguration {
    @Autowired
    protected TestRestTemplate testRestTemplate;
}

CucumberTest.java

import io.cucumber.junit.platform.engine.Cucumber;

@Cucumber
public class CucumberTest {
}

TestControllerIT.java

import io.cucumber.java.en.Given;

public class TestControllerIT extends CucumberSpringConfiguration {
    @Given("random given text")
    public void testGiven() {
        System.out.println("test");
    }
}

test.feature

Feature: This is a test feature

  Scenario: Test scenario
    Given random given text
    When a condition is met
    Then do something

junit-platform.properties

cucumber.plugin=junit:target/cucumber-reports/cucumber.xml
cucumber.glue=foo.bar.cuke.project.controller

build.gradle

Make sure you have the necessary dependencies and configurations. Here’s a sample build.gradle snippet:

plugins {
    id 'java'
    id 'org.springframework.boot' version '2.5.4' // Use your version
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'io.cucumber' version '7.18.0' // Use your version
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.cucumber:cucumber-java'
    testImplementation 'io.cucumber:cucumber-spring'
    testImplementation 'io.cucumber:cucumber-junit-platform-engine'
}

tasks.named('test') {
    useJUnitPlatform()
}

Running Tests

To run your Cucumber tests, you should execute the following Gradle command:

./gradlew integrationTest

Make sure to check for any version conflicts in your dependencies, especially related to Bouncy Castle or other libraries that might be causing the SecurityException. If the issue persists, consider checking the classpath for duplicate or conflicting JAR files.