내가 정의 LinkedList의 방법을 테스트 (JUnit을 테스트) 내 개인 추가를위한 가짜 비트 맵 이미지를 생성하고 얻을 필요가 JUnit을 테스트 안드로이드 스튜디오에서 null을 반환 Bitmap.CreateBitmap하지만 Bitmap.createBitmap 오류 반환 :는
을 java.lang.RuntimeException : android.graphics.Bitmap의 createBitmap 메소드가 조롱되지 않았습니다.
public class TicketsIteratorTest {
Bitmap img_Bmp;
TicketsIterator<Bitmap> TicketsList = new TicketsIterator();
/*
* Test for the add e get methods, check if the element just insert it's the same of the one just extract.
*/
@Test
public void Add_n_Get() throws Exception {
int i = 0, numIMG = 100;
Bitmap[] IMG_Generated;
IMG_Generated = new Bitmap[numIMG];
// Generate numIMG of imagine to insert into the Iterator and it save each one of it into an
// Bitmap array usefull for testing of the get method
while (i <= numIMG) {
// Generation of the fake Ticket Bitmap
try {
img_Bmp = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
IMG_Generated[i] = img_Bmp;
} catch (Exception e) {
// Print the cause of the error just generated
e.getCause().printStackTrace();
}
// Addition of the imagine just created
TicketsList.add(img_Bmp);
i++;
}
// Test if the imagine inserted it is correct
while (i <= numIMG) {
assertTrue(IMG_Generated[i] == TicketsList.get(IMG_Generated[i]));
i++;
}
}
이 도움을 주셔서 감사합니다 :
이
내 JUnitTest의 코드입니다.