Quantcast

Where should I put my test helpers files to be shared among unit and integration tests?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Where should I put my test helpers files to be shared among unit and integration tests?

rosenfeld
I'd like to be able to have some class, say DomainFactory, that would
create domain instances. And I'd like to use this factory both in unit
and integration tests, but I don't want them to be included in the WAR.

Is there a recommended way of doing that on Grails or do I have to
exclude those files manually from WAR through grails.war.resources.

Also, I didn't find any references in the documentation about the
"delete" method in the DSL inside "fileset". Where is the complete
reference to this DSL?

Thanks in advance,
Rodrigo.

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

Teddy.P
Hello Rodrigo,
When you create a war, all the classes in test folder are ignored so, you can put your factory in this folder.

Teddy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

rosenfeld
Em 01-02-2012 10:31, Teddy.P escreveu:
> Hello Rodrigo,
> When you create a war, all the classes in test folder are ignored so, you
> can put your factory in this folder.

What folder, specifically? Remember I want to use the class helper for
both unit and integration tests.

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

Graeme Rocher
Administrator
On Wed, Feb 1, 2012 at 6:16 PM, Rodrigo Rosenfeld Rosas
<[hidden email]> wrote:
> Em 01-02-2012 10:31, Teddy.P escreveu:
>
>> Hello Rodrigo,
>> When you create a war, all the classes in test folder are ignored so, you
>> can put your factory in this folder.
>
>
> What folder, specifically? Remember I want to use the class helper for both
> unit and integration tests.

Currently there isn't a shared helper directory other than src/groovy

It is one of the things on the TODO list

Cheers

>
>
> ---------------------------------------------------------------------
> 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
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

Graeme Rocher
Administrator
On Thu, Feb 2, 2012 at 9:28 AM, Graeme Rocher <[hidden email]> wrote:

> On Wed, Feb 1, 2012 at 6:16 PM, Rodrigo Rosenfeld Rosas
> <[hidden email]> wrote:
>> Em 01-02-2012 10:31, Teddy.P escreveu:
>>
>>> Hello Rodrigo,
>>> When you create a war, all the classes in test folder are ignored so, you
>>> can put your factory in this folder.
>>
>>
>> What folder, specifically? Remember I want to use the class helper for both
>> unit and integration tests.
>
> Currently there isn't a shared helper directory other than src/groovy
>
> It is one of the things on the TODO list

As a workaround you can add in scripts/_Events.groovy:

eventCompileStart = {
  projectCompiler.srcDirectories << "$basedir/test/common"
}
eventAllTestsStart = {
   classLoader.addURL(new File("$basedir/test/common").toURL())
}


Cheers

>
> Cheers
>
>>
>>
>> ---------------------------------------------------------------------
>> 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



--
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
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

rosenfeld
In reply to this post by rosenfeld
Em 01-02-2012 15:16, Rodrigo Rosenfeld Rosas escreveu:
> Em 01-02-2012 10:31, Teddy.P escreveu:
>> Hello Rodrigo,
>> When you create a war, all the classes in test folder are ignored so,
>> you
>> can put your factory in this folder.
>
> What folder, specifically? Remember I want to use the class helper for
> both unit and integration tests.

As no one could provide a solution for this, I'm gonna use an unportable
hack:

tree test

- test
  - helpers
    TestUtil.groovy
  - unit
   - myapp
     - MyTests.groovy
     - helpers (symlink to ../helpers)
  - integration
   - myapp
     - MyTests.groovy
     - helpers (symlink to ../helpers)

then, in my tests I've included "import helpers.*"

This is an easy hack as I don't plan to program in Windows.

Feel free to tell me if you have a better solution (other than using
delete in grails.war.resources DSL).

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

rosenfeld
In reply to this post by Graeme Rocher
Em 02-02-2012 08:37, Graeme Rocher escreveu:

> On Thu, Feb 2, 2012 at 9:28 AM, Graeme Rocher<[hidden email]>  wrote:
>> On Wed, Feb 1, 2012 at 6:16 PM, Rodrigo Rosenfeld Rosas
>> <[hidden email]>  wrote:
>>> Em 01-02-2012 10:31, Teddy.P escreveu:
>>>
>>>> Hello Rodrigo,
>>>> When you create a war, all the classes in test folder are ignored so, you
>>>> can put your factory in this folder.
>>>
>>> What folder, specifically? Remember I want to use the class helper for both
>>> unit and integration tests.
>> Currently there isn't a shared helper directory other than src/groovy
>>
>> It is one of the things on the TODO list
> As a workaround you can add in scripts/_Events.groovy:
>
> eventCompileStart = {
>    projectCompiler.srcDirectories<<  "$basedir/test/common"
> }
> eventAllTestsStart = {
>     classLoader.addURL(new File("$basedir/test/common").toURL())
> }

Thanks! Sorry about the other message. Hadn't seen this one yet...


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

rosenfeld
Em 02-02-2012 10:43, Rodrigo Rosenfeld Rosas escreveu:

> Em 02-02-2012 08:37, Graeme Rocher escreveu:
>> On Thu, Feb 2, 2012 at 9:28 AM, Graeme Rocher<[hidden email]>  
>> wrote:
>>> On Wed, Feb 1, 2012 at 6:16 PM, Rodrigo Rosenfeld Rosas
>>> <[hidden email]>  wrote:
>>>> Em 01-02-2012 10:31, Teddy.P escreveu:
>>>>
>>>>> Hello Rodrigo,
>>>>> When you create a war, all the classes in test folder are ignored
>>>>> so, you
>>>>> can put your factory in this folder.
>>>>
>>>> What folder, specifically? Remember I want to use the class helper
>>>> for both
>>>> unit and integration tests.
>>> Currently there isn't a shared helper directory other than src/groovy
>>>
>>> It is one of the things on the TODO list
>> As a workaround you can add in scripts/_Events.groovy:
>>
>> eventCompileStart = {
>>    projectCompiler.srcDirectories<<  "$basedir/test/common"
>> }
>> eventAllTestsStart = {
>>     classLoader.addURL(new File("$basedir/test/common").toURL())
>> }
>
> Thanks! Sorry about the other message. Hadn't seen this one yet...
>

Auto-reloading doesn't work anymore if I add the _Events.groovy to
scripts. Any idea why?


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Where should I put my test helpers files to be shared among unit and integration tests?

kennethkalmer
For future readers that discover this thread, there is a solution posted in the Grails issue tracker - https://jira.grails.org/browse/GRAILS-8776

Long story short, change the first event from eventCompileStart to eventTestCompileStart.

Kind regards
Loading...