Test
The good procedure is measured.
Purpose of the test: test out as many bugsas possible in the program.
Test is divided into
Black Box testing: Testing business logic
White box test: Test logic method. In general, write a script code to invoke the business logic method through scripting code.
According to the test granularity is divided into :
Method Test:function Test tests a method
Unit tests: Unit Test Multiple methods for testing a class or a unit
Integration testing:integration Testv Server and client joint debugging, testing multiple units.
The system test is the function of the whole system, and all the units are tested together .
According to the degree of violence tested, divided into:
Smoke test: TheSmoke Test program runs in a high-load state with no memory overflow or error, indicating that the program is normal.
Stress test:pressure test simulates a certain amount of user connection to the server to see if the server will be down.
regression test : after modifying the old code, re-test to confirm that the modification did not introduce a new error or cause other code to produce an error.
Unit Test
In Android , A class that integrates the Androidtestcase class table name is a test class.
Each method in the test class can be run independently.
In Android , when you do unit testing, you need to add a test instruction set to the manifest file or a test class library to use. added before the application tag.
It doesn't matter where the test framework is defined or what it is to test the project.
The test method is a fixed public access permission, with no return value. The method name usually begins with a lowercase test . It is followed by the name of the method to be tested.
The definition format is public void Test method name () {}
When testing a method in the test framework, do not run the project, just run the test method, but you must open the emulator or connect to a real phone.
You can also use the Unit test framework in Android .
Package com.test.unittestdemo.utils;
Public class Utils {
Public Static int Add(intA,intb) {
return A + b;
}
}
Package com.test.unittestdemo.test;
Import com.test.unittestdemo.utils.Utils;
Import android.test.AndroidTestCase;
public   class testcase   extends   Androidtestcase {
Span style= "font-family: Song body; Color: #7f055; Font-weight:bold; Font-size:12.0000pt "> public   void   test Span style= "font-family: Song body; Color: #000000; Font-size:12.0000pt "> () {
Span style= "font-family: Song body; Color: #000000; Font-size:12.0000pt "> int   result  =  utils add (10, 5);
assertion: Used to detect consistency between actual and expected values, first value is expected, second value is actual value
There is no way to return a value, the assertion has no actual meaning
Span style= "font-family: Song body; Color: #000000; Font-size:12.0000pt "> // There is no way to return a value, the general test is whether the business logic of the period is normal
assertequals ( result);
}
}
Introduction to the use of test framework in Android