1

In one of my integration tests, I need to get a list of all the controllers

In a gsp I can use:

${grailsApplication.controllerClasses.sort { it.fullName }

But I cannot use this method inside an integration test.

I am using Grails 1.3.7

tim_yates
  • 167,322
  • 27
  • 342
  • 338
A B
  • 1,926
  • 1
  • 20
  • 42

1 Answers1

2

You can also use the grailsApplication to get to all Domain classes or Controller classes (as well as probably other artifact types I'm unaware of).

Class IntegrationTests {

    def grailsApplication

    @Test
    void something() {
        def controllers = grailsApplication.getArtefacts("Controller")
    }
}

http://grails.org/doc/1.3.7/api/org/codehaus/groovy/grails/commons/GrailsApplication.html#getArtefacts(java.lang.String)

Jarred Olson
  • 3,075
  • 1
  • 19
  • 34