1^O PtU:V#dN0importjava.util.ArrayList;51Testing软件测试网PV~Hh8i import java.util.HashMap; L3^r.{'nioJ0import java.util.List;51Testing软件测试网g(Q"h$D xM"h+ya7L import java.util.Map; A&{%tJV051Testing软件测试网G-p$@f(S-?u)rimport com.helloAndroid.Books;51Testing软件测试网.\(d*x`2l import com.helloAndroid.HelloAndroid; /f9\/FA
n[o3T0import com.helloAndroid.R; 0e7}j-]/~![+a0;QA ytm
ew)B0import android.R.xml;51Testing软件测试网z9MP
h3`!z7Qf?"{ import android.test.ActivityInstrumentationTestCase2;51Testing软件测试网|0z~B.bW@i0wy import android.widget.ListView; $@&g"YV1T.l/L*V(q&z0import android.widget.SimpleAdapter; *^&D z0Swi)n!K3_051Testing软件测试网`3a\7_"i5s \M51Testing软件测试网*q:]"kV\j0M?&kU/x public class Junit3 extends ActivityInstrumentationTestCase2<Books> { 9n~]%@&~3_@051Testing软件测试网&E`8~1j4g;GPListView listView;51Testing软件测试网l/c9W-kW$C0E/P K Books books; d3f6}[+Yc0E~"^7r azt#}IH6j1P0public Junit3() { %M)Km3EIW~0super("com.helloAndroid.HelloAndroid" ,Books.class); v*f?~OC Iw5k0// TODO Auto-generated constructor stub51Testing软件测试网8`.f,I4v)RKX*u } 7e1aw/]4Gt-DT0I0u+T*Tt"g Lc0protected void setUp() throws Exception { [^8ThE5S0super.setUp();51Testing软件测试网.h#C"a8@Y~ books = this.getActivity();51Testing软件测试网:Y+g RK2?7ch 51Testing软件测试网#lm&}v3B)Jl51Testing软件测试网+` E.v^%d4o }51Testing软件测试网%qWfE1V }'a1t 51Testing软件测试网-aldAo//添加testPreconditions()方法,检查初始化环境,只执行一次51Testing软件测试网6m;k+c%o+z7K public void testPreconditions() { 'n&e-ol Tf9} S*r0e!U [uzC,}Y@Xy4Ps0 //assertNotNull(integer); 9r{u)Ot/QK051Testing软件测试网Zifj
b{.Z k} #}1C9NO W${R E051Testing软件测试网8lD8?2g
S]g/hA//添加单元测试 }#U?vv pb,D)v0public void testText() { (jFoq
G,[7\?K0%w
W:@o8m*i0 //assertEquals(resourceString,(String)mView.getText());51Testing软件测试网(L[)m-@u{3d List<Map<String, Object>> resourceName = new ArrayList<Map<String,Object>>(); ZwgGVppa0Map<String ,Object> map = new HashMap<String, Object>(); 9L3CR2F"Qe051Testing软件测试网O3n-x#KzYmap.put("line1", "测试Junit"); \-qV5\0gx}0map.put("img", R.drawable.weikexue); a?;O
p1q*Q!R0resourceName.add(map);51Testing软件测试网5m%NSAHwux p{SsZO0//listView = (ListView)books.findViewById(com.helloAndroid.R.id.l)51Testing软件测试网0OK
Y4hO? SimpleAdapter notes = new SimpleAdapter(51Testing软件测试网mdKDm2H^Y J books,51Testing软件测试网ps7x"~H)V] resourceName,51Testing软件测试网2iCmB5K
a,p R.layout.rows,51Testing软件测试网M&` [-U3Pv new String[]{"line1" ,"img"}, a"]6we$K0o
P0new int[]{R.id.text1, R.id.img});51Testing软件测试网 ~2w.~1rc.[$`kbO ,z9CBJ1|^@4Llr0//books.setListAdapter(notes);51Testing软件测试网lL7Q1Q? } 8d)oG;J3~N%G05CT2f1^
P0}51Testing软件测试网
{8?
^H_tre |