Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
631 views
in Technique[技术] by (71.8m points)

scala - Compile tests with SBT and package them to be run later

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...