我想使用已经到位的空手道测试来运行加特林测试。
为此,我创建了第一个 .scala 文件,并使用所需的依赖项和插件定义了我的 pom.xml。我还下载了2.12.8版本的scala库
我遇到以下错误:找不到模块的项目 Scala 库 2.12.8。找不到该库。
我的IDE是intelliJ。这是我放置在项目中的库
该库被集成到项目模块中,如下所示:
这是运行/调试配置:
这是 scala.file:
package karate.features.api
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import scala.language.postfixOps
import scala.concurrent.duration._
class KarateGatling extends Simulation {
val corpoProtocol = karateProtocol("/v0/corporations/{id}" -> Nil)
val quotProtocol = karateProtocol("/v0/quotations/{id}" -> Nil)
val createCorpo = scenario("blah").exec(karateFeature("classpath:karate/features/api/api-blah-blah.feature"))
val createQuot = scenario("blah").exec(karateFeature("classpath:karate/features/api/api-v-blah.feature"))
setUp(
createCorpo.inject(rampUsers(20) during (10 seconds)).protocols(corpoProtocol),
createQuot.inject(rampUsers(10) during (5 seconds)).protocols(quotProtocol)
这是 pom.xml:
4.0.0 org.springframework.boot spring-boot-starter-父级 2.5.6 com.crm.e2e e2e-ui 0.0.1-快照 e2e-ui 空手道入门
<properties>
<java.version>11</java.version>
<junit-jupiter.version>5.4.0</junit-jupiter.version>
<mockito.version>3.2.4</mockito.version>
<karate.version>1.2.0</karate.version>
<gatling.plugin.version>4.1.5</gatling.plugin.version>
<scala.maven.plugin.version>4.5.6</scala.maven.plugin.version>
<web-drivers.version>3.12.0</web-drivers.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>${web-drivers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${web-drivers.version}</version>
<scope>test</scope>
</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>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<excludes>
<exclude>karate/**/*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling.plugin.version}</version>
<configuration>
<simulationsFolder>src/test/java</simulationsFolder>
<includes>
<include>karate.features.api.perfCreateCorpo</include>
</includes>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala.maven.plugin.version}</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-Jbackend:GenBCode</arg>
<arg>-Jdelambdafy:method</arg>
<arg>-target:jvm-1.8</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:postfixOps</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
我的环境:
请问如何解决该错误?
我修复了类似的 Intellij Maven 同步错误:
找不到模块的项目 Scala 库 2.12.14
我在 pom.xml 中的 scala-maven-plugin 中添加了 Scala 版本的配置标签
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.8.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>2.12.14</scalaVersion>
</configuration>
</plugin>
在 加载 Maven 更改后,我也在 IntelliJ 上遇到类似的错误。
找不到模块 XXX 的项目 Scala 库 2.12.10
对我来说,在 pom.xml 中添加以下依赖项后问题得到解决
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.12.10</version>
</dependency>