Test in Android review Android, reviewandroid
In Android, there are two types of tests:
1. Write test code in a project.
2. Create a project to write test code.
1. Write test code in a project
Steps:
1. Write a class to inherit AndroidTestCase
For example:
Package com. example. junittest; import junit. framework. assert; import android. test. androidTestCase; public class MyTest extends AndroidTestCase {public void testDevide () {Service service = new Service (); System. out. println (service. devide (10, 2);/*** Assert. assertEquals (expected, actual); * function: assertEquals. * Expected: expected Value * actual: actual value */Assert. assertEquals (5, service. devide (10, 2);} public void testDevide1 () {Service service = new Service (); System. out. println (service. devide (10, 2 ));}}
2. Configure the following two pieces of code in AndroidManifest. xml.
<Instrumentation
Android: name = "android. test. InstrumentationTestRunner"
Android: targetPackage = "com. njupt. sqlit"/>
<Uses-library android: name = "android. test. runner"/>
For example:
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.junittest" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.example.junittest" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <uses-library android:name="android.test.runner" /> <activity android:name="com.example.junittest.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application></manifest>
Resolution: The targetPackage in <insrtumentation/> specifies the registration of the application to be tested, that is, the package in the <manifest/> node.
The content specified by the tag must be consistent.
Note that:
1. Right-click the Test class ----- "run as Android JUNIT Test". At this time, all the Test methods of this Test class are run in one piece.
2. Right-click the Test method ----- "run as Android JUNIT Test ". At this time, only one test method is run.
2. Create a test project
Method:
Ctrl + n ---------> at this time, you will see the following interface:
Then select Android Test Project -----
Enter the name of the Android test project... -------------
Select the project to be tested .. ---------------------------------------
Next, click next .....
2. Differences from writing test code in a project.
1) The new test project does not contain MainActivity.
2) AndroidManifest. xml already contains labels such as <instrument/>.
3) This is to send the test project and the project on the north side to the mobile phone.
Download source code:
Http://download.csdn.net/detail/caihongshijie6/7612085
What is the difference between android app testing and android mobile phone testing?
Basically, all tests with Android are software tests:
Difference: Android app testing: This is used to test Android apps. Android app development companies are dedicated to testing their apps. For example, a game, chat software, or system software.
Android mobile phone testing: Mobile Phone Software Testing. For example, if a mobile phone is under development, mobile phone software testers must perform a system test on the mobile phone software, including OS and built-in applications, ease of use and so on.
How to test example in android sdk of Sina Weibo
1. the SDK example itself is a project, which can be imported to Eclipse. Note that there will be an error. After modification, you can run the test. Log On Through OAuth and display the Weibo list.
2. Baidu searched for the "ppy2790 blog" in the Sina Weibo development series. Very detailed.