Android Code functional test

Source: Internet
Author: User

1,Android test code when the first need to declare services in the manifest, mainly including the copy of 2 tags: such as the red part of the code,

The instrumentation label needs to be application, while the uses-library and activity are lateral.

<?xml version= "1.0" encoding= "Utf-8"? ><manifest xmlns:android= "http://schemas.android.com/apk/res/        Android "package=" Com.example.datebase "android:versioncode=" 1 "android:versionname=" 1.0 "> <uses-sdk android:minsdkversion= "8" android:targetsdkversion= "/>"<instrumentation android:label= "Tests for MyApp" Android:name= "Android.test.InstrumentationTestRunner "Android:targetpackage=" Com.example.datebase "/><application android:allowbackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@strin G/app_name "Android:theme=" @style/apptheme "><uses-library android:name= "Android.test.runner"/><activity android:name= "com.example.datebase.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&    Gt </application></manifest>

2, create a test class, it inherits Androidtestcase, and in the test function function can not pass parameters, the following testadd cannot pass the argument, the negation will not execute this test function

public class Persontest extends Androidtestcase {public void Testadd () throws Exception {System.out.println ("start"); Persondao db2=new Persondao (GetContext ());d B2.add ("Zhangpeng", 156,12); SYSTEM.OUT.PRINTLN ("Success");}}

  

Android Code functional test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.