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

查看:490
本文介绍了使用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.

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

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

推荐答案

sbt不要在工件中发布测试

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/人工制品

运行测试

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天全站免登陆