有没有一种不运行 SBT 就可以构建测试的方法?
我自己的用例是使用 scalac 插件对测试代码运行静态分析。另一个可能的用例是使用一个单独的运行器来运行部分或全部测试代码,而不是使用内置在 SBT 中的运行器。
理想情况下,这个问题的解决方案适用于任何 SBT 项目。例如,Maven 有一个测试编译命令,可以只用来编译测试而不运行它们。如果 SBT 有同样的东西就好了。
不太理想但仍然非常有用的解决方案是涉及修改项目构建文件的解决方案。
Just use the Test / compile command.
Test / compile
Test/compile works for compiling your unit tests.
Test/compile
To compile integration tests you can use IntegrationTest/compile.
IntegrationTest/compile
Another hint to continuously compile on every file change: ~Test/compile
~Test/compile
We have a build.sbt file that is used for multiple projects. Doing sbt test:compile compiled the tests for every single project and took over 30 minutes.
build.sbt
sbt test:compile
I found out I can compile only the tests for a specific project named xyz by doing:
xyz
sbt xyz/test:compile
Using sbt version 1.5.0 and higher test:compile returns deprecation warning.
test:compile
Use Test / compile.
(docs)