Classification of software Testing
* Black box test
* Test Logic Business
* White Box test
* Test Logic method
According to the test grain size
* Method Test: Function test
* Unit tested: Unit test
* Integration testing: Integration test
* System tests: Systems Test
According to the level of testing violence
* Smoke test: Smoke test
* Stress test: Pressure test
Create a new Android project, create a new Test.java file, and note that defining a class inheritance must be inherited androidtestcase
Package com.wuyudong.juint.test; Import com.wuyudong.juint.util.Utils; Import android.test.AndroidTestCase; Public class extends androidtestcase { publicvoid Test () { int res = Utils.add (3, 5); Assertequals (8, res);} }
New Toolkit File Utils.java
Package Com.wuyudong.juint.util; Public class Utils { publicstaticint Add (intint b) { return A- b; }}
Run the project, error:
[2016-05-30 06:21:13-Unit Test] Unit test does not specify a android.test.InstrumentationTestRunner instrumentation or does not de Clare Uses-library Android.test.runner in its androidmanifest.xml
Add the following code to the Androidmanifest.xml:
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.wuyudong.juint"Android:versioncode= "1"Android:versionname= "1.0" > <USES-SDKandroid:minsdkversion= "8"android:targetsdkversion= "+" /> <instrumentation android:name= "Android.test.InstrumentationTestRunner"
android:targetpackage= "Com.wuyudong.juint"></instrumentation
> <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" > <uses-library android:name= "Android.test.runner"/> <ActivityAndroid:name= "Com.wuyudong.juint.MainActivity"Android:label= "@string/app_name" > <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> </Application></Manifest>
The following assertion exception occurs when you continue to run the unit tests test
Double-click Jump to
Public class extends androidtestcase { publicvoid Test () { int res = Utils.add (3, 5 ); assertequals (8, res);} }
Android junit Unit Test