Search code examples
karate

Karate Gatling Simulation: "No Simulations to Run" Error Java 21


I am integrating Karate with Gatling for performance testing. However, when I run my simulation using Maven, I encounter the following error:

[ERROR] No simulations to run [INFO] BUILD FAILURE Project Structure: Here is my project structure:

karate/
├── src/
│   ├── test/
│   │   ├── java/
│   │   │   ├── resources/
│   │   │   │   ├── performance/
│   │   │   │   │   ├── PerfTest.scala
│   │   │   │   │   ├── demoTest.feature

Maven Configuration: Here is the relevant section of my pom.xml:

 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>21</java.version>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.surefire.version>2.22.2</maven.surefire.version>
        <karate.version>1.4.1</karate.version>
        <gatling.plugin.version>4.12.2</gatling.plugin.version>
    </properties> 

    <dependencies>         
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-junit5</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cucumber-reporting</artifactId>
            <version>5.7.5</version>
        </dependency>
        <dependency>
            <groupId>com.intuit.karate</groupId>
            <artifactId>karate-gatling</artifactId>
            <version>${karate.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
    
        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerArgument>-Werror</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.version}</version>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
            </plugin>

            <plugin>
                <groupId>io.gatling</groupId>
                <artifactId>gatling-maven-plugin</artifactId>
                <version>${gatling.plugin.version}</version>
                <configuration>
<simulationsFolder>src/test/java/resources/performance</simulationsFolder>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>4.9.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <args>
                                <arg>-Jbackend:GenBCode</arg>
                                <arg>-Jdelambdafy:method</arg>
                                <arg>-target:jvm-21</arg>
                                <arg>-deprecation</arg>
                                <arg>-feature</arg>
                                <arg>-unchecked</arg>
                                <arg>-language:implicitConversions</arg>
                                <arg>-language:postfixOps</arg>
                            </args>
                        </configuration>
                    </execution>
                </executions>
            </plugin> 
        </plugins>   
       </pluginManagement>
    </build>       
</project>

Scala Simulation File: Here is my PerfTest.scala file:

package performance

import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.concurrent.duration._

class PerfTest extends Simulation {

  val protocol = karateProtocol().runner.karateEnv("perf")

  val create = scenario("demo").exec(karateFeature("classpath:resources/performance/demoTest.feature"))

  setUp(
    create.inject(rampUsers(10) during (5 seconds)).protocols(protocol)
  )
}

Command Used:

mvn clean test-compile gatling:test

Solution

  • Most likely a mismatch of package name. Try changing

    package performance

    to:

    package resources.performance.

    This is a "Java thing" and tricky, do look at the sample projects and pay attention to the folder structures etc. For e.g. karate-todo - note the value of <simulationsFolder>.