laitimes

Precision Testing Practice - Test Scope Analysis| JD Cloud technical team

author:JD Cloud developer

1. Background

One of the main reasons for bugs leakage to the production environment is to evaluate the business impact points in the process of requirement iteration. Reducing the occurrence of missed evaluation problems is an important direction to improve the quality of delivery, and accurate testing is another way to analyze business impact points in addition to relying on the ability and experience of production and research personnel.

Second, the practice plan

1. Brief introduction of the program

The following describes the automatic analysis scheme for the impact of code churn for a single Java application.

1) Introduction to the principle

Based on code dependencies, analyze which entry codes (such as interfaces, messages, and tasks) are affected by the changed code.

For example, in the following figure, if an application changes the underlying method 1, methods a, b, and z can be analyzed based on the call relationship between the codes, and methods a, b, and z are the outermost entry methods of the application affected by method 1.

Precision Testing Practice - Test Scope Analysis| JD Cloud technical team



2) Introduction to the implementation process

Precision Testing Practice - Test Scope Analysis| JD Cloud technical team



The code dependency analysis scheme is described in detail:

A. Parse the Java bytecode file based on the ASM framework, and the call relationship between the codes can be parsed.

For example, the following figure is a screenshot of part of the content of the bytecode file, the invokexxx instruction in the method is the instruction to call the method in the bytecode, and the asm bytecode analysis framework can be used to analyze that methodB is called in methodA.

Precision Testing Practice - Test Scope Analysis| JD Cloud technical team



b. The methods containing diff in the test branch and the master branch are used as the query object, and the relationship data between the methods can be used to find out which entry methods are affected by a certain method

3. Practical effects

Combined with the coding webhooks, the code diff and the automatic analysis of the affected code are automatically obtained after the code is tested.

Precision Testing Practice - Test Scope Analysis| JD Cloud technical team



Fourth, future planning

Based on the analysis of the affected interface and message entry information, combined with the test cases of the corresponding interfaces, the recommendation and automatic operation of test cases can be further realized, and the test coverage report can be automatically given in combination with the code coverage analysis ability.

Author: Jingdong Technology Lv Jun

Source: JD Cloud Developer Community

Read on