Search

CN-122019353-A - Data processing method, apparatus, electronic device, computer readable storage medium, and computer program product

CN122019353ACN 122019353 ACN122019353 ACN 122019353ACN-122019353-A

Abstract

The application provides a data processing method, a device, electronic equipment, a computer program product and a computer readable storage medium, wherein the method comprises the steps of obtaining sample data of a page to be tested, wherein the sample data is used for testing any display state of the page to be tested, generating a target test set of the page to be tested based on the sample data, wherein the target test set comprises at least two test data and expected display states corresponding to each test data, the at least two test data are used for testing each display state of the page to be tested, obtaining updated page codes obtained by updating the page to be tested, determining each updated display state of the page to be tested based on the updated page codes and the at least two test data, and determining a test result of the updated page codes based on each updated display state and each expected display state. The application can reduce the cost of data processing and improve the efficiency of data processing.

Inventors

  • FENG WENCHENG

Assignees

  • 腾讯科技(北京)有限公司

Dates

Publication Date
20260512
Application Date
20241112

Claims (15)

  1. 1. A method of data processing, the method comprising: acquiring sample data of a page to be tested, wherein the sample data is used for testing any display state of the page to be tested; Generating a target test set of the page to be tested based on the sample data, wherein the target test set comprises at least two test data and an expected display state corresponding to each test data, and the at least two test data are used for testing each display state of the page to be tested; Acquiring updated page codes obtained by updating the page to be tested, and determining the updated display state of each page to be tested based on the updated page codes and the at least two test data; and determining a test result of the updated page code based on each updated display state and each expected display state.
  2. 2. The method of claim 1, wherein the generating the target test set for the page to be tested based on the sample data comprises: Generating test data corresponding to the sample data; acquiring a first page code of the page to be tested in an expected display state, and determining an expected display state corresponding to the test data based on the first page code and the test data; Generating a candidate test set based on the test data and the expected display state; a target test set is determined based on the candidate test set.
  3. 3. The method of claim 2, wherein the determining a target test set based on the candidate test set comprises: determining the coverage rate of the candidate test set on the display state of the page to be tested; Generating next test data corresponding to the sample data based on the sample data when the display state coverage rate is smaller than or equal to a preset coverage rate; determining a next expected display state corresponding to the next test data based on the first page code and the next test data; adding the next test data and the next expected display state to the candidate test set to obtain a new candidate test set; the target test set is determined based on the new candidate test set.
  4. 4. A method according to claim 3, characterized in that the method further comprises: and when the display state coverage rate is larger than the preset coverage rate, determining the candidate test set as the target test set.
  5. 5. The method of claim 2, wherein the generating test data corresponding to the sample data comprises: Determining a first data type of the sample data; when the first data type belongs to a first preset type, generating the test data based on the first data type; and when the first data type belongs to a second preset type, determining a plurality of first sub-types included in the first data type, and generating the test data based on the plurality of first sub-types.
  6. 6. The method of claim 5, wherein the generating the test data based on the plurality of first subtypes comprises: Generating first candidate data based on the first subtype when the first subtype belongs to a first preset type for each first subtype; When the first subtype belongs to a second preset type, determining a plurality of second subtypes included in the first subtype until each second subtype is the first preset type, and generating second candidate data based on each second subtype; The test data is determined based on the first candidate data and the second candidate data.
  7. 7. The method of any of claims 1 to 6, wherein the determining each updated display state of the page to be tested based on the updated page code and the at least two test data comprises: And aiming at each piece of test data, taking the test data as input data of the updated page code, and executing the updated page code to obtain each updated display state of the page to be tested.
  8. 8. The method of any of claims 1 to 6, wherein the determining a test result of the updated page code based on each of the updated display states and each of the expected display states comprises: When each updated display state is the same as the corresponding expected display state, determining that the test result is test passing; and when any updated display state is different from the corresponding expected display state, determining a comparison result between the updated display state and the expected display state, and determining the test result based on the comparison result.
  9. 9. The method of claim 8, wherein determining a comparison between the updated display state and the expected display state comprises: Determining a first area from the updated display state, and determining a second area from the expected display state, wherein the first area and the second area are areas with differences between the updated display state and the corresponding expected display state; and determining the first area and the second area as the comparison result.
  10. 10. The method of claim 8, wherein the determining the test result based on the comparison result comprises: When the updated display state is determined to be in accordance with expectations based on the comparison result, determining that the test result is test passing; and when the updated display state is determined to be not in accordance with expectations based on the comparison result, determining that the test result is that the test fails.
  11. 11. The method according to claim 10, wherein the method further comprises: When the test result is that the test fails, updating the updated page code to obtain a new updated page code; and determining a test result of the new updated page code based on the new updated page code and the target test set.
  12. 12. A data processing apparatus, the apparatus comprising: the acquisition module is used for acquiring sample data of a page to be tested, wherein the sample data is used for testing any display state of the page to be tested; The generation module is used for generating a target test set of the page to be tested based on the sample data, wherein the target test set comprises at least two test data and an expected display state corresponding to each test data, and the at least two test data are used for testing each display state of the page to be tested; The acquisition module is further configured to acquire an updated page code obtained by updating the page to be tested, and determine, based on the updated page code and the at least two test data, a display state of each of the updated pages to be tested; And the determining module is used for determining a test result of the updated page code based on each updated display state and each expected display state.
  13. 13. An electronic device, the electronic device comprising: A memory for storing computer executable instructions or computer programs; a processor for implementing the method of any one of claims 1 to 11 when executing computer-executable instructions or computer programs stored in the memory.
  14. 14. A computer-readable storage medium storing computer-executable instructions or a computer program, which when executed by a processor implement the method of any one of claims 1 to 11.
  15. 15. A computer program product comprising computer-executable instructions or a computer program, which, when executed by a processor, implements the method of any one of claims 1 to 11.

