title: Grails 2.1.1 - Unit testing and Mocking the elements of domain class
body: <p>I need a little help in writing Unit tests for my project.
  I have created Unit test classes for my Controllers and Domain.</p>
  
  <p><strong>My Question is</strong>-
  I have a domain class named employee
  It has-
      String id
      String firstname
      String middleInitial
      String lastname
      String status
      String empType
      String userid</p>
  
  <p>And I want to mock them in my setUp() method under test class EmployeeControllerTest()</p>
  
  <h2>I have added following Mixin</h2>
  
  <pre><code>package EmployeeController
  
  import static org.junit.Assert.*
  
  import grails.test.mixin.*
  import grails.test.mixin.support.*
  import org.junit.*
  import java.io.Serializable
  
  import grails.test.mixin.TestFor
  import grails.test.mixin.TestMixin
  import grails.test.mixin.Mock
  import grails.test.mixin.support.GrailsUnitTestMixin
  import grails.test.mixin.domain.DomainClassUnitTestMixin
  import grails.test.mixin.services.ServiceUnitTestMixin
  import grails.test.mixin.web.ControllerUnitTestMixin
  import grails.test.mixin.web.FiltersUnitTestMixin
  import grails.test.mixin.web.GroovyPageUnitTestMixin
  import grails.test.mixin.web.UrlMappingsUnitTestMixin
  import grails.test.mixin.webflow.WebFlowUnitTestMixin
  
  @TestMixin(GrailsUnitTestMixin)
  @TestFor(EmployeeController)
  @Mock([Employee])
  
  class EmployeeControllerTests {
  
      void setUp() {
          // Setup logic here
  
         def Employee ce = new Employee()
         ce.put(empNo: "001", firstname: "amy", middleInitial: "ratr", lastname: "suz", status: "A", empType: "vendor", userid: "amar")
      }
  
      void tearDown() {
          // Tear down logic here
      }
  
      void testSomething() {
          //fail "Implement me"
      }
  </code></pre>
  
  <hr>
  
  <p>Kindly, let me know if I am missing something or need to do some modifications.</p>
  
  <p>Thanks in Advance :)
  Amy</p>