title: Testing class with Protected Constructor w/ PowerMock and Mockito
body: <p>I have the following class to test:</p>
  
  <pre><code>public abstract class Challenge {
      protected int id;
      protected String name;
      protected String question;
  
      protected Challenge(){}
  
      public String[] toStrings(){
          String[] s = {Integer.toString(id), name, question};
          return s; 
      }
  
      ...
  </code></pre>
  
  <p>But using this test:</p>
  
  <pre><code>@Test
  public void testToStrings() throws Exception{
  
      String[] expectedResult1 = new String[]{"1", "a", "b"};
  
      String[] obtainedResult1 = null;
  
      Challenge challengeMock = PowerMockito.mock(Challenge.class);
      challengeMock.id = 1;
      challengeMock.name = "a";
      challengeMock.question = "b";
  
      obtainedResult1 = challengeMock.toStrings();
      Assert.assertEquals(expectedResult1[0], obtainedResult1[0]);
      Assert.assertEquals(expectedResult1[1], obtainedResult1[1]);
      Assert.assertEquals(expectedResult1[2], obtainedResult1[2]);
  }
  </code></pre>
  
  <p>I get a NullPointerException due to "obtainedResult1 = challengeMock.toStrings();" that returns null.</p>
  
  <p>I use PowerMock + Mockito running in Robolectric with rule(becouse its an Android project).</p>
  
  <pre><code>@Rule
  public PowerMockRule rule = new PowerMockRule();
  </code></pre>
  
  <p>Where is the problem?</p>