我有一个与Kotlin的Gradle项目,有3个源代码文件夹(main,test,integration)。我想为单元和集成测试设置不同的分级测试任务。测试和集成文件夹的用途。我尝试了几种解决方案来设置集成测试任务,但到目前为止都没有工作。到处都提到我需要为集成创建一个不同的源集,添加一些配置以便能够正确地编译该文件夹中的代码,并设置任务本身。都做完了,但当我做测试的时候,他们失败了。然后,报告说ClassNotFound用于所有内容,基本上是指(集成)文件夹中的内容。build.gradle文件和输出结果附在下面
buildscript {
ext.kotlin_version = '1.3.71'
ext.ktor_version = '1.3.2'
ext.exposed_version = '0.22.1'
ext.kodein_version = '6.5.0'
ext.postgres_version = '42.2.6'
ext.stripe_version = '17.16.0'
ext.junit_version = '5.6.0'
ext.log4j2_version = '2.13.1'
ext.aws_sdk_version = '1.11.734'
ext.html_to_pdf_version = '1.0.0'
ext.kotlintest_version = '4.0.2'
repositories {
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "javax.jms:jms:1.1"
}
}
plugins {
id("java")
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.3.71'
id("application")
}
group 'nz.co.redium'
mainClassName = 'nz.co.redium.bookmybusiness.ApplicationKt'
repositories {
mavenCentral()
jcenter()
maven { url "https://dl.bintray.com/kotlin/ktor" }
}
compileKotlin {
kotlinOptions.jvmTarget = "12"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "12"
}
sourceSets {
integration {
java.srcDir "$projectDir/src/integration/kotlin"
kotlin.srcDir "$projectDir/src/integration/kotlin"
resources.srcDir "$projectDir/src/integration/resources"
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
configurations {
integrationImplementation.extendsFrom testImplementation
integrationRuntime.extendsFrom testRuntime
}
test {
useJUnitPlatform()
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Multi-Release': true,
'Main-Class': "$mainClassName"
}
project.archivesBaseName = project.name + '-full'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task integrationTest(type: Test) {
useJUnitPlatform()
description = 'Runs the integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integration.output.classesDirs
classpath = sourceSets.integration.runtimeClasspath
outputs.upToDateWhen { false }
mustRunAfter test
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
check.dependsOn integrationTest
dependencies {
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-server-host-common:$ktor_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "io.ktor:ktor-jackson:$ktor_version"
implementation "io.ktor:ktor-locations:$ktor_version"
implementation "io.ktor:ktor-gson:$ktor_version"
implementation "io.ktor:ktor-client-serialization:$ktor_version"
implementation "io.ktor:ktor-client-serialization-jvm:$ktor_version"
implementation "io.ktor:ktor-client-jetty:$ktor_version"
implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
implementation "org.jetbrains.exposed:exposed-core:$exposed_version"
implementation "org.jetbrains.exposed:exposed-dao:$exposed_version"
implementation "org.jetbrains.exposed:exposed-jdbc:$exposed_version"
implementation "org.jetbrains.exposed:exposed-jodatime:$exposed_version"
implementation "org.postgresql:postgresql:$postgres_version"
implementation "org.apache.logging.log4j:log4j-api:$log4j2_version"
implementation "org.apache.logging.log4j:log4j-core:$log4j2_version"
implementation "org.apache.logging.log4j:log4j-slf4j-impl:$log4j2_version"
implementation "org.springframework.security:spring-security-core:5.1.5.RELEASE"
implementation "com.amazonaws:aws-java-sdk-ses:$aws_sdk_version"
implementation "com.amazonaws:aws-java-sdk-s3:$aws_sdk_version"
implementation "com.stripe:stripe-java:$stripe_version"
implementation "org.apache.velocity:velocity-engine-core:2.1"
implementation "com.openhtmltopdf:openhtmltopdf-core:$html_to_pdf_version"
implementation "com.openhtmltopdf:openhtmltopdf-pdfbox:$html_to_pdf_version"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.10.3"
implementation "org.jetbrains.exposed:exposed-jodatime:$exposed_version"
implementation "io.rest-assured:rest-assured:4.3.0"
implementation "org.hamcrest:hamcrest:2.2"
testImplementation "io.kotest:kotest-runner-junit5-jvm:$kotlintest_version" // for kotest framework
testImplementation "io.kotest:kotest-assertions-core-jvm:$kotlintest_version" // for kotest core jvm assertions
testImplementation "org.assertj:assertj-core:3.11.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
testImplementation "io.ktor:ktor-server-core:$ktor_version"
testImplementation "io.ktor:ktor-server-host-common:$ktor_version"
testImplementation "io.ktor:ktor-gson:$ktor_version"
testImplementation "io.mockk:mockk:1.9.3"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.5'
testRuntime "org.junit.jupiter:junit-jupiter-engine:$junit_version"
}
> Task :integrationClasses UP-TO-DATE
Skipping task ':integrationClasses' as it has no actions.
:integrationClasses (Thread[Daemon worker Thread 29,5,main]) completed. Took 0.0 secs.
:integrationTest (Thread[Daemon worker Thread 29,5,main]) started.
Gradle Test Executor 19 started executing tests.
Gradle Test Executor 19 finished executing tests.
> Task :integrationTest FAILED
file or directory '/opt/receptioner/bookmybusiness/build/classes/java/integration', not found
Caching disabled for task ':integrationTest' because:
Build cache is disabled
Task ':integrationTest' is not up-to-date because:
Task.upToDateWhen is false.
file or directory '/opt/receptioner/bookmybusiness/build/classes/java/integration', not found
Starting process 'Gradle Test Executor 19'. Working directory: /opt/receptioner/bookmybusiness Command: /usr/lib/jvm/java-13-openjdk-amd64/bin/java -Dorg.gradle.native=false @/tmp/gradle-worker-classpath16424721448345780337txt -Xmx512m -Dfile.encoding=UTF-8 -Duser.country=NZ -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 19'
Successfully started process 'Gradle Test Executor 19'
Finished generating test XML results (0.0 secs) into: /opt/receptioner/bookmybusiness/build/test-results/integrationTest
Generating HTML test report...
Finished generating test html results (0.0 secs) into: /opt/receptioner/bookmybusiness/build/reports/tests/integrationTest
:integrationTest (Thread[Daemon worker Thread 29,5,main]) completed. Took 0.523 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':integrationTest'.
> There were failing tests. See the report at: file:///opt/receptioner/bookmybusiness/build/reports/tests/integrationTest/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
13 actionable tasks: 1 executed, 12 up-to-date
奇怪的是,失败的任务引用的是classes/java/integration文件夹(不存在),而不是classes/kotlin/integratin文件夹,后者确实存在,编译后的代码就在这里。
都是我的错。在我将代码从test移到integration文件夹后,里面的一些资源(那些负责初始化类的资源)指向旧目录test,而不是integration。Gradle构建文件是正确的。
This is about end to end integration testing. Tests are executed automatically (Jenkins CI) ROS / MAVROS Tests Prerequisites: JMAVSim Simulation Gazebo ROS and MAVROS Execute Tests To run the complete
一面 自我介绍 实习 一些测试相关的问题 有没有接触过网络配置相关 计网 - [ ] dns协议 说一下dns协议 哪一层 工作原理 ping的过程 动态路由协议 1.手工配置路由 知不知道交换机 怎么配置网关 2.知不知道自学习 假如两台pc之间通过路由通信 他会学习路由发给他的哪些东西 python: 字段key可以使用列表吗 为什么 没回答出来 可以使用元组吗 为什么 面试官建议如果入职 要
当我运行testing.xml时,testNG适合于它的运行,但当运行gradle测试任务时,它不执行测试 buildscript{ext{springBootVersion='1.4.1.release'}存储库{mavenCentral()}依赖项{classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBoo
问题内容: 什么是Java中的综合类?为什么要使用它?如何使用? 问题答案: 例如,当您有一个switch语句时,java创建一个以$开头的变量。如果要查看此示例,请查看其中包含switch语句的类的java反射。当您在类中的任何地方至少有一个switch语句时,您将看到这些变量。 要回答您的问题,我认为您不能访问(除了反射)综合类。 如果要分析的类(通过反射)一无所知,并且需要了解有关该类的非常
我正在编写一个自定义的gradle插件,它生成代码并注入一些新的gradle任务。我当前的问题是,在上,或任务失败。 在您说but hey之前,R文件不是生成的:它是生成的。我在文件系统中看到了文件。 当我在mac上禁用并行任务时,我玩得更多了,它的编译也很好。然而,在特拉维斯身上,它还是失败了。
一面、二面见前面的帖子。 base武汉改到上海了(面试官说的,不是我要改的) 软件开发-java岗 前面通过了2轮技术面试,我一开始以为第三轮面试是HR面,没想到今天面试官是综合面试,面试前一点准备都没有,不过还好面试官没有很难的问题,虽然也有一些问题答不上来 10.17,综合面试,1位面试官,25min 一上来就强调本次面试只有25min,让我注意讲话挑重点 1. 自我介绍 2. 非科班,学校开