2

プロジェクトで機能テスト用のソース セットをセットアップしました。junit テスト レポートの生成を除いて、すべてが期待どおりに機能しています。欠落している構成ビットがわかりません。ここに私が持っているものがあります:

sourceSets {
    // Note that just declaring this sourceset creates two configurations.
    funcTest {
        scala {
            srcDir 'src/funcTest/scala'
            compileClasspath += main.output
            runtimeClasspath += main.output
        }
    }
}

configurations {
    funcTestCompile.extendsFrom testCompile
    funcTestRuntime.extendsFrom testRuntime
}

task funcTest(type:Test){
    description = "Run integration tests (located in src/funcTest/...)."
    testClassesDir = project.sourceSets.funcTest.output.classesDir
    testSrcDirs = project.sourceSets.funcTest.scala.source
    classpath = project.sourceSets.funcTest.runtimeClasspath
    dependsOn test
}

上記は私のテストをビルドして実行します。ただし、レポートのディレクトリ構造は次のようになります。

./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/base-style.css
./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/css3-pie-1.0beta3.htc
./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/MongoConfigTest.html
./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/MongoConfigTest.scala.html
./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/report.js
./build/reports/tests/No source file found at src/test/scala/com/hp/snapfish/ecommerce/taxservice/mongo/style.css

私は何が欠けていますか?なぜそれを作成しているのですか

src にソース ファイルが見つかりません

ディレクトリ?scala ファイルを探す必要があることを知る必要があると思いますが、それを伝える方法がわかりません。明らかな何かが欠けているに違いありません。

4

3 に答える 3

2

「src にソース ファイルが見つかりません」の原因がわかりませんが、testResultsDir(XML) とtestReportDir(HTML) を設定してみてください。とにかくこれらを設定する必要があります。そうしないと、testタスクによって生成されたファイルが上書きされます。

reports.junitXml.destination = "$buildDir/test-results/TaskName"  
reports.html.destination = "$buildDir/test-results/TaskName"
于 2012-11-22T04:04:20.963 に答える
2

build.gradle ファイルで次のようなことを試してください。

test {
    testLogging {
        // log results to "build/test-results" directory
        exceptionFormat "full"
        events "started", "passed", "skipped", "failed", "standardOut", "standardError"
    }
}

次に、 project-root/build/test-results のような場所に出力が見つかるはずです。「メイン」ソーストランクでこれを行う方法がわかりませんが、これは「テスト」トランクで機能します。単体テストがある場合は、これを試して、より良いアイデアを得ることができます。

于 2012-11-19T23:05:08.920 に答える
0

問題は scala 仕様にありました ( https://groups.google.com/forum/?fromgroups=#!topic/specs2-users/zxOWrMEL8rYを参照)。これはグラドルの問題ではありません。specs2 についてもっと調査する必要があります。提案をありがとう。

于 2012-11-28T17:07:20.353 に答える