- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个Kotlin的Gradle项目,带有3个源文件夹(主要,测试,集成)。我想为单元测试和集成测试设置不同的Gradle测试任务。那是那些测试和集成文件夹的用途。我尝试了几种解决方案来设置集成测试任务,但到目前为止没有任何效果。到处都提到我需要创建一个不同的sourceSet进行集成,添加一些配置以能够正确地编译该文件夹中的代码并设置任务本身。一切都完成了,但是当我运行测试时,它们失败了。然后该报告说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
最佳答案
是我不好在将代码从测试移到集成文件夹后,内部的一些资源(负责初始化类的资源)指向旧的目录测试,而不是集成。 Gradle构建文件正确。
关于kotlin - Kotlin类的Gradle集成测试任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61132601/
我正在查看Kotlin Github page我注意到 Kotlin 语言本身大部分是用 Kotlin 编写的:我只是想知道,一种语言怎么可能大部分都是用它自己的语言编写的?在您可以使用正在创建的语言
我有以下非常简单的 kotlin 代码来演示中缀函数 com.lopushen.demo.presentation 包 fun main(args: Array) { print("Hello
我在 Java 中有 2 个模型类,其中一个扩展了另一个 @UseStag public class GenericMessages extends NavigationLocalizationMap
Kotlin 代码 runBlocking { flow { for (i in 0..4) { println("Emit $i")
这三个 Kotlin 插件和它们的实际作用有什么区别? plugins { id 'kotlin-android' id 'org.jetbrains.kotlin.android'
我正在为某些现有库添加 Kotlin 原生 linuxX64 目标支持。库已成功编译,但在运行测试用例时,出现以下运行时错误: kotlin.native.concurrent.InvalidMuta
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 2 年前。 Improve t
我创建了一个类并向其添加了一个与成员函数具有相同签名的扩展,并执行了这个方法,它总是执行成员方法。 class Worker { fun work() = "...working" } fun
我知道传递给函数的参数将被视为“val”,即使变量被初始化为“var”。但这对我来说一直是个问题。在下面的示例代码中,我想通过使用函数“changeNum”修改变量“num”的值。但当然,Kotlin
现在,我正在尝试用 Kotlin 重写我的 Java 应用程序。然后,我遇到了日志语句,比如 log.info("do the print thing for {}", arg); 所以我有两种方法可
有点出名article关于许多语言的异步编程模型的状态,指出它们存在“颜色”问题,特别是将生态系统分为两个独立的世界:异步和非异步。以下是这种语言的属性: 每个函数都有一种颜色,红色或蓝色(例如asy
因为 KDoc 文档生成引擎是 abandoned in favor of Dokka , Kotlin 文档应该称为“KDoc 注释”,还是“Dokka 注释”? 最佳答案 如所述here , KD
我想在可空对象上传递函数引用。以 Android 为例,假设我想使用 Activity#onBackPressed来自作为该事件的子级的片段。 如果我想调用这个函数,我可以很容易地做到 activit
我有一个列表 (x, y)其中y只能是 0 或 1 这样 例如: [(3, 0), (3, 1), (5, 1)] [(5, 0), (3, 1), (5, 1)] [(1, 1), (3, 1),
从强类型语言的定义来看: A strongly-typed programming language is one in which each type of data (such as intege
这不能编译的事实是否意味着它们不是一流的类型? fun foo(s: String): Int = s.length // This won't compile. val bar = foo 有没有办
如果在 Java i++是一个表达式和 i++;是一个表达式语句,分号(;) 在 Kotlin 中是可选的,是 i++ Kotlin 中的表达式或表达式语句? 最佳答案 i++是一个表达式,因为它有一
代码(如下所示)是否正确?它取自 Kotlin-docs.pdf 的第 63 页,这也是 https://kotlinlang.org/docs/reference/generics.html 的最后
我正在尝试使用 Kotlin 为 Android 的一些全局 API 解析器(检查网络连接、调用 API 并通过来自源的单个调用返回格式化数据),并且在某些时候我不得不创建一个通用类型 object就
kotlinlang 中的任务: 使用月份变量重写此模式,使其与格式 13 JUN 1992(两位数字、一个空格、一个月份缩写、一个空格、四位数字)中的日期相匹配。 答案是:val month = "
我是一名优秀的程序员,十分优秀!