STS(Eclipse)でJUnit5用のbuild.gradle設定方法
SpringBoot2.2でJUnit5がデフォルトになりました。
build.gradleのデフォルトは以下のようになっています。
dependencies { implementation 'org.springframework.boot:spring-boot-starter' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } }
JUnit5.6を使う場合は以下の2行を追加します。
dependencies { implementation 'org.springframework.boot:spring-boot-starter' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' } testImplementation('org.junit.jupiter:junit-jupiter-api:5.6.0') testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.0') }
junit-platform-gradle-pluginが廃止
以下サイトに記載がある通り、junit-platform-gradle-pluginが廃止になりました。
testタスクにuseJUnitPlatform()を宣言すればよいだけのようです。
JUnit 5 User Guide
test { useJUnitPlatform() }
その他詳細なtestタスクのプロパティが以下に記載されています。
Testing in Java & JVM projects


KHI入社して退社。今はCONFRAGEで正社員です。関西で140-170/80~120万から受け付けております^^
得意技はJS(ES6),Java,AWSの大体のリソースです
コメントはやさしくお願いいたします^^
座右の銘は、「狭き門より入れ」「願わくは、我に七難八苦を与えたまえ」です^^
資格:少額短期保険募集人,FP3級
コメント