当前位置: 首页 > 知识库问答 >
问题:

Gradle不在命令行上执行任何测试

蒋栋
2023-03-14

我的Gradle项目使用了KotlinDSL和JUnit5/Jupiter(以及Kotlin作为编程语言),Gradle似乎没有正确地接受我的任何测试。当我在命令行上运行Gradle测试时,它告诉我

SUCCESS: Executed 0 tests in 1s

不管我怎么尝试。然而,在我的IDE中,我可以轻松地运行项目中的每个单个测试类,而不会出现任何问题。

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.1.8.RELEASE"
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    id("com.adarshr.test-logger") version "1.7.0"
    kotlin("jvm") version "1.2.71"
    kotlin("plugin.spring") version "1.2.71"
    kotlin("plugin.jpa") version "1.2.71"
}

group = "myprojectgroup"
version = "1.0-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8


val junitVersion="5.5.2"
val mockitoVersion="2.28.2"

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
    implementation("org.flywaydb:flyway-core")
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    runtimeOnly("com.h2database:h2")
    testImplementation("org.springframework.boot:spring-boot-starter-test")
    testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
    testCompile ("org.mockito:mockito-core:$mockitoVersion")
    testCompile("org.mockito:mockito-junit-jupiter:$mockitoVersion")
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

tasks.test {
    useJUnitPlatform {
        includeEngines("junit-jupiter")
    }
}

共有1个答案

常小白
2023-03-14

看看这个:当所有测试都是最新的时,如何运行Gradle测试?这可能是原因和修复您的问题。

 类似资料:
  • 并将我的文件保存如下: Runner类: 把这个放到我的大楼里。格雷德尔: 但我得到的回应是: 但是,我不能看到我的测试是否通过。我做错了什么? 分级版本:2.14.1

  • 我试图从jenkins master中触发特定节点的execute shell中的gradle命令,它正在运行一个异常,如下所示- 但是,如果am试图在本地工作区下的同一节点中执行shell,则gradle命令可以工作。 null 授予对。gradle的读写访问权限 在这里,node-jenkins和master-jenkins都安装了gradle V2.5。为什么执行shell触发从主人詹金斯找

  • 问题内容: 我有一个非常简单的问题。我是Mac的新手,我正试图将Java项目移到新Mac上。该项目有一个Gradlew文件,我认为我可以从命令行运行以在任何计算机上构建和运行。当我从命令行(在gradlew文件的位置)执行gradlew时,它说未找到gradlew。我是否缺少有关如何从bash shell运行命令的内容? 问题答案: 您的gradlew目录未包含在PATH中,因此您必须指定grad

  • 本文向大家介绍Dapper.NET 执行不返回任何结果的命令,包括了Dapper.NET 执行不返回任何结果的命令的使用技巧和注意事项,需要的朋友参考一下 示例            

  • 问题内容: 如何从命令行在Node.js上运行Jasmine测试?我已经通过npm安装了jasmine- node并编写了一些测试。我想在目录中运行测试并在终端中获取结果,这可能吗? 问题答案: 编辑 由于不再维护该软件包,因此这似乎不再是当前的最佳答案。请参阅下面的答案 你可以这样做 从您的测试目录 这会将茉莉花安装到../node_modules/jasmine-node 然后 从我的演示中做

  • PHPUnit 命令行测试执行器可通过 phpunit 命令调用。下面的代码展示了如何用 PHPUnit 命令行测试执行器来运行测试: phpunit ArrayTest PHPUnit 6.5.0 by Sebastian Bergmann and contributors. .. Time: 0 seconds OK (2 tests, 2 assertions) 上面这个调用例子中,