使用 SBT 编译测试并将它们打包以便稍后运行 [英] Compile tests with SBT and package them to be run later

查看:37
本文介绍了使用 SBT 编译测试并将它们打包以便稍后运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SBT 和 Play!框架.目前,我们的管道中有一个提交阶段,我们发布到工件我们的二进制文件.二进制文件是使用 dist 任务生成的.然后管道运行用 scala 编写的冒烟和验收测试.它们使用 sbt 运行.

Im working with SBT and Play! Framework. Currently we have a commit stage in our pipeline where we publish to artifactory our binaries. The binaries are generated with the dist task. The pipeline then runs smoke and acceptance tests that are written in scala. They are run with sbt.

我想做的是编译冒烟测试和验收测试以及二进制文件并将它们发布到工件.这将允许管道下载这些二进制文件(测试套件)并运行它们,而不是每次都重新编译它们,这需要很长时间.

What I want to do is to compile the smoke and acceptance tests as well as the binary and publish them to artifactory. That will allow the pipeline to download these binaries (the test suites) and run them, instead of recompiling them every time, which takes a long time.

我尝试了生成 jar 的 sbt test:compile,但是我找不到运行测试的方法.

I tried sbt test:compile which generates the jar, but then I cant find a way to run the tests.

推荐答案

sbt dont publish test in artifacts

sbt dont publish test in artifacts

publishArtifact in GlobalScope in Test:== false

来源:https://github.com/sbt/sbt/blob/a7413f6415687f32e6365598680f3bb8545c46b5/main/src/main/scala/sbt/Defaults.scala#L1118

这是如何启用它

// enable publishing the jar produced by `test:package`
publishArtifact in (Test, packageBin) := true

// enable publishing the test API jar
publishArtifact in (Test, packageDoc) := true

// enable publishing the test sources jar
publishArtifact in (Test, packageSrc) := true

来源:http://www.scala-sbt.org/release/docs/Detailed-Topics/Artifacts

运行测试

scala -classpath pipeline.jar classpath scalatest-<version>.jar org.scalatest.tools.Runner -p compiled_tests

其中 pipeline.jar 是您从管道收到的测试工件

where pipeline.jar is the test artifact you receive from the pipeline

或者你可以通过 sbt 设置一个测试项目

or you can setup a test projet via sbt

http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing.html

这篇关于使用 SBT 编译测试并将它们打包以便稍后运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