This blogpost titled “Test forward method of Controller” explains the technique that can be used to test forward method of controller. Recently, I was writing test cases in grails to test an action :

I wrote the following test case:

When I ran the test case it failed. The value of ‘forwardedUrl’ was ‘/grails/controllerName/actionName.dispatch’.

So in order to test it I had two ways:

  1. Parse the forwardedURL using regex(Regular Expression)

2. Using metaclass to override the behavior of controller’s forward method:

Jira Issue related to this problem : JIRA ISSUE

That was all.
Hope it helped ­čÖé