title: grails unit testing with multiple datasource
body: <p>I am trying to write unit test case for grails controller which has following structure:</p>
  
  <pre><code>class MyController{
  
      def save(){
           def myDomain = new MyDomain(params)
           business validation 1
           business validation 2
           myDomain.writedatasource.save()
           business validation 3
           business validation 4
      }
  }
  </code></pre>
  
  <p>Since Unit test doesn't load Datasource.groovy the <em>writedatasource</em> isn't available during unit testing so the test cases for "business validation 3" and "business validation 4" fail as I get </p>
  
  <p>groovy.lang.MissingPropertyException: No such property: writedatasource for class: MyDomain</p>
  
  <p>How can I modify my test case to test validation scenarios 3 and 4?</p>
  
  <p>Test case is simple and looks like follows:</p>
  
  <pre><code>void testSave(){
      ...setup...
      controller.save()
      assert conditions
      ....
  
  }
  </code></pre>