A B
A B

Reputation: 1936

List all Controllers in an Integration test?

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

Upvotes: 1

Views: 474

Answers (1)

Jarred Olson
Jarred Olson

Reputation: 3243

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)

Upvotes: 2

Related Questions