How do I set Java options in SBT for the test configuration only?

broadmonkey

I currently have a command line sbt -Dsome.configuration.option test doing what I want, but I would like it to apply that configuration option automatically for sbt test (and no other sbt phase). If my terminology is correct, then I want to set a Java Option for the Test Configuration. How do I do this?

Searching on these terms has led me to http://www.scala-sbt.org/release/docs/Testing.html but I have not yet been able to understand it.

This question looks similar to mine: Define custom test configurations in sbt

Dale Wijnand

Try this:

testOptions in Test +=
  Tests.Setup(() => sys.props += "some.configuration.option" -> "true")

Caveat:

Because you're not forking this mutates the state of the system property in the JVM running sbt itself.

Which means that after running test the first time it that system property will also be set if you, for instance, run your main from within sbt (run/runMain).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I set the Java options for Kafka?

From Dev

How do you make sbt `test` equivalent to a run command with some set of options?

From Dev

How do you make sbt `test` equivalent to a run command with some set of options?

From Dev

How do I change options in PAM configuration?

From Dev

How do I add additional file to class path which is not java or scala file using SBT configuration?

From Dev

How do I sbt test continually until a flakey test fails?

From Dev

Selenium Java - how do I run only one test?

From Dev

Set default env variable for test configuration in sbt

From Dev

How do I set JVM options for GradleWorkerMain?

From Dev

How do I set available options for a property?

From Dev

How do I set the compiler options?

From Java

How do I restart nginx only after the configuration test was successful on Ubuntu?

From Dev

How do I run JUnit 4.11 test cases with SBT?

From Dev

How do I get `sbt test` to recognize my custom target?

From Dev

How do I run JUnit 4.11 test cases with SBT?

From Dev

How do I set multiple folder in SBT's `javaSource`?

From Dev

How do I set the default system properties for SBT in Windows?

From Dev

X-Frame-Options Header Not Set: How do I set it?

From Dev

How do I determine which configuration options an rpm package is built with?

From Dev

How do I compile Java 8 sources with SBT

From Java

How do I set the value property in AngularJS' ng-options?

From Dev

How do I set indenting options for a language in a VSCode extension?

From Dev

How do I set a prompt on a select using ng-options?

From Dev

How do I set Kraken.js generator options

From Dev

How do I set $LESS invocation options in a lesskey file?

From Dev

How do I set indenting options for a language in a VSCode extension?

From Dev

How do I write a test for a simple configuration class?

From Dev

how do I test a Java SIP client?

From Dev

How do I set up a kiosk that uses java and plays a . jar file only?

Related Related

  1. 1

    How do I set the Java options for Kafka?

  2. 2

    How do you make sbt `test` equivalent to a run command with some set of options?

  3. 3

    How do you make sbt `test` equivalent to a run command with some set of options?

  4. 4

    How do I change options in PAM configuration?

  5. 5

    How do I add additional file to class path which is not java or scala file using SBT configuration?

  6. 6

    How do I sbt test continually until a flakey test fails?

  7. 7

    Selenium Java - how do I run only one test?

  8. 8

    Set default env variable for test configuration in sbt

  9. 9

    How do I set JVM options for GradleWorkerMain?

  10. 10

    How do I set available options for a property?

  11. 11

    How do I set the compiler options?

  12. 12

    How do I restart nginx only after the configuration test was successful on Ubuntu?

  13. 13

    How do I run JUnit 4.11 test cases with SBT?

  14. 14

    How do I get `sbt test` to recognize my custom target?

  15. 15

    How do I run JUnit 4.11 test cases with SBT?

  16. 16

    How do I set multiple folder in SBT's `javaSource`?

  17. 17

    How do I set the default system properties for SBT in Windows?

  18. 18

    X-Frame-Options Header Not Set: How do I set it?

  19. 19

    How do I determine which configuration options an rpm package is built with?

  20. 20

    How do I compile Java 8 sources with SBT

  21. 21

    How do I set the value property in AngularJS' ng-options?

  22. 22

    How do I set indenting options for a language in a VSCode extension?

  23. 23

    How do I set a prompt on a select using ng-options?

  24. 24

    How do I set Kraken.js generator options

  25. 25

    How do I set $LESS invocation options in a lesskey file?

  26. 26

    How do I set indenting options for a language in a VSCode extension?

  27. 27

    How do I write a test for a simple configuration class?

  28. 28

    how do I test a Java SIP client?

  29. 29

    How do I set up a kiosk that uses java and plays a . jar file only?

HotTag

Archive