CN-121979788-A - Test case generation method and device, storage medium and electronic equipment
Abstract
The application discloses a test case generation method, a device, a storage medium and electronic equipment, and relates to the technical field of computers, wherein the method comprises the steps of obtaining a plurality of interface elements in a target user interface and a test case set of the target user interface; the method comprises the steps of establishing a mapping relation between a plurality of interface elements and a test case set, responding to code updating of target interface elements in the plurality of interface elements, identifying target test cases corresponding to the target interface elements from the test case set according to the mapping relation, and generating updated test cases of the target interface elements according to updating codes of the target interface elements. According to the application, by constructing the mapping relation between the interface elements and the test case set, the accurate association of the interface elements and the test cases is realized, the test case execution irrelevant to updating is reduced, the omission of the test cases relevant to updating can be avoided, and the accuracy of the test case generation is improved.
Inventors
- LI CHENGCHENG
Assignees
- 北京中科金得助智能科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251230
Claims (10)
- 1. A test case generation method, comprising: Acquiring a plurality of interface elements in a target user interface and a test case set of the target user interface; constructing a mapping relation between the interface elements and the test case set; Responding to code updating of a target interface element in the plurality of interface elements, and identifying a target test case corresponding to the target interface element from the test case set according to the mapping relation; And generating an update test case of the target interface element according to the update code of the target interface element.
- 2. The method of claim 1, wherein said constructing a mapping between said plurality of interface elements and said set of test cases comprises: In response to testing the target user interface according to the test case set, identifying a use relationship between a test case in the test case set and the plurality of interface elements; and constructing a mapping relation between the interface elements and the test case set according to the use relation.
- 3. The method of claim 2, wherein constructing a mapping relationship between the plurality of interface elements and the set of test cases according to the usage relationship comprises: Determining a use test case of each interface element in the plurality of interface elements according to the use relation, and generating a first association relation between the plurality of interface elements and the test case set; Determining interface elements tested by each test case in the test case set according to the use relation, and generating a second association relation between the plurality of interface elements and the test case set; and generating the mapping relation according to the first association relation and the second association relation.
- 4. The method of claim 1, wherein prior to the identifying, from the set of test cases, a target test case corresponding to the target interface element according to the mapping relationship in response to code updating the target interface element of the plurality of interface elements, the method further comprises: monitoring the plurality of interface elements; The responding to the code updating of the target interface element in the plurality of interface elements, and identifying the target test case corresponding to the target interface element from the test case set according to the mapping relation, comprises the following steps: And responding to the monitoring of the updating codes of the target interface elements in the plurality of interface elements, and identifying the target test cases corresponding to the target interface elements from the test case set according to the mapping relation.
- 5. The method of claim 4, wherein generating the updated test-case for the target interface element from the updated code for the target interface element comprises: Performing difference recognition on the update code and the initial code of the target interface element; And updating the target test case according to the difference identification result and the updating code to generate an updated test case of the target interface element.
- 6. The method of claim 5, wherein updating the target test case based on the difference identification result and the update code to generate an updated test case for the target interface element comprises: Determining a target update code which meets the test stability influence condition from the update codes according to the difference identification result; And updating the target test case according to the target updating code to generate an updated test case of the target interface element.
- 7. A test case generating apparatus, comprising: An acquisition module configured to acquire a plurality of interface elements in a target user interface and a set of test cases for the target user interface; a building module configured to build a mapping relationship between the plurality of interface elements and the test case set; The updating module is configured to respond to code updating of a target interface element in the plurality of interface elements, and identify a target test case corresponding to the target interface element from the test case set according to the mapping relation; And the generating module is configured to generate an update test case of the target interface element according to the update code of the target interface element.
- 8. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method of any one of claims 1 to 6.
- 9. An electronic device comprising a storage medium, a processor and a computer program stored on the storage medium and executable on the processor, characterized in that the processor implements the method of any one of claims 1 to 6 when executing the computer program.
- 10. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 6.
Description
Test case generation method and device, storage medium and electronic equipment Technical Field The present application relates to the field of computer technologies, and in particular, to a test case generating method and apparatus, a storage medium, and an electronic device. Background The automatic test of the User Interface (UI) is an important link in the process of updating the software, and the number of test cases for the automatic test of the UI is increased along with the continuous updating of the software, and the generation of the test cases can influence the verification effect of the user interface function. At present, three common modes are mainly adopted for generating test cases, namely, the test cases are classified according to the page or the function of software, the test cases under the classification are directly used for testing when corresponding modules are changed in the follow-up process, the test cases related to the modification codes during software updating are screened out to be used as the test cases of the current updating test, a tester attaches a function label to each test case, and when the software is updated, the test cases corresponding to the function labels are selected for updating. However, in this way, in the process of updating the interface elements in the UI, there may be a problem that test cases that need to be updated cannot be found accurately, so that a large number of unrelated test cases may be updated, and thus, the software performance may be affected. Disclosure of Invention In view of this, the present application provides a method, an apparatus, a storage medium and an electronic device for generating test cases, which are mainly aimed at improving the technical problem that in the prior art, in the process of updating interface elements in a UI interface, there is a problem that test cases which need to be updated cannot be found accurately, so that a large number of unrelated test cases are updated, and further, the software performance is affected. In a first aspect, the present application provides a test case generating method, including: Acquiring a plurality of interface elements in a target user interface and a test case set of the target user interface; constructing a mapping relation between the interface elements and the test case set; Responding to code updating of a target interface element in the plurality of interface elements, and identifying a target test case corresponding to the target interface element from the test case set according to the mapping relation; And generating an update test case of the target interface element according to the update code of the target interface element. Optionally, the constructing a mapping relationship between the plurality of interface elements and the test case set includes: In response to testing the target user interface according to the test case set, identifying a use relationship between a test case in the test case set and the plurality of interface elements; and constructing a mapping relation between the interface elements and the test case set according to the use relation. Optionally, the constructing a mapping relationship between the plurality of interface elements and the test case set according to the usage relationship includes: Determining a use test case of each interface element in the plurality of interface elements according to the use relation, and generating a first association relation between the plurality of interface elements and the test case set; Determining interface elements tested by each test case in the test case set according to the use relation, and generating a second association relation between the plurality of interface elements and the test case set; and generating the mapping relation according to the first association relation and the second association relation. Optionally, before the code updating is performed on the target interface element in the plurality of interface elements, and the target test case corresponding to the target interface element is identified from the test case set according to the mapping relationship, the method further includes: monitoring the plurality of interface elements; The responding to the code updating of the target interface element in the plurality of interface elements, and identifying the target test case corresponding to the target interface element from the test case set according to the mapping relation, comprises the following steps: And responding to the monitoring of the updating codes of the target interface elements in the plurality of interface elements, and identifying the target test cases corresponding to the target interface elements from the test case set according to the mapping relation. Optionally, generating the update test case of the target interface element according to the update code of the target interface element includes: Performing difference recognition on the update code and the