我的项目中有3个测试源文件夹。我在build.sbt
(SBT版本:1.2.1)中添加了以下密钥:
sourceDirectories in Test := baseDirectory { base =>
Seq(
base / "src/test/common/scala",
base / "src/test/unit/scala",
base / "src/test/functional/scala"
)
}.value
SBT正确识别了文件夹:
sbt test:sourceDirectories
...
[info] Set current project to service (in build file:/myprojectfolder/)
[info] * /myprojectfolder/src/test/common/scala
[info] * /myprojectfolder/src/test/unit/scala
[info] * /myprojectfolder/src/test/functional/scala
但是test:compile
在target/scala-2.11/test-classes
中不产生任何测试类,结果test
任务没有运行任何测试。
我正在使用ScalaTest 3.0.5,尽管这似乎无关紧要。
有什么想法为什么SBT在编译过程中会忽略测试Scala源?
答案 0 :(得分:0)
manuzhang感谢您提供有用的评论。确实,以下更改可以解决问题:
代替
sourceDirectories in Test := baseDirectory { base =>
Seq(
base / "src/test/common/scala",
base / "src/test/unit/scala",
base / "src/test/functional/scala"
)
}.value
我用过
unmanagedSourceDirectories in Test := baseDirectory { base =>
Seq(
base / "src/test/common/scala",
base / "src/test/unit/scala",
base / "src/test/functional/scala"
)
}.value