Last active
December 20, 2017 22:23
-
-
Save dos65/1988eb306125625d866ced014401accf to your computer and use it in GitHub Desktop.
sbt - fork in Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" | |
// doesn't work | |
fork in (Test, test) := true | |
javaOptions in (Test, test) ++= Seq("-Dkey=value") | |
// works | |
fork in Test := true | |
javaOptions in Test ++= Seq("-Dkey=value") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] Loading project definition from /home/dos65/projects/try_smth/sbt_1.1.0_RC2/project | |
[info] Updating ProjectRef(uri("file:/home/dos65/projects/try_smth/sbt_1.1.0_RC2/project/"), "sbt_1-1-0_rc2-build")... | |
[info] Done updating. | |
[info] Loading settings from build.sbt ... | |
[info] Set current project to sbt_1-1-0_rc2 (in build file:/home/dos65/projects/try_smth/sbt_1.1.0_RC2/) | |
[info] Updating ... | |
[info] Done updating. | |
[info] Compiling 1 Scala source to /home/dos65/projects/try_smth/sbt_1.1.0_RC2/target/scala-2.12/classes ... | |
[info] Done compiling. | |
[info] Compiling 2 Scala sources to /home/dos65/projects/try_smth/sbt_1.1.0_RC2/target/scala-2.12/test-classes ... | |
[info] Done compiling. | |
[info] TestSpec: | |
[info] TestSpec *** ABORTED *** | |
[info] java.lang.RuntimeException: non forked | |
[info] at scala.sys.package$.error(package.scala:27) | |
[info] at TestSpec.<init>(Test.scala:7) | |
[info] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) | |
[info] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) | |
[info] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) | |
[info] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) | |
[info] at java.lang.Class.newInstance(Class.java:442) | |
[info] at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:435) | |
[info] at sbt.ForkMain$Run$2.call(ForkMain.java:300) | |
[info] at sbt.ForkMain$Run$2.call(ForkMain.java:290) | |
[info] ... | |
[info] Run completed in 2 seconds, 944 milliseconds. | |
[info] Total number of tests run: 0 | |
[info] Suites: completed 0, aborted 1 | |
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0 | |
[info] *** 1 SUITE ABORTED *** | |
[error] Error during tests: | |
[error] TestSpec | |
[error] (Test / test) sbt.TestsFailedException: Tests unsuccessful | |
[error] Total time: 13 s, completed Dec 21, 2017 1:20:32 AM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest._ | |
class TestSpec extends FunSpec { | |
sys.props.get("key") match { | |
case Some(k) => println(s"ok: $k") | |
case None => sys.error("non forked") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment