我已在我的项目中为功能测试设置了一个源集。除了生成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文件,但我不知道如何告诉它。我一定错过了一些明显的东西。
答案 0 :(得分: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。我不知道如何在“主”源干线上执行此操作,但这适用于“测试”干线。如果你有单元测试,你可以尝试这个,也许会有更好的想法。
答案 1 :(得分:2)
我无法分辨“在src找不到源文件”的来源,但尝试设置testResultsDir
(XML)和testReportDir
(HTML)。您无论如何都必须设置它们,否则您将覆盖test
任务生成的文件。
reports.junitXml.destination = "$buildDir/test-results/TaskName"
reports.html.destination = "$buildDir/test-results/TaskName"
答案 2 :(得分:0)
问题在于scala规范(参见https://groups.google.com/forum/?fromgroups=#!topic/specs2-users/zxOWrMEL8rY)。这不是一个问题。我需要对specs2做更多的调查。感谢您的建议。