在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):koral--/jacoco-gradle-testkit-plugin开源软件地址(OpenSource Url):https://github.com/koral--/jacoco-gradle-testkit-plugin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):jacoco-gradle-testkit-pluginGradle plugin for JaCoCo code coverage in tests using Gradle TestKit. MotivationThere is no built-it support for code coverage in TestKit. Those tests run in separate JVM and configuration of JaCoCo plugin is not taken into account. See Gradle forum post for more details. Usage
plugins {
id "pl.droidsonroids.jacoco.testkit" version "1.0.8"
} This will add
class AwesomeTest {
fun InputStream.toFile(file: File) {
use { input ->
file.outputStream().use { input.copyTo(it) }
}
}
fun GradleRunner.withJaCoCo(): GradleRunner {
javaClass.classLoader.getResourceAsStream("testkit-gradle.properties").toFile(File(projectDir, "gradle.properties"))
return this
}
@get:Rule
val temporaryFolder = TemporaryProjectFolder()
@Test
fun `empty project builds successfuly`() {
val result = GradleRunner.create()
.withProjectDir(temporaryFolder.root)
.withTestKitDir(temporaryFolder.newFolder())
.withPluginClasspath()
.withJaCoCo()
.build()
}
} Adding coverage for another task (ex. integrationTest)By default the plugin configures the To configure the coverage for another task just add something like this: jacocoTestKit {
applyTo("intTestRuntimeOnly", tasks.named("integrationTest"))
} Custom JaCoCo destination fileJaCoCo destination file path reads it from the tasks.named("test").configure {
jacoco {
destinationFile = file('integration.exec')
}
} Update from 1.0.5 or olderStarting from plugin version 1.0.6 the minimum supported Gradle version is 4.9 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论