使用 SBT 编译测试并将它们打包以便稍后运行

编程入门 行业动态 更新时间:2024-10-28 00:19:59
本文介绍了使用 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

来源:github/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

来源:www.scala-sbt/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

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

更多推荐

使用 SBT 编译测试并将它们打包以便稍后运行

本文发布于:2023-07-14 22:19:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:并将   稍后   测试   SBT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!