title: Grails Integration Test Filter
body: <p>Is there a way to test a controller which uses a filter on an integration test?</p>
  
  <p>There seems to be a way using the @Mock annotation for Unit Tests and than wrapping the controller call on a withFilter closure.</p>
  
  <p>But I can't get to test filters on an integration test which from my pov should be very straight forward.</p>
  
  <p>Update</p>
  
  <p>So here is the solution I found. Instead of using the @Mock annotation, I instantiated the FiltersUnitTestMixin class and populated it with the necessary values.  </p>
  
  <pre><code>public class ControllerTest {  
  
      def controller = new Controller()  
          FiltersUnitTestMixin f = new FiltersUnitTestMixin()
  
      @Before
      public void setup() {
          f.grailsApplication = grailsApplication
          f.applicationContext = grailsApplication.mainContext
          f.mockFilters(ControllerFilters)
      }
  
      @Test
      public void shouldPassTheTest() {
          f.withFilters(action:"actionName") {
              controller.actionName()
          }
      }
  }
  </code></pre>