How to create a Bundle in a Unit test
<p>I want to test a method that deals with <a href="https://developer.android.com/reference/android/os/Bundle.html" rel="noreferrer">Bundles</a>. I'm unable to create a (non-null) Bundle object in the test environment, though.</p>

<p>Given the following code:</p>

<pre><code>Bundle bundle = new Bundle();
bundle.putString("key", "value");
boolean containsKey = bundle.containsKey("key");
</code></pre>

<p><code>containsKey</code> is <code>true</code> if the code is executed in the application context, but <code>false</code> if executed in a unit test.</p>

<p><a href="https://i.stack.imgur.com/o8vyS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/o8vyS.png" alt="Service Context"></a></p>

<p><a href="https://i.stack.imgur.com/Nd1CN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Nd1CN.png" alt="Test Context"></a></p>

<p>I can't figure out why that's the case and how to create a Bundle for my tests.</p>