My class needs a bitmap but mockito's mock context object is not capable of doing that is seems:
public class PlayerTest {
@Mock // Mocking the android context class
Context mMockContext;
// intantiating object from that mocked class
Context mContext;
private Player player;
private Bitmap playerBitmap;
private int screenX;
private int screenY;
@Before
public void setupPlayer(){
playerBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.player);
player = new Player(mContext, screenX, screenY,playerBitmap);
}
...
Can't you just annotate private Bitmap playerBitmap
with @Mock
?
I can't see the rest of the class, but I presume you're using the Mockito JUnit runner. If not, you'll need to either use that, or call MockitoAnnotations.initMocks(this)
in your setup method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With