请问怎么用 junut测试工具测试代码啊?
1条回答 默认 最新
- joy460154849 2017-04-01 03:21关注
新建一个class,新建一个方法,加上Test注释,写完之后,run as junit Test
给你举个例子吧:
//实现图片的复制
@Test
public void testImgCopy() throws Exception{
File f = new File("/Users/lixiuming/Desktop/商品详情图片/detail-1.jpg");
FileInputStream fis = new FileInputStream(f);
File out = new File("/Users/lixiuming/Desktop/project/day_15/detail-1.jpg");
FileOutputStream fos = new FileOutputStream(out);
byte[] b= new byte[1024];
int len;
while((len = fis.read(b)) != -1){
fos.write(b, 0, len);
}
}本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报