关于Log的打印:
首先需要定义一个静态变量TAG:
private static final String TAG = ”DylanTest”;
打印写法:
Log.i(TAG, text);
这里还是用NotePad举例:
1 | package com.example.android.notepad.test; |
2 | import java.util.ArrayList; |
3 | import android.R.string; |
4 | import android.test.ActivityInstrumentationTestCase2; |
5 | import android.util.Log; |
6 | import android.widget.TextView; |
7 | import com.example.android.notepad.NotesList; |
8 | import com.jayway.android.robotium.solo.Solo; |
10 | public class CydTest extends ActivityInstrumentationTestCase2<NotesList> |
13 | private static final String TAG = "CYDLog" ; |
16 | super (NotesList. class ); |
19 | public void setUp() throws Exception{ |
20 | solo = new Solo(getInstrumentation(),getActivity()); |
23 | public void tearDown() throws Exception { |
24 | solo.finishOpenedActivities(); |
27 | public void testAdd() { |
28 | solo.clickOnMenuItem( "Add note" ); |
29 | solo.enterText( 0 , "CYDtest" ); |
31 | assertEquals( true ,solo.searchText( "CYDtest" )); |
32 | ArrayList<TextView> arrNote = solo.clickInList( 0 ); |
33 | Log.i(TAG, arrNote.get( 0 ).getText().toString()); |
36 | <span style= "font-size: 12px; line-height: 18px;" > |
然后在LogCat中,就能看到Log信息了,为了查看方便,这里在LogCat中了个筛选。

转载地址:http://www.cydtest.com/?p=1750