我正在尝试在gradle构建中使用空手道进行加特林战斗,并使其低于错误,
/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;
和例外
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 {
}
对此有任何帮助
答案 0 :(得分:0)
您需要在JUnit上添加testCompile
依赖项,例如:
testCompile 'junit:junit:4.12'