Testing bootstrap.groovy

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Testing bootstrap.groovy

kamilofski
I currently have to use 'run-app' to see whether my BootStrap.groovy code is correct.  How can I write a BootStrapTest.groovy to just test the file and make sure everything is working as expected?  In other words, I want to do this but it doesn't find BootStrap.groovy:


import BootStrap  //ERROR: Groovy unable to resolve BootStrap.groovy

import groovy.util.GroovyTestCase;

class BootStrapTest extends GroovyTestCase {


        void testBootStrap() {
                new BootStrap().init(null)
        }
}
Reply | Threaded
Open this post in threaded view
|

Re: Testing bootstrap.groovy

Roshan Dawrani
It is just a quick guess - you are not writing it as a unit test, are you? 

Because if you are, Bootstrap class may not come into picture

-- 
Roshan
Blog: http://roshandawrani.wordpress.com/
Twitter: @roshandawrani
Skype: roshandawrani

On Thu, Jan 20, 2011 at 10:44 AM, kamilofski <[hidden email]> wrote:

I currently have to use 'run-app' to see whether my BootStrap.groovy code is
correct.  How can I write a BootStrapTest.groovy to just test the file and
make sure everything is working as expected?  In other words, I want to do
this but it doesn't find BootStrap.groovy:


import BootStrap  //ERROR: Groovy unable to resolve BootStrap.groovy

import groovy.util.GroovyTestCase;

class BootStrapTest extends GroovyTestCase {


       void testBootStrap() {
               new BootStrap().init(null)
       }
}

--
View this message in context: http://grails.1312388.n4.nabble.com/Testing-bootstrap-groovy-tp3225471p3225471.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Testing bootstrap.groovy

ld@ldaley.com
In reply to this post by kamilofski

On 20/01/2011, at 3:14 PM, kamilofski wrote:

> import BootStrap  //ERROR: Groovy unable to resolve BootStrap.groovy

It's a limitation of Java and Groovy that you cannot use classes from the default package in classes that are not in the default package.

If you move your test to the default package and ditch the import it should work.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Testing bootstrap.groovy

Graeme Rocher
Administrator
In reply to this post by kamilofski
Right your logic in a service, write a test for the service then
inject the service into Bootstrap.

It is a cleaner approach

Cheers

On Thu, Jan 20, 2011 at 6:14 AM, kamilofski <[hidden email]> wrote:

>
> I currently have to use 'run-app' to see whether my BootStrap.groovy code is
> correct.  How can I write a BootStrapTest.groovy to just test the file and
> make sure everything is working as expected?  In other words, I want to do
> this but it doesn't find BootStrap.groovy:
>
>
> import BootStrap  //ERROR: Groovy unable to resolve BootStrap.groovy
>
> import groovy.util.GroovyTestCase;
>
> class BootStrapTest extends GroovyTestCase {
>
>
>        void testBootStrap() {
>                new BootStrap().init(null)
>        }
> }
>
> --
> View this message in context: http://grails.1312388.n4.nabble.com/Testing-bootstrap-groovy-tp3225471p3225471.html
> Sent from the Grails - user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>



--
Graeme Rocher
Grails Project Lead
SpringSource - A Division of VMware
http://www.springsource.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Testing bootstrap.groovy

kamilofski
Thanks for all of the great responses guys, they are close to what I'm looking for; however, they don't seem to catch my syntax errors inside BootStrap.groovy.  In addition I couldn't import BootStrap from my service class.

The reason I am trying to do this is because there are times where my syntax is incorrect inside BootStrap.groovy and i have to do a 'run-app' (which takes quite a bit of time) to show me that there are errors.

I would prefer to have a test that just runs BootStrap.groovy code and makes sure that everything is being inserted as expected.  What would be the best way to do this?
Reply | Threaded
Open this post in threaded view
|

Re: Testing bootstrap.groovy

ld@ldaley.com

On 21/01/2011, at 2:30 PM, kamilofski wrote:

> Thanks for all of the great responses guys, they are close to what I'm
> looking for; however, they don't seem to catch my syntax errors inside
> BootStrap.groovy.  In addition I couldn't import BootStrap from my service
> class.
>
> The reason I am trying to do this is because there are times where my syntax
> is incorrect inside BootStrap.groovy and i have to do a 'run-app' (which
> takes quite a bit of time) to show me that there are errors.
>
> I would prefer to have a test that just runs BootStrap.groovy code and makes
> sure that everything is being inserted as expected.  What would be the best
> way to do this?

BootStraps should be run when the application starts up for integration testing.

If your integration phase passes then your bootstraps are ok.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email