grails - Use GORM inside spock functional test to insert data in db -


I would like to use GORM to set up test data in functional tests written with spock since I do not want to fake the behavior , So I got an exception

  java.lang.IllegalStateException: The method was used outside of the Grails application on the [com.test.Person] class. If the use of the Malling API or BootStrap Grails is being correctly implemented in the context of a test  

Is there any way to use the Goram in this way? I have seen the remote control plugin, but I do not want to use it and AFAIK should be in the same JVM because I start testing without the - war switch.

<2.3 Share execution is enabled by default (which includes run-ap, test-app, run-war, console). You will have to take a look at your BuildConfig.groovy (see for more information), if Falb execution is enabled. You have to disable it, but you will also lose some of its other positive aspects. You have only the right option, so use it with some construction (Example from remote-control plugin:

  def remote = new remote control (def define) (def {} = Remote {Deaf person = new person (name: "m") person.save () person.id} // Some request some HTTP requests and check that person in DB Remote (id) .delete () }}  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -