我的类需要一个位图,但Mockito的模拟上下文对象似乎无法做到这一点:
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);
}
...
decodeResource
方法,还是只是想模拟mContext.getResources
的结果? - ThrawnCA