[SBT] Custom test configuration

186 views
Skip to first unread message

Jakub Liska

unread,
Nov 17, 2014, 7:58:19 PM11/17/14
to scal...@googlegroups.com
Hey, 

I'm trying to run tests in different setups, for example :

  lazy val AsyncTest = config("async") extend(Test)
  jsEnv
in (AsyncTest, fastOptStage) := new PhantomJSEnv(autoExit = false)
  postLinkJSEnv
in (AsyncTest, fastOptStage) := new PhantomJSEnv(autoExit = false)


  lazy val js
=
    project
.in(file("js"))
     
.configs(AsyncTest).settings(inConfig(AsyncTest)(scalaJSSettings) : _*)
     
.settings(scalaJSSettings:_*)
     
.settings(utestJsSettings:_*)
     
.settings(
        testOptions
in AsyncTest := Seq(Tests.Filter(s => s.contains("Async"))),
        test in AsyncTest := (test in (AsyncTest, fastOptStage)).value,
       )




>async:test doesn't respect testOptions filter nor jsEnv setting...

I'm playing with it for almost an hour, but as I'm quite new to SBT, I don't think I have a chance to put it together. Also as I started to use scala-js 0.6.0-SNAPSHOT, Intellij idea doesn't have scala-js plugin declared in project/build.sbt on classpath ... so I don't have an IDE support in Build.scala

Sébastien Doeraene

unread,
Nov 17, 2014, 8:25:41 PM11/17/14
to Jakub Liska, scal...@googlegroups.com
Hi,

You should not need to set postLinkJSEnv in fastOptStage, and you should not need to set jsEnv at all. Just use this:
postLinkJSEnv in AsyncTest := new PhantomJSEnv(autoExit = false)

That should work, I think, although I don't really know how config extensions work in sbt. So maybe we just don't play nice enough with them.

Cheers,
Sébastien

--
You received this message because you are subscribed to the Google Groups "Scala.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-js+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-js/c8863e87-2c7c-4f1c-830f-ee44e3f084ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jakub Liska

unread,
Nov 18, 2014, 4:45:04 AM11/18/14
to scal...@googlegroups.com, liska...@gmail.com, haoy...@gmail.com
I think that the main problem might be the fact that we actually run test in fastOptStage and the custom configuration that extends from Test doesn't apply to this scope.

I was actually trying to set this up 2 weeks ago. That's why I wanted to integrate this into utest, which showed up to be even more difficult task.

Btw the problem with intellij idea was caused by using sbt 0.13.5... People do not use it, prefer 0.13.1, unless you wanna get stuck with broken Build.scala and plugins.sbt for good.


Jakub Liska

unread,
Nov 18, 2014, 7:23:44 AM11/18/14
to scal...@googlegroups.com, haoy...@gmail.com
I call it an async dead end number 2 in a row, another time to figure a roundabout way... If anybody more sbt-skilled ever manages to setup multiple test configurations with utest, please let us know...

Jakub Liska

unread,
Nov 18, 2014, 10:36:17 AM11/18/14
to scal...@googlegroups.com
A few hints for those who want to test asynchronous stuff (how I ended up doing that) : 

1) Use utest programmatically instead of relying on the sbt test integration - it is really much more flexible and it lets you do whatever you want. I personally will use utest for testing everything this way only.
2) If you have some async tests, use  PhantomJSEnv(autoExit = false) for all tests, even those synchronous. Just call System.exit(0) after you interpret the results. It just works and it is easily maintainable.

I went almost crazy trying to do the opposite. Don't do that, really :-) It might seem to be a code smell to even test asynchronous stuff, but I just sometimes don't know what to expect from the javascript/browser environment, it just often behaves really weird and I don't have time to manually play with it in browser, it is much better to prototype it in a test suite first instead of playing with it in browser.
Reply all
Reply to author
Forward
0 new messages