gpt4 book ai didi

gradle - 带有 gradle build 的 Karate Gatling 不起作用

转载 作者:行者123 更新时间:2023-12-04 16:04:34 26 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to run Karate and Gatling with Gradle build system

(2 个回答)


7 个月前关闭。




我正在尝试在 gradle build 中使用 Karate 运行 gatling 并出现错误,

/smoketests/SmokeTestRunner.java:19: error: package org.junit.runner does not exist
import org.junit.runner.RunWith;
^
/smoketests/SmokeTestRunner.java:21: error: package com.intuit.karate.junit4 does not exist
import com.intuit.karate.junit4.Karate;
^
/smoketests/SmokeTestRunner.java:30: error: cannot find symbol
@RunWith(Karate.class)
^
symbol: class RunWith
/wskadmin/WskAdminRunner.java:19: error: package org.junit does not exist
import org.junit.Test;
^
/wskadmin/WskAdminRunner.java:20: error: package org.junit.runner does not exist
import org.junit.runner.RunWith;
^
/wskadmin/WskAdminRunner.java:22: error: package com.intuit.karate.junit4 does not exist
import com.intuit.karate.junit4.Karate;

和异常(exception)
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGatlingScala'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)

想要查询更多的信息,
下面是我的 build.gradle 文件,
plugins {
id "com.github.lkishalmi.gatling" version "0.7.3"
}

apply plugin: 'java'
apply plugin: 'maven'

group = 'karate-gatling'
version = '1.0-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
repositories {
mavenCentral()
maven { url "http://repo.maven.apache.org/maven2" }
}

sourceSets {
gatling {
scala.srcDirs = ['src/test/java']
}
test {
java
{
srcDir file('src/test/java')
// exclude '**/*.java'
}
resources
{
srcDir file('src/test/java')
// exclude '**/*.java'
}
}
}
dependencies {
compile group: 'com.jcraft', name: 'jsch', version:'0.1.53'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version:'2.10.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.10.0'
compile group: 'com.intuit.karate', name: 'karate-netty', version:'0.8.0.1'
testCompile group: 'net.masterthought', name: 'cucumber-reporting', version:'3.8.0'
testCompile group: 'com.intuit.karate', name: 'karate-apache', version:'0.8.0.1'
testCompile group: 'com.intuit.karate', name: 'karate-junit4', version:'0.8.0.1'
testCompile group: 'com.intuit.karate', name: 'karate-gatling', version:'0.8.0.1'
gatling 'com.intuit.karate:karate-gatling:0.8.0.1'
gatling 'com.google.code.gson:gson:2.8.0'
gatling 'org.apache.httpcomponents:httpclient:4.3.2'
gatlingCompile 'org.apache.commons:commons-lang3:3.4'
gatlingRuntime 'cglib:cglib-nodep:3.2.0'
}
gatling {
sourceRoot = 'src/test/java'
toolVersion = '2.3.1'
}

运行我的模拟类,我使用下面的命令,

./gradlew clean gatlingRun-mypackage.LoadTest



下面是我的 LoadTest.scala 文件
class LoadTest extends Simulation {
before{
println("Simulation is about to start!")
}
val createActionTest = scenario("smoke").exec(karateFeature("classpath:path/myfeature.feature"))


setUp(createActionTest.inject(rampUsers(5) over (5 seconds))
).maxDuration(1 minutes).assertions(global.responseTime.mean.lt(1100))

after {
println("Simulation is finished!")
}
}

下面是我的运行者文件
import org.junit.runner.RunWith;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;

@RunWith(Karate.class)
@CucumberOptions(tags = {"~@ignore","~@driver","~@reliability","~@resiliency","~@concurrent","~@wskfunctions"})
public class SmokeTestRunner {

}

对此的任何帮助都非常有用

最佳答案

您需要添加一个 testCompile对 JUnit 的依赖,例如:
testCompile 'junit:junit:4.12'

关于gradle - 带有 gradle build 的 Karate Gatling 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51954561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com