14th Lesson for Joshui teacher
One, log log output
log.v (tag,message); Verbose mode, print the most detailed log
LOG.D (Tag,message); Debug-level logs
LOG.I (Tag,message); Log at info level
LOG.W (Tag,message); Warn-level logs
LOG.E (Tag,message); Log at error level
tag is used to mark the source of the log message with represented. Message is the contents of this log.
Two, Unit test
Step1: Add the following configuration information in Androidmanifest.xml:
<!--<application> Medium:--><uses-library android:name= "Android.test.runner"/><!--</ After application>:--><instrumentation<instrumentation android:name= " Android.test.InstrumentationTestRunner " android:targetpackage=" szy.android.activity "android:label=" testing />
step2 Writing Unit test code
a better approach is to create a new source Floderz in the project to write the unit file to be tested and add it to the Androidtestcase:
public class Persondaotest extends Androidtestcase {private static final String TAG = "Persondaotest";p ublic void Testadd ( ) //method {LOG.I (TAG, "test") to be tested;} public void Testdelete ()//method {fail ("not yet implemented") to be tested;}}
check a method in the tested class when testing right-runas->android junit test
The junit window has a green bar to indicate that the test passes. Red is a problem.
Three, commissioning
Debug is relatively simple, you get started groping.
Report:
Unit Tests for Android apps
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Learning Note (7) Android program debugging learning