私の目標は、統合テスト用に設定されたソースを設定することです。私は「intTest」と呼ばれるソースのセットを作成しました。私は簡単なテストの内部を置きます:
package com.github.frozensync;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class Application {
@Test
@DisplayName("should work")
void foo() {
assertEquals(2, 2);
}
}
私はそれを実行しようとすると、私は次のエラーを取得します:
FAILURE:ビルドが例外で失敗しました。
*何が間違っていた:
実行は、タスクに失敗しました「:integrationTest」。
[com.github.frozensync.Application](filter.includeTestsMatching):与えられたために>ありませんテストが含まれてい
*お試しください:
ファイル名を指定して実行--stacktraceオプションでスタックトレースを取得します。--info以上のログ出力を取得するには--debugオプション付きで実行します。完全な洞察を得るために--scanを実行します。
*で、より多くの助けを得るhttps://help.gradle.org
BUILDは0msとに失敗しました
そして、これは私です build.gradle
plugins {
id 'java'
}
group 'com.github.frozensync'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
sourceSets {
intTest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
idea {
module {
testSourceDirs += sourceSets.intTest.java.srcDirs
testResourceDirs += sourceSets.intTest.resources.srcDirs
}
}
configurations {
intTestImplementation.extendsFrom implementation
intTestRuntimeOnly.extendsFrom runtimeOnly
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
intTestImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
test {
useJUnitPlatform()
}
task integrationTest(type: Test) {
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = sourceSets.intTest.output.classesDirs
classpath = sourceSets.intTest.runtimeClasspath
shouldRunAfter test
}
check.dependsOn integrationTest
私が続いてきたのGradleによってガイド。:私は問題に直面したとき、私は次のことを試してみました
ラン- ./gradlew cleanIntegrationTest integrationTest
バイパスのIntelliJにそれはまだ0のテストを実行しました
-追加のアイデアのGradleプラグインを。
-追加dependsOn
からこの。
-からソリューションこれ。
どのように私は、ソースセット「intTest」内部テストを発見するためのGradleを有効にすることができますか?
あなたのテストは、JUnitのテスト5ですが、Gradleのに語っていません。ただ、テスト・タスクのようにあなたを呼び出す必要があります
useJUnitPlatform()
あなたの構成でintegrationTest
作業。