title: testing grails data binding
body: <p>I've written the following Grails controller</p>
  
  <pre><code>class CategoryController {
  
      def create = {
          def newCategory = new CategoryCommand()
          bindData(newCategory, params)
          [newCategory: newCategory]
      }
  }
  
  class CategoryCommand {
  
      String name
      String seoName
  }
  </code></pre>
  
  <p>I've written this unit test to test the data binding:</p>
  
  <pre><code>class CategoryControllerTests extends ControllerUnitTestCase {
  
  
      void testCreate() {
  
          // A new ControllerCommand should be returned if invoked with no params
          assertNotNull controller.create()
  
          // If called with params, they should be bound
          mockParams.name = 'snooker'
          mockParams.seoName = 'snooker-loopy'
          def model = controller.create()
  
          CategoryCommand newCategory = model.newCategory
          assertEquals 'snooker', newCategory.name
          assertEquals 'snooker-loopy', newCategory.seoName
  
      }
  }
  </code></pre>
  
  <p>But I get this exception when <code>controller.create()</code> is invoked:</p>
  
  <blockquote>
    <p>No signature of method: com.example.CategoryController.bindData() is applicable for argument types: (com.example.CategoryCommand, org.codehaus.groovy.grails.web.taglib.GroovyPageAttributes) values: [com.example.CategoryCommand@7860e7d2, [:]] </p>
  </blockquote>
  
  <p>I tried running this as an integration test instead, but the result is the same.</p>