Here are my thoughts.
class UrlMappingTests extends GrailsUrlMappingTestCase {
def mappings = UrlMappings
/* tests */
}
or
class UrlMappingTests extends GrailsUrlMappingTestCase {
def mappings = [UrlMappings, OtherUrlMappings]
/* tests */
}
and if `mappings` is omitted then all mappings are loaded, considering that I think this would be the most common case.
I am also trying choose between the following...
void testMapping() {
"/module/list"(controller: "module", action: "list")
}
and...
void testMapping() {
assertUrlMapping("/module/list", controller: "module", action: "list")
}
Also trying to decide the best approach to asserting params.
With mappings like...
mappings = {
"/$groovy/$module/ivy.xml"(controller:"module", action: "ivy")
}
We could do...
void testMapping() {
assertUrlMapping("/1.5.4/someModule/ivy.xml", controller: "module", action: "ivy", groovy: "1.5.4", module: "someModule")
}
Or something like...
void testMapping() {
assertUrlMapping("/1.5.4/someModule/ivy.xml", controller: "module", action: "ivy")
{
groovy = "1.5.4"
module = "someModule"
}
}
Or...
void testMapping() {
assertUrlMapping("/1.5.4/someModule/ivy.xml", controller: "module", action: "ivy") {
assertEquals("1.5.4", groovy)
assertEquals("someModule", module)
}
}
I am personally leaning towards...
void testMapping() {
"/1.5.4/someModule/ivy.xml"(controller: "module", action: "ivy") { groovy = "1.5.4" module = "someModule" }
}
Which is the most concise, but probably not the most intuitive.
I have looked through how url mappings work, doesn't seem like it would be too hard to add testing support.
One thing I don't know though is how to get hold of the grailsUrlMappingsHolderBean in a test scenario. Perhaps there should be a 'GrailsIntegrationTest' class that somehow either gets beans injected via spring, or has access to those beans somehow.