Android junit
1、在一个testMehod()中只要执行完代码行,无论是否子线程是否执行完毕,都会执行tearDown(),是不会打印十个sleep的。
import android.os.Environment; import android.os.SystemClock; import android.test.AndroidTestCase; public class T4 extends AndroidTestCase{ @Override protected void setUp() throws Exception { // TODO Auto-generated method stub System.out.println("setup ..."); super.setUp(); } public void test1(){ Thread thread=new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub for(int i=0;i<10;i++){ System.out.println("sleep ...."); SystemClock.sleep(1000); } } }); thread.start(); } @Override protected void tearDown() throws Exception { // TODO Auto-generated method stub System.out.println("teardown...."); super.tearDown(); } }
2、在android test Project中使用getRawResource文件,获取的都是乱码。。。
原因使用getContext().getRawResource()的上下文还是原项目的,要获取test project的上下文和资源文件要InputStream im = getInstrumentation().getContext().getResources().openRawResource(R.raw.test_urls);
相关推荐
shirleypaddy 2020-10-19
qingmumu 2020-10-19
lustdevil 2020-10-18
ganlulululu 2020-10-12
lustdevil 2020-08-03
lustdevil 2020-07-18
lustdevil 2020-06-25
lustdevil 2020-06-21
zhengzf0 2020-06-21
宿命java 2020-06-15
JackYin 2020-06-14
dongxurr 2020-06-07
snowphy 2020-06-06
zhengzf0 2020-05-28
81901836 2020-05-26
Julywhj 2020-05-26