Quantcast

modifying the testing templates

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

modifying the testing templates

eeno

Where can I find a reference documenting the various means of
modifying the grails templates?

For instance, I'm seeing stuff like "@artifact.package@" and
"${className}", etc. in the files under src/templates/ -  I'd
like to see what other variables are accessible from these
templates.



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

Re: modifying the testing templates

eeno
On Friday, May 18, 2012 03:28:15 PM eeno wrote:

>
> Where can I find a reference documenting the various means of
> modifying the grails templates?
>
> For instance, I'm seeing stuff like "@artifact.package@" and
> "${className}", etc. in the files under src/templates/ -  I'd
> like to see what other variables are accessible from these
> templates.
>
>


For instance...  What if I wanted to modify the testing/UnitTest.groovy
template to something like this:

@artifact.package@
import grails.test.mixin.*
import grails.test.mixin.support.*
import org.junit.*
import static org.junit.Assert.*


@TestMixin(GrailsUnitTestMixin)
class @artifact.name@ {

   void testMyClass() {

      fail "Implement MyClass!"
   }
}

... I want to replace the literal string 'MyClass', with the name
of the actual class under test, so that it looked more like this:


class mypackage.FooBar

import grails.test.mixin.*
import grails.test.mixin.support.*
import org.junit.*
import static org.junit.Assert.*


@TestMixin(GrailsUnitTestMixin)
class FooBar {

   void testFooBar() {

      fail "Implement FooBar!"
   }
}



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

Re: modifying the testing templates

eeno
On Monday, May 21, 2012 11:23:38 AM eeno wrote:

> On Friday, May 18, 2012 03:28:15 PM eeno wrote:
> >
> > Where can I find a reference documenting the various means of
> > modifying the grails templates?
> >
> > For instance, I'm seeing stuff like "@artifact.package@" and
> > "${className}", etc. in the files under src/templates/ -  I'd
> > like to see what other variables are accessible from these
> > templates.
> >
> >
>
>
> For instance...  What if I wanted to modify the testing/UnitTest.groovy
> template to something like this:
>
> @artifact.package@
> import grails.test.mixin.*
> import grails.test.mixin.support.*
> import org.junit.*
> import static org.junit.Assert.*
>
>
> @TestMixin(GrailsUnitTestMixin)
> class @artifact.name@ {
>
>    void testMyClass() {
>
>       fail "Implement MyClass!"
>    }
> }
>
> ... I want to replace the literal string 'MyClass', with the name
> of the actual class under test, so that it looked more like this:
>
>
> class mypackage.FooBar
>
> import grails.test.mixin.*
> import grails.test.mixin.support.*
> import org.junit.*
> import static org.junit.Assert.*
>
>
> @TestMixin(GrailsUnitTestMixin)
> class FooBar {
>
>    void testFooBar() {
>
>       fail "Implement FooBar!"
>    }
> }
>

I just want to know where I can find what all variables are available
from within artifact and scaffolding templates.

Any clue would be welcome, and appreciated - I'm sorry if I've missed
anything obvious in the docs.


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

Re: modifying the testing templates

eeno
On Wednesday, May 23, 2012 08:25:33 AM eeno wrote:
> On Monday, May 21, 2012 11:23:38 AM eeno wrote:
> > On Friday, May 18, 2012 03:28:15 PM eeno wrote:
> I just want to know where I can find what all variables are available
> from within artifact and scaffolding templates.
>
> Any clue would be welcome, and appreciated - I'm sorry if I've missed
> anything obvious in the docs.
>


Totally Warnocked.

https://en.wikipedia.org/wiki/Warnock%27s_Dilemma



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

Re: modifying the testing templates

Ian Roberts
In reply to this post by eeno
On 18/05/2012 23:28, eeno wrote:
>
> Where can I find a reference documenting the various means of
> modifying the grails templates?
>
> For instance, I'm seeing stuff like "@artifact.package@" and
> "${className}", etc. in the files under src/templates/ -  I'd
> like to see what other variables are accessible from these
> templates.

I'm not sure there is documentation as such, like so many things in
Grails the only definitive answer is in the source code.  These
particular cases appear to be hard-coded in
scripts/_GrailsCreateArtifacts.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

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

Re: modifying the testing templates

eeno
On Friday, May 25, 2012 04:55:57 PM Ian Roberts wrote:

> On 18/05/2012 23:28, eeno wrote:
> >
> > Where can I find a reference documenting the various means of
> > modifying the grails templates?
> >
> > For instance, I'm seeing stuff like "@artifact.package@" and
> > "${className}", etc. in the files under src/templates/ -  I'd
> > like to see what other variables are accessible from these
> > templates.
>
> I'm not sure there is documentation as such, like so many things in
> Grails the only definitive answer is in the source code.  These
> particular cases appear to be hard-coded in
> scripts/_GrailsCreateArtifacts.groovy.
>

Excellent, many thanks!   You are a gentleman, and a scholar!  (c8=

... and indeed I was able to confirm that there are just 4 different
variables available which can all be found with within the
...templates//testing/* files anyhow:

@artifact.name@
@artifact.package@
@artifact.superclass@
@artifact.testclass@

( alas I was hoping to have easy access to the name of the class under
test without the 'Tests' suffix )


Cheers


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

Re: modifying the testing templates

Ian Roberts
On 25/05/2012 17:09, eeno wrote:
> ( alas I was hoping to have easy access to the name of the class under
> test without the 'Tests' suffix )

The events mechanism may come to your rescue here, as createArtifact
fires an event that provides that class name as a parameter, so it looks
like you could define in your _Events.groovy:

eventCreatedArtefact = { file, className ->
  ant.replace(file:file, token:'@artifact.classUnderTest@', value:className)
}

(yes, it is eventCreatedArtefact, the script doesn't agree with itself
as to whether it should be "ifact" or "efact" and uses both in different
contexts...)

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK

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

Re: modifying the testing templates

eeno
On Friday, May 25, 2012 05:26:50 PM Ian Roberts wrote:

> On 25/05/2012 17:09, eeno wrote:
> > ( alas I was hoping to have easy access to the name of the class under
> > test without the 'Tests' suffix )
>
> The events mechanism may come to your rescue here, as createArtifact
> fires an event that provides that class name as a parameter, so it looks
> like you could define in your _Events.groovy:
>
> eventCreatedArtefact = { file, className ->
>   ant.replace(file:file, token:'@artifact.classUnderTest@', value:className)
> }
>

Killer - works like a champ...


> (yes, it is eventCreatedArtefact, the script doesn't agree with itself
> as to whether it should be "ifact" or "efact" and uses both in different
> contexts...)
>

Fun!   <grin>


Thanks again for the assist - much appreciated!


Beers



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

    http://xircles.codehaus.org/manage_email


Loading...