亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

IntelliJ Spring Gradle“運行所有測試”不起作用(單個測試運行良好)

IntelliJ Spring Gradle“運行所有測試”不起作用(單個測試運行良好)

墨色風雨 2023-03-23 15:03:19
我有一個帶有 4 個測試和以下 build.gradle 的 Spring Gradle 項目:plugins {    id 'org.springframework.boot' version '2.1.6.RELEASE'    id 'java'}apply plugin: 'io.spring.dependency-management'version = '0.0.1'sourceCompatibility = '11'configurations {    compileOnly {        extendsFrom annotationProcessor    }}repositories {    mavenCentral()}dependencies {    implementation 'org.springframework.boot:spring-boot-starter'    //Rest Controller    compile 'org.springframework.boot:spring-boot-starter-web'    //Lombok    compileOnly 'org.projectlombok:lombok'    annotationProcessor 'org.projectlombok:lombok'    //Tests    testImplementation 'org.springframework.boot:spring-boot-starter-test'    testCompile 'com.h2database:h2'    //Database    compile("mysql:mysql-connector-java")    compile("org.springframework.boot:spring-boot-starter-data-jpa")    //Authentication    compile 'org.springframework.security:spring-security-crypto' //e.g. PasswordEncoder    compile 'org.springframework.boot:spring-boot-starter-security' //e.g. @PreAuthorize    //ResourceAssembler    compile 'org.springframework.boot:spring-boot-starter-hateoas'    //JWT Token generation    compile("com.auth0:java-jwt:3.4.0")}我可以用“運行測試”開始每個測試,它工作得很好,但是當我嘗試“運行所有測試”時,它失敗并顯示消息“運行“全部”時出錯:沒有 junit.jar”我已經嘗試添加以下任何依賴項,但都沒有解決問題:testCompile 'junit:junit:4.12testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')我正在使用 IntelliJ
查看完整描述

1 回答

?
冉冉說

TA貢獻1877條經驗 獲得超1個贊

類路徑派生自包含測試的模塊的依賴項。這些文件是從工作目錄加載的,因此應該在測試的運行/調試配置中指定它。以下鏈接解釋了如何為您的測試配置它。 在 IntelliJ 中運行 JUnit 測試

另外,我想檢查 IntelliJ IDE 中的測試運行器配置。打開首選項或設置對話框窗口。檢查 Gradle 配置并查找構建、執行、部署 | 構建工具 | 搖籃 | 亞軍:

http://img1.sycdn.imooc.com//641bf9da00011b5b06590546.jpg

在這里,選擇 Gradle 測試運行器。配置完成后,您可以使用覆蓋率運行您的代碼,看看它是否有幫助。



查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 118 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號