This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money. Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.
The test basis
The test principles
- Testing should be done early and continuously;
- Testing should be avoided by people or groups of meta-developers;
- When designing the test scheme, not only the input data should be determined, but also the expected output results should be determined according to the system function.
- It includes both valid and reasonable test cases and irrational and invalid test cases.
- Verify that the program does what it should and should not do;
- Strictly follow the test plan;
- Properly store test plans and test cases;
- Test cases can be reused or appended to tests.
Dynamic test type
Program run time test, divided into
- Black box testing method: functional testing, do not understand the software code structure, according to the functional design of use cases, test software functions.
- White box test method: structural test, clear code flow, design use cases according to code logic, use case coverage.
- Gray box test method: both black box, also have white box.
Static tests: Type
When the program is static, that is, manual review of the code, divided into
- Desk check: programmers check their own programs, after the program is compiled, before unit testing.
- Code review: Review by a panel of programmers and testers through a program review meeting.
- Code walkthrough: meetings are also used to review the code, but instead of simply checking the code, testers provide test cases, and programmers play the role of computers to run test cases manually and check the code logic.
The test strategy
-
Bottom-up: test from the bottom module, need to write drivers, and then start to merge modules one by one, and finally complete the test of the whole system. The advantage is that the underlying modules are validated earlier.
-
Top-down: first test the whole system, need to write the pile program, and then step down until the last test the lowest module. The advantage is that the main control and judgment points of the system are verified earlier.
-
Sandwich: There are both bottom-up and top-down testing methods, including both. Both have the advantages of both, the disadvantage is the test workload.
Testing phase
-
Unit testing: Also known as module testing, testing objects are independently compiled or assembled program modules, software components, or classes in OO software (collectively referred to as modules) based on detailed software design specifications.
-
Integration test: the purpose is to check the interface relationship between modules, as well as between modules and integrated software, and verify whether integrated software meets design requirements. The tests are based on the software outline design document.
-
Validation test: verifies whether the functions, performance, and other features of the software meet user requirements. Depending on the level of user involvement, the following types are usually included:
- Internal validation testing: testing is performed primarily within the software development organization in accordance with the SRS.
- Alpha testing: Testing by users in a development environment.
- Beta testing: The product is delivered to users only after the user has passed the test in the actual use environment.
- Acceptance testing: User-directed testing of SRS prior to delivery. Its test object is a complete, integrated computer system. The purpose of acceptance testing is to verify that the software system meets the development technical contract or SRS in a real user working environment. The conclusion of acceptance test is the main basis for users to decide whether to accept the software. In addition to meeting the admittance conditions for general testing, the software system under test shall be confirmed to have passed system testing prior to acceptance testing.
- System test: the test object is a complete, integrated computer system; The purpose of the test is to verify that the completed software configuration items can correctly connect to the system and meet the requirements specified in the system/subsystem design document and software development contract under the real system working environment. Testing is based on user requirements or development contracts.
The main contents include functional testing, robustness testing, performance testing, user interface testing, security testing, installation and anti-installation testing, among which, the most important work is to carry out functional testing and performance testing. Function test mainly uses black box test method; Performance testing.
The main indicators include response time, throughput, number of concurrent users and resource utilization.
-
Configuration item test: The test object is software configuration items. The test object is to check the consistency between software configuration items and SRS. The test is based on SRS. During this time, verify that the software configuration items under test have passed both unit and integration tests.
-
Regression testing: The purpose of testing software changes is to test the correctness of the changed parts and the compliance with the change requirements, as well as the original and correct functions, performance and other specified requirements of the software.
Test case design
1 Black Box Test Case
Think of the program as a black box, only know the input and output, do not know the internal code, test cases are designed, divided into the following categories:
-
Equivalence classification: classify all data according to certain characteristics, and then select one of the data in each category. The design principle of equivalence class test cases: Design a new test case to cover as many valid equivalence classes as possible that have not been covered, and repeat this step until all valid equivalence classes have been covered; Count a new test case that covers only one invalid equivalence class that has not been covered, and repeat this step until all invalid equivalence classes are covered.
-
Boundary value division: The boundary value of each class is taken as a test case. The boundary value is generally the two ends of the range and the two values with the smallest interval outside the range, such as the age range of 0-150 and the boundary value of 0,150 and -1,151.
-
Miscalculation: There is no fixed way, as a rule of thumb, to predict where a problem might occur and test it as a test case.
-
Causality diagram: a method of deducing causes from one result to another. There is no fixed method.
2 White box Test Case
Know the code logic of the program and design test cases covering code branches according to the code statements of the program. The coverage levels are divided into the following types from low to high:
-
Statement coverage SC: All statements in logical code must be executed once, with the lowest level of coverage. Because all statements are executed, all conditional judgments are not executed.
-
Decision override DC: All true and false branches of the logical code that determine the condition of the statement are overwritten once.
-
Condition override CC: True and false are executed once for each independent condition within each judgment condition.
-
Conditional decision combination coverage CDC: both decision coverage and conditional coverage are satisfied.
-
Path coverage: All possible paths in logical code are covered, with the highest level of coverage.
debugging
Testing is about finding errors, debugging is about finding the code and why. Debugging requires determining the exact location of the error; Determine the cause of the problem and try to correct it; Regression testing should be performed after correction.
Method of debugging
-
Brute force method: also known as exhaustive method or enumeration method, enumerate all possible methods to try one by one.
-
Backtracking method: it is also called heuristic method. It searches forward according to the optimal conditions to reach the target. When it finds that the original selection is not optimal or fails to reach the target, it takes a step back and selects again.
-
Deductive: method of reasoning from general to particular, as opposed to induction, starting from general premises. The process of arriving at specific statements or individual conclusions.
-
Induction: is from the special to the general reasoning method, starting from the problem exposed by the test, collect all correct or incorrect data, analyze the relationship between them, put forward the cause of the hypothetical error, with these data to prove or refute, so as to find out the error.
Software metrics
McCabe metric: also known as loop complexity, assuming that the number of directed edges in the digraph is M and the number of nodes is N, then the loop complexity of the digraph is M-N +2.
Note that the meanings of m and n cannot be confused, and the simplest loop can be used to make special values to remember this formula. In addition, for a program flowchart, each branch edge (line) is a directed edge, and each statement (box) is a vertex.
Two properties of software
External properties
Attributes for managers and users that can be measured directly, as performance indicators.Internal properties
Attributes of the software product itself, such as reliability, that can only be measured indirectly.