Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play 2.0 - access running (Fake)Application from scala console

I'm just getting started with the Play Framework 2.0 (using current trunk 2.1-SNAPSHOT, Scala) and I'm finding it very useful to experiment with the Scala API in the play console.

For some things, however, for example stuff that depends on play.libs.WS API, I'm getting the There is no started application error. Fair enough, but I can't figure out how to set up a fake one up to use from the console, or whether this is even possible.

It seems that play.api.test._ isn't even accessible from the console. Any suggestions?

Update: Thanks to @charroch, I needed to run play test:console, so I can now do:

import play.api.test.Helpers.running
import play.api.test.FakeApplication

val res = running(FakeApplication()) { 
    MyWebservice.someFunction()  
}
like image 535
Mikesname Avatar asked Jun 25 '12 17:06

Mikesname


1 Answers

try test:console to start the console with test api in classpath

You need to have running(FakeApplication) {...} in your test as per: http://www.playframework.org/documentation/2.0/ScalaTest

like image 75
charroch Avatar answered Nov 04 '22 13:11

charroch