Description

Data processing method, apparatus, electronic device, computer readable storage medium, and computer program product Technical Field The present application relates to information technology, and in particular, to a data processing method, apparatus, electronic device, computer readable storage medium, and computer program product. Background The unit test is used to test the front end, considering the unit (finger function, component, page, etc.) as the minimum test. In the related art, the unit test is realized by manually handwriting the test case, inputting the test case into the code of the execution unit after the unit, judging whether the output result is consistent with the expected output result, and if the output result is consistent with the expected output result, indicating that the test is passed. However, for the front-end page or the component unit, if all states of the front-end page are to be enumerated through the test cases, the front-end page or the component unit needs to be familiar with services in the unit, and a large number of test cases need to be written manually, so that the labor cost is high and the efficiency is low. Disclosure of Invention Embodiments of the present application provide a data processing method, apparatus, computer readable storage medium, and computer program product, which can reduce the cost of data processing and improve the efficiency of data processing. The technical scheme of the embodiment of the application is realized as follows: the embodiment of the application provides a data processing method, which comprises the following steps: The method comprises the steps of obtaining sample data of a page to be tested, wherein the sample data are used for testing any display state of the page to be tested, generating a target test set of the page to be tested based on the sample data, wherein the target test set comprises at least two pieces of test data and expected display states corresponding to each piece of test data, the at least two pieces of test data are used for testing each display state of the page to be tested, obtaining updated page codes obtained by updating the page to be tested, determining each updated display state of the page to be tested based on the updated page codes and the at least two pieces of test data, and determining a test result of the updated page codes based on each updated display state and each expected display state. An embodiment of the present application provides a data processing apparatus, including: The system comprises an acquisition module, a generation module and a determination module, wherein the acquisition module is used for acquiring sample data of a page to be tested, the sample data are used for testing any display state of the page to be tested, the generation module is used for generating a target test set of the page to be tested based on the sample data, the target test set comprises at least two test data and an expected display state corresponding to each test data, the at least two test data are used for testing each display state of the page to be tested, the acquisition module is also used for acquiring an updated page code obtained by updating the page to be tested, each updated display state of the page to be tested is determined based on the updated page code and the at least two test data, and the determination module is used for determining a test result of the updated page code based on each updated display state and each expected display state. An embodiment of the present application provides an electronic device, including: A memory for storing computer executable instructions or computer programs; and the processor is used for realizing the method provided by the embodiment of the application when executing the computer executable instructions or the computer programs stored in the memory. The embodiment of the application provides a computer readable storage medium, which stores a computer program or computer executable instructions for implementing the data processing method provided by the embodiment of the application when being executed by a processor. The embodiment of the application provides a computer program product, which comprises a computer program or a computer executable instruction, and the computer program or the computer executable instruction realize the data processing method provided by the embodiment of the application when being executed by a processor. The embodiment of the application has the following beneficial effects: Sample data of a page to be tested is obtained, a target test set of the page to be tested is generated based on the sample data, the target test set comprises at least two test data and an expected display state corresponding to each test data, and each display state of the page to be tested can be tested by the at least two test data. Thus, the target test set is automatically generated through the sample data, the generation efficiency of