Compile tests with SBT and package them to be run later

淺唱寂寞╮ 提交于 2019-11-27 03:29:49

问题


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.

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


回答1:


sbt dont publish test in artifacts

publishArtifact in GlobalScope in Test:== false

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

this is how to enable it

// 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

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

run the test

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

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

or you can setup a test projet via sbt

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



来源:https://stackoverflow.com/questions/16389446/compile-tests-with-sbt-and-package-them-to-be-run-later

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!