ExampleUnitTest的用法
生活随笔
收集整理的這篇文章主要介紹了
ExampleUnitTest的用法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
android studio ExampleUnitTest 自己在項目中很常用,這里主要說下自己
常用來做打印log日志,
比如項目中有些打印需要拿出來單獨測試可以不,
下面一個截取的為例子
首先項目選為android 這樣在...test里面就能看到了
寫出部分
?
String code="12345678";
code=code.substring(code.length()-4,code.length());
System.out.println( code );
?
然后在上面運行選擇要運行如下面
之后再點擊運行之后再控制臺就能看到了,
如下圖
?
例如
package com.fmm.machinea;import org.junit.Test;import static org.junit.Assert.*;/*** Example local unit test, which will execute on the development machine (host).** @see <a href="http://d.android.com/tools/testing">Testing documentation</a>*/
public class ExampleUnitTest {@Testpublic void addition_isCorrect() throws Exception {assertEquals(4, 2 + 2);String code="1";while(code.length()<7){code+=code;}System.out.println( code );}
}
輸出結果
總結
以上是生活随笔為你收集整理的ExampleUnitTest的用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 哪可以看免费高清最新电影电视剧,谢谢
- 下一篇: 警告 '_'用作标识符, JavaSE8