title: Mocking class properties Java/Android
body: <p>I have a class written by somebody which exposes it properties as public without getters/setters.</p>
  
  <p>Now I want to mock this class using Android Mocking framework.
  I dont want to modify the class_under_test (unless required). I know its a bad programming practice, but is there a way to mock the properties like</p>
  
  <pre><code>AndroidMock.expect(myMockClass.name).andReturn('Scott');
  </code></pre>
  
  <p>I get exception when I run the testcase :</p>
  
  <pre><code>java.lang.IllegalStateException: no last call on a mock available
  at org.easymock.EasyMock.getControlForLastCall(EasyMock.java:174)
  at org.easymock.EasyMock.expect(EasyMock.java:156)
  at com.google.android.testing.mocking.AndroidMock.expect(AndroidMock.java:264)
  at com.akshat.test.TestPerson.testGetName(TestPerson.java:41)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
  at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
  at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
  at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
  </code></pre>