Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
setting system properties for tests
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Alexy Khrabrov  
View profile  
 More options Sep 21 2012, 6:50 pm
From: Alexy Khrabrov <al...@scalable.pro>
Date: Fri, 21 Sep 2012 15:50:57 -0700 (PDT)
Local: Fri, Sep 21 2012 6:50 pm
Subject: setting system properties for tests

I'm using ScalaTest 2.0.0.M4 to test a Play app, both from IDEA and SBT.
 Play 2.0 uses a system property which you can define on the command line
with -Dconfig.file=conf/test.conf to override the default
conf/application.conf.  I find it important to always use a test.conf so
that only test databases will be used.  In IDEA I simply provide -Dk=v in
the VM options.  In SBT, however, the property will be set in the current
JVM, so I have to set it initially and then set and restore it around
tests, like this:

    initialize ~= { _ =>
      System.setProperty("config.file", "conf/dev.conf")
    },
    testOptions in Test ++= Seq( Tests.Setup{ () =>
System.setProperty("config.file", "conf/test.conf") }, Tests.Cleanup{ () =>
System.setProperty("config.file", "conf/dev.conf")})

(I'd need to set yet another configuration file for the dist task, and
ensure it is set around dist...)  When researching setting properties in
SBT, I've found the recommendation to use the test frameworks' own options.
 Config maps looked exactly like that, but they seem not to affect the
system properties.  E.g., this didn't seem to work:

    testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest,
"-Dconfig.file=conf/test.conf")

What are the config maps used for, and what's the recommended way to set
the system properties in SBT?  Can they be specified as a part of the tests
themselves in a general way, e.g. via importing a setting?

A+


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Venners  
View profile  
 More options Sep 22 2012, 4:27 am
From: Bill Venners <b...@artima.com>
Date: Sat, 22 Sep 2012 16:27:10 +0800
Local: Sat, Sep 22 2012 4:27 am
Subject: Re: [scalatest-users] setting system properties for tests
Hi Alexy,

ScalaTest's config map is independent from system properties. I'm not
sure if there's a better way to do what you are doing with sbt. That's
probably better asked on the sbt mailing list than here. But you could
also possibly do this inside your tests themselves.

I'm not sure what other setup is going on in your tests, but if you
can change that system property for each test, you could create a
trait with a withFixture(NoArgTest) that sets the system property
before each test and resets it after. You could mix that trait into
each test class.

Bill

--
Bill Venners
Artima, Inc.
http://www.artima.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »