title: Using the Android KeyStore in Robolectric tests
body: <p>I'm attempting to write a few testcases that work against the <a href="https://developer.android.com/training/articles/keystore.html" rel="noreferrer">Android Keystore</a>. However, when I write the following test case:</p>
  
  <pre><code>@RunWith(RobolectricGradleTestRunner.class)
  @Config(constants = BuildConfig.class, sdk = 21)
  public class FancyPantsUnitTest {
     @Test
     public void buildKey() {
          keyPairGenerator = KeyPairGenerator.getInstance("RSA", "AndroidKeyStore");
          keyPairGenerator.initialize(4096);
          final KeyPair keyPair = keyPairGenerator.generateKeyPair();
     }
  }
  </code></pre>
  
  <p>This fails with the following exception:</p>
  
  <pre><code>org.junit.ComparisonFailure: expected:&lt;null&gt; but was:&lt;java.security.KeyStoreException: AndroidKeyStore not found&gt;
  </code></pre>
  
  <p>I'm targeting API Level <strong>23</strong> if that helps.</p>