scala 如何使用 SBT 编译测试而不运行它们
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13847109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to compile tests with SBT without running them
提问by user1809090
Is there a way to build tests with SBT without running them?
有没有办法用 SBT 构建测试而不运行它们?
My own use case is to run static analysis on the test code by using a scalac plugin. Another possible use case is to run some or all of the test code using a separate runner than the one built into SBT.
我自己的用例是使用 scalac 插件对测试代码运行静态分析。另一种可能的用例是使用与 SBT 内置的运行程序不同的运行程序运行部分或全部测试代码。
Ideally there would be a solution to this problem that applies to any SBT project. For example, Maven has a test-compile command that can be used just to compile the tests without running them. It would be great if SBT had the same thing.
理想情况下,应该有一个适用于任何 SBT 项目的解决方案。例如,Maven 有一个 test-compile 命令,可以用来编译测试而不运行它们。如果 SBT 也有同样的东西,那就太好了。
Less ideal, but still very helpful, would be solutions that involve modifying the project's build files.
不太理想但仍然非常有用的是涉及修改项目构建文件的解决方案。
回答by Guillaume Massé
Just use the test:compilecommand.
只需使用test:compile命令。
回答by Brendan Maguire
test:compileworks for compiling your unit tests.
test:compile适用于编译您的单元测试。
To compile integration tests you can use it:compile.
要编译集成测试,您可以使用it:compile.
Another hint to continuously compile on every file change: ~test:compile
在每次文件更改时持续编译的另一个提示: ~test:compile
回答by pacoverflow
We have a build.sbtfile that is used for multiple projects. Doing sbt test:compilecompiled the tests for every single project and took over 30 minutes.
我们有一个build.sbt用于多个项目的文件。Doingsbt test:compile为每个项目编译了测试,耗时超过 30 分钟。
I found out I can compile only the tests for a specific project named xyzby doing:
我发现我只能编译通过以下方式命名的特定项目的测试xyz:
sbt xyz/test:compile

