CN117370142A - Code testing method and device - Google Patents

Code testing method and device Download PDF

Info

Publication number
CN117370142A
CN117370142A CN202210771474.0A CN202210771474A CN117370142A CN 117370142 A CN117370142 A CN 117370142A CN 202210771474 A CN202210771474 A CN 202210771474A CN 117370142 A CN117370142 A CN 117370142A
Authority
CN
China
Prior art keywords
code
test case
version
version code
result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210771474.0A
Other languages
Chinese (zh)
Inventor
陈柳杉
甘陈卿
梁昊
马国俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Zitiao Network Technology Co Ltd
Original Assignee
Beijing Zitiao Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Zitiao Network Technology Co Ltd filed Critical Beijing Zitiao Network Technology Co Ltd
Priority to CN202210771474.0A priority Critical patent/CN117370142A/en
Publication of CN117370142A publication Critical patent/CN117370142A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the disclosure provides a code test method and device, the method includes firstly executing a second test case corresponding to a second version code through a first version code to obtain a first return test execution result, wherein the first version code is a code of a previous version of the second version code, the second test case is generated according to the second version code, secondly executing the second test case through the second version code to obtain a second return test execution result, finally comparing the first return test execution result with the second return test execution result, generating a return test result corresponding to the second version code according to the comparison result, and the return test result is used for correcting the second version code. The embodiment can timely find the problem of the new modified code in the second version code, and can improve the test sufficiency and the test accuracy.

Description

Code testing method and device
Technical Field
The embodiment of the disclosure relates to the technical field of software testing, in particular to a code testing method and device.
Background
Differential Testing (Diff-Testing) is a code Testing technique, which takes the same test case as input, runs different versions of codes, and identifies errors in the codes by comparing the running conditions of the different versions of codes. But the sufficiency and accuracy of testing current version codes in the current differential testing technology is to be improved.
Disclosure of Invention
The embodiment of the disclosure provides a code testing method and device for improving the sufficiency and accuracy of current version code testing.
In a first aspect, an embodiment of the present disclosure provides a code testing method, including:
executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code;
executing the second test case through a second version code to obtain a second back test execution result;
and comparing the first return execution result with the second return execution result, and generating a return result corresponding to the second version code according to the comparison result, wherein the return result is used for correcting the second version code.
In a second aspect, embodiments of the present disclosure provide a code testing apparatus, including:
the execution module is used for executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code and a first test case corresponding to the first version code;
The execution module is further used for executing the second test case through a second version code to obtain a second return test execution result;
and the comparison module is used for comparing the first return execution result with the second return execution result, generating a return result corresponding to the second version code according to the comparison result, and correcting the second version code by the return result.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: a processor and a memory;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored in the memory to cause the at least one processor to perform the code testing method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, implement the code testing method as described above in the first aspect and the various possible designs of the first aspect.
In a fifth aspect, embodiments of the present disclosure provide a computer program product comprising a computer program which, when executed by a processor, implements the code testing method of the first aspect and the various possible designs of the first aspect as described above.
According to the code testing method and the code testing equipment, a first test execution result is obtained by executing a second test case corresponding to a second version code through a first version code, the first version code is a code of a previous version of the second version code, the second test case is generated according to the second version code, a second test execution result is obtained by executing the second test case through the second version code, finally the first test execution result and the second test execution result are compared, a test result corresponding to the second version code is generated according to the comparison result, and the test result is used for correcting the second version code. According to the embodiment, the second test case generated based on the second version code can be adopted to test the second version code and the first version code of the version before the second version code, so that the problem of a new modified code can be found timely, and the test sufficiency and the test accuracy can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, a brief description will be given below of the drawings that are needed in the embodiments or the description of the prior art, it being obvious that the drawings in the following description are some embodiments of the present disclosure, and that other drawings may be obtained from these drawings without inventive effort to a person of ordinary skill in the art.
Fig. 1 is a schematic diagram of a code testing method according to an embodiment of the present disclosure;
FIG. 2 is a flowchart of a code testing method according to an embodiment of the present disclosure;
FIG. 3 is a second schematic flow chart of a code testing method according to an embodiment of the disclosure;
fig. 4 is a schematic diagram of a message pushing policy of a code testing method according to an embodiment of the disclosure;
FIG. 5 is a block diagram of a code testing apparatus provided by an embodiment of the present disclosure;
fig. 6 is a schematic hardware structure of a code testing device according to an embodiment of the present disclosure.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present disclosure more apparent, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without inventive effort, based on the embodiments in this disclosure are intended to be within the scope of this disclosure.
Related noun interpretation:
the single-test automatic generation technology comprises the following steps: broadly refers to a class of techniques that enable unit testing to be generated for specific code segments based on program static and dynamic analysis results. Based on a genetic evolution algorithm, a large number of use cases are randomly generated and then the superior and inferior are eliminated, so that the method is the most common single-test generation mode. The technology aims at generating test cases only by carrying out test case generation on information obtained by program analysis under the condition that manual intervention is not needed, and often has the problem that the output correctness is difficult to verify (Oracle program).
Differential test (Diff-testing): is a test technology for trying to overcome Oracle problem and used for testing production flow, and has certain practice in the industry and academia. Diff test is to run two versions of code (e.g., base version and test version) with the same input (test case) and then compare the intermediate and final products (Diff) of the two versions of code to identify undesirable behavior (bug). The Diff-testing inputs can be collected from the actual business scenario, with the characteristics of large volumes and close proximity to the actual scenario.
Referring to the above explanation of the term, differential Testing (Diff-Testing) is a code Testing technique that uses the same test case as input, runs different versions of code, and identifies errors in the code by comparing the running conditions of the different versions of code. In the related art, when testing a current version code, a unit automatic generation technology is generally adopted, a test case is automatically generated based on a previous version code, and the previous version code and the current version code are operated by taking the test case as input to realize automatic differential testing. However, in the above manner, there is no problem of newly modifying the code from the discovery of the current version code, so that the test sufficiency and accuracy of the current version code are low.
In order to solve the technical problems, the inventor researches and discovers that when the automatic differential test is performed on the current version, because the test case is generated based on the previous version code, the test case does not have the test case of the new modified code in the current version code, so that the problem of the new modified code in the current version code cannot be discovered in the current differential test on the current version, if the current differential test is based on the existing mode, the inventor can further discover the problem by adopting a back test mode, namely when the automatic test is performed on the next version code, the new test case corresponding to the current version code is generated, the problem of the new modified code in the current version code can be discovered based on the new test case, compared with the problem of the new modified code in the previous version code is discovered, the problem is not favorable for timely correcting the code error, and the problem is not delayed in the problem is discovered, the current differential test on the current version code can be discovered until the next version code is automatically tested, namely when the current differential test is performed on the next version code, the current version code is fully discovered, and the problem is fully corrected, and the problem is completely discovered.
Referring to fig. 1, fig. 1 is a schematic diagram of a code testing method according to an embodiment of the disclosure. In the code development process, in order to better realize multi-person collaboration, codes can be branched, different developers are responsible for different branches, as shown in fig. 1, for an X branch, multiple versions of codes, for example, a 1 version code, a 2 version code, a 3 version code and up to an N version code, where N is a positive integer greater than 3, may occur. Taking a 2-version code as an example, in the related art, a 1-version code is used as input to generate a 1-version test case, the 1-version code and the 2-version code are respectively operated to complete a regression flow, the regression flow cannot find the problem of a new modification code of the 2-version code relative to the 1-version code, furthermore, a 2-version test case is generated based on the 2-version code, the 2-version test case is used as input to respectively operate the 1-version code and the 2-version code to complete a back test flow, and the problem of the new modification code in the 2-version code can be found in time through the back test flow. The code testing method provided by the embodiment of the disclosure can timely find the problem of new modified codes when testing the current version codes, and can improve the test sufficiency and the test accuracy.
The technical scheme of the present application is described in detail below with specific examples. The following embodiments may be combined with each other, and some embodiments may not be repeated for the same or similar concepts or processes.
Referring to fig. 2, fig. 2 is a schematic flow chart of a code testing method according to an embodiment of the disclosure. The method of the embodiment can be applied to a terminal device or a server, and the code testing method comprises the following steps:
201. executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code.
In this embodiment, the first version code and the second version code may be adjacent version codes, or non-adjacent version codes, as long as the second version code is a code of a version after the first version code, which is not limited in this embodiment. For example, if the first version code is the version 1 code shown in fig. 1, the second version code may be the version 2 code or the version 3 code shown in fig. 1.
Optionally, the second test case is generated in multiple ways.
In one implementation, the corresponding test case may be automatically generated as the second test case according to the second version code based on a single test automatic generation technique.
In another implementation, a first difference code of the second version code that is different from the first version code may be determined; automatically generating a differential test case based on the first differential code; and generating the second test case according to the differential test case and the first test case corresponding to the first version code. For example, the differential test case and the first test case may be directly determined as the second test case.
In yet another implementation, a first difference code of the second version code that is different from the first version code may be determined; automatically generating a differential test case based on the first differential code; determining a second difference code in the first version code, which is different from the second version code; and removing the test case corresponding to the second difference code from the first test case, and adding the difference test case to obtain the second test case.
For example, as shown in fig. 1, a test case 1 corresponding to a version 1 code may be automatically generated according to a version 1 code based on a single test automatic generation technique, a test case 2 corresponding to a subsequent version 2 code may remove a test case corresponding to a code having a difference between the version 1 code and the version 2 code from the test case 1, and a test case having a difference between the version 2 code and the version 1 code may be automatically generated by adding the test case to the test case 1 based on the single test automatic generation technique, thereby obtaining a test case 2, a test case 3 corresponding to a subsequent version 3 code, and a test case N corresponding to an N version code may be generated by referring to the generation method of the test case 2.
202. And executing the second test case through the second version code to obtain a second back test execution result.
203. And comparing the first return execution result with the second return execution result, and generating a return report corresponding to the second version code according to the comparison result, wherein the return report is used for correcting the second version code.
In this embodiment, the first test execution result may include an intermediate product and a final product generated during the execution of the second test case by the first version code. The second loop execution results are similar.
Specifically, after a first return test execution result and a second return test execution result are obtained, the first return test execution result and the second return test execution result may be subjected to differential comparison to obtain a first execution result corresponding to a test case in which execution in both the first version code and the second version code fails, and a second execution result corresponding to a test case in which execution results in the first version code and the second version code are different; and generating a return report corresponding to the second version code according to the first execution result and the second execution result.
As can be seen from the above description, in the embodiment, when testing the second version code, the first version code and the second version code are respectively operated by taking the second test case corresponding to the second version code as input, so that the problem of the new modification code can be found in time, and the testing accuracy and the testing sufficiency can be improved.
In an embodiment of the present disclosure, on the basis of the embodiment of fig. 2, in order to further improve the test accuracy, a regression flow may be combined with a return flow, and this embodiment may further include: executing a first test case through the first version code to obtain a first regression execution result; executing the first test case through the second version code to obtain a second regression execution result; and comparing the first regression execution result with the second regression execution result, and generating a regression report corresponding to the second version code according to the comparison result so as to correct the second version code according to the regression report.
In this embodiment, if the first version code is the initial code of the corresponding branch, the first test case is automatically generated according to the first version code. The method is characterized by comprising the steps of generating the whole code uniformly based on a single-test automatic generation technology before branching, and splitting uniformly generated test cases for different branches.
As can be seen from the above description, the code testing method provided by the embodiments of the present disclosure first solves the problem of insufficient testing. The second version code contains new modification codes (patch codes) which are not contained in the first version code, the first test case generated based on the first version code is difficult to cover (in some cases even impossible to cover) to code logic which is not contained in the first version code, and the problem of insufficient test exists in the second version code when the first test case is used for testing. The present embodiment solves this problem by testing the second version code and the first version code using the second test case.
Second, the problem of problem discovery hysteresis is solved. In problem detection, testing code that is overlaid onto the patch portion is an essential inadequate condition for problem discovery. Therefore, based on the mode of using the test case of the last version code to perform differential test on the last version code and the current version code in the related art, if the problem of the newly submitted code is to be covered and found, the next test on the current version code and the next version code is to be waited. In this embodiment, the second test case is adopted to test the state change of the first version code when the program runs, so that the problem can be found without waiting for the next version code to be generated.
Finally, the problem of Oracle outdated can be solved. One potential assumption that the test automatically generates is that the code version on which it is based is correct and acts as Oracle. From the perspective of developing iterative evolutions, oracle of the first version code may have become outdated relative to the second version code; the second test case generated by using the second version code as the Oracle can make up the inapplicable aspect of the Oracle of the first version code and timely expose the program behavior variation.
In the development process, one issue cycle includes multiple branch Merge Requests (MRs), and one MR has a large number of code versions Commit, and tests are performed based on each version of Commit, so that a large number of test reports are generated accordingly. In order to find problems in time, a large number of manual reading reports are needed to identify the problems, and in order to reduce the labor cost of problem finding, automatic problem identification can be adopted.
Referring to fig. 3, fig. 3 is a second flowchart of a code testing method according to an embodiment of the disclosure. The process of automatic problem identification based on the feedback report is described in detail in this embodiment, and the code testing method includes:
301. Executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code.
302. And executing the second test case through the second version code to obtain a second back test execution result.
303. And comparing the first return execution result with the second return execution result, and generating a return report corresponding to the second version code according to the comparison result, wherein the return report is used for correcting the second version code.
Steps 301 to 303 in this embodiment are similar to steps 201 to 203 in the above embodiment, and will not be repeated here.
304. And analyzing the feedback report to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of tested code units, a plurality of attribution information and corresponding relations among the three.
In this embodiment, the attribution information may include a location where the failure occurs, and a corresponding failure type.
Alternatively, the second identifier of the tested code may be a class name of the tested class, and the identifier of the test case may be a name of the test case, such as test0, test1, test2, and so on.
For example, assuming that the callback report is stored in the package, class test > testName State format, when the callback report is parsed, the test result may be extracted in the package, class test > testName State format, and the attribution information of the test case that fails to run may be collected.
305. And generating a failure test case report according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case report is used for correcting the second version code.
Specifically, after the failure test case identifier, the corresponding tested code identifier and the corresponding attribution information are collected, a failure test case report can be generated based on the three.
To simplify reporting, deduplication may be performed to generate failure test case reports.
In one embodiment of the present disclosure, the generating a report of the failure test case according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information, and the correspondence may include: generating a failure test case record corresponding to the attribution information according to a first identifier corresponding to the attribution information and a second identifier corresponding to the attribution information aiming at each attribution information; and generating a failure test case report according to the failure test case records respectively corresponding to the attribution information.
For example, for a plurality of test cases with identical attribution information and failed execution, a problem can be considered to be exposed, so that attribution information can be used as a primary key, a plurality of test cases can be associated, and a plurality of problems can be reported by a plurality of attribution information, so that the report is more simplified, and the readability is improved.
In an embodiment of the present disclosure, in order to further improve the intelligence of the problem identification based on the embodiment shown in fig. 3, the present embodiment may further include: analyzing the failure test case report, generating a reminding message according to an analysis result, and pushing the reminding message to a target user.
Optionally, in an embodiment of the present disclosure, if the analysis result indicates that the test case in the second test case fails to execute in both the first version code and the second version code, a first exception alert message is generated; the first exception reminding message indicates that a new error is introduced into a corresponding tested code in the second version code; if the analysis result indicates that the test case in the second test case fails to be executed in one version code of the first version code and the second version code, generating a confirmation reminding message; the confirmation reminding message indicates whether the modification of the corresponding tested code in the second test case accords with the expected design or not; and/or if the analysis result indicates that the test case in the first test case fails to be executed in the first version code and is executed successfully in the second version code, generating a repair reminding message; the repair reminding message indicates that the problem of the corresponding tested code in the first version code is repaired; if the analysis result indicates that the test case in the first test case is successfully executed in the first version code and fails to be executed in the second version code, generating a second abnormality reminding message; the second exception prompting message indicates that a new error is introduced into a corresponding tested code in the second version code.
For example, as shown in fig. 4, the test case 1 is run on the version 1 code to obtain a regression execution result 1, the test case 2 is run on the version 2 code to obtain a regression execution result 2, and the test case 2 is run on the version 1 code to obtain a regression execution result 1, and the test case 2 is run on the version 2 code to obtain a regression execution result 2. In parsing the regression report and pushing the message, test cases that pass in version 2 but fail in version 1 may be considered, for example: and (3) pushing the reminding message of successful modification by the test case B. For test cases that do not pass in version 1 in version 2, for example: the test case G may not be pushed, and for a test case that neither version passes, for example: the test case H can push the newly added abnormal problem. When parsing the feedback report and pushing the message, for example, for a test case that passes in version 2 but does not pass in version 1, the following may be adopted: test case F, and for test cases in version 2 that do not pass in version 1, for example: the test case G may push a development engineer to confirm whether the test case meets the expectations, and for the test case that neither version passes, for example: the test case H can push the newly added abnormal problem.
From the description, the report is analyzed, and the failure test cases are automatically summarized, so that the automatic identification of the problems can be realized, the cost of manually reading the report is reduced, and the working efficiency is improved.
In one embodiment of the present disclosure, for the test performed by the regression flow and the return flow simultaneously, the return report and the regression report may be identified simultaneously, and after step 303, may further include: analyzing the return test report and the regression report to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of tested code units, a plurality of attribution information and a corresponding relation among the three; and generating a failure test case report according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case report is used for correcting the second version code. For a specific implementation, reference may be made to the descriptions of step 304 and step 305, which are not repeated here.
According to the continuous integration (Continuous Integration, CI) development flow, the test and problem discovery scenarios can be divided into three dimensions: version Commit dimension, branching MR dimension, issue period dimension. Code changes in three dimensions differ by an order of magnitude (generally, one release cycle includes multiple MRs and one MR includes multiple Commit), and different problem discovery strategies can be formulated according to the three dimensions:
In one embodiment of the present disclosure, for a Commit dimension scenario: identified problems: in one MR development process, each Commit corresponds to the problem of [ new increase ] or [ decrease ], and can support debug. Through problem identification in the Commit dimension, the main roles include: the problem can be intercepted during the MR development process, and whether each code submission meets the expectations can be verified.
Scenes for MR dimensions; reporting range of processing: report of all Commit in the current MR. All problems that occur during this MR development are identified and the problem summary and problem details are presented. The main functions are as follows: the whole problem in MR can be measured and analyzed.
A scenario for the publishing period dimension; reporting range of processing: reporting of all Commit's within the current issue period; and identifying all the problems in the whole release period, and displaying the problem summary and the problem details. The main functions are as follows: the same problem in a plurality of MRs can be effectively eliminated. The overall problem in this development cycle can be measured and analyzed.
Corresponding to the code testing method of the above embodiment, fig. 5 is a block diagram of the code testing apparatus provided by the embodiment of the present disclosure. For ease of illustration, only portions relevant to embodiments of the present disclosure are shown. Referring to fig. 5, the apparatus 50 includes: an execution module 501 and a comparison module 502.
The execution module 501 is configured to execute a second test case corresponding to a second version code through the first version code, to obtain a first test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code and a first test case corresponding to the first version code;
the execution module 501 is further configured to execute the second test case through a second version code to obtain a second test execution result;
and the comparison module 502 is configured to compare the first feedback execution result with the second feedback execution result, and generate a feedback report corresponding to the second version code according to the comparison result, where the feedback report is used to correct the second version code.
In one embodiment of the present disclosure, the execution module 501 is further configured to determine a first difference code in the second version code that is different from the first version code;
automatically generating a differential test case based on the first differential code;
and generating the second test case according to the differential test case and the first test case corresponding to the first version code.
In one embodiment of the present disclosure, execution module 501 is further to: determining a second difference code in the first version code, which is different from the second version code; and removing the test case corresponding to the second difference code from the first test case, and adding the difference test case to obtain the second test case.
In one embodiment of the present disclosure, execution module 501 is further to: executing a first test case through the first version code to obtain a first regression execution result; executing the first test case through the second version code to obtain a second regression execution result; the comparison module 502 is further configured to: and comparing the first regression execution result with the second regression execution result, and generating a regression report corresponding to the second version code according to the comparison result so as to correct the second version code according to the regression report.
In one embodiment of the disclosure, if the first version code is an initial code of a corresponding branch, the first test case is automatically generated according to the first version code.
In one embodiment of the present disclosure, execution module 501 is further to: analyzing the return test report and the regression report to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of tested code units, a plurality of attribution information and a corresponding relation among the three; and generating a failure test case report according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case report is used for correcting the second version code.
In one embodiment of the present disclosure, the execution module 501 is specifically configured to: generating a failure test case record corresponding to the attribution information according to a first identifier corresponding to the attribution information and a second identifier corresponding to the attribution information aiming at each attribution information; and generating a failure test case report according to the failure test case records respectively corresponding to the attribution information.
In one embodiment of the present disclosure, execution module 501 is further to: analyzing the failure test case report, generating a reminding message according to an analysis result, and pushing the reminding message to a target user.
In one embodiment of the present disclosure, the execution module 501 is specifically configured to: if the analysis result indicates that the test case in the second test case fails to be executed in the first version code and the second version code, a first abnormality reminding message is generated; the first exception reminding message indicates that a new error is introduced into a corresponding tested code in the second version code; and/or if the analysis result indicates that the test case in the second test case fails to be executed in one of the first version code and the second version code, generating a confirmation reminding message; the confirmation reminding message indicates whether the modification of the corresponding tested code in the second test case accords with the expected design or not; if the analysis result indicates that the test case in the first test case fails to be executed in the first version code and is executed successfully in the second version code, a repair reminding message is generated; the repair reminding message indicates that the problem of the corresponding tested code in the first version code is repaired; if the analysis result indicates that the test case in the first test case is successfully executed in the first version code and fails to be executed in the second version code, generating a second abnormality reminding message; the second exception prompting message indicates that a new error is introduced into a corresponding tested code in the second version code.
The device provided in this embodiment may be used to execute the technical solution of the foregoing method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
In order to achieve the above embodiments, the embodiments of the present disclosure further provide an electronic device.
Referring to fig. 6, a schematic diagram of a structure of an electronic device 600 suitable for use in implementing embodiments of the present disclosure is shown, the electronic device 600 may be a terminal device or a server. The terminal device may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a personal digital assistant (Personal Digital Assistant, PDA for short), a tablet (Portable Android Device, PAD for short), a portable multimedia player (Portable Media Player, PMP for short), an in-vehicle terminal (e.g., an in-vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 6 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 6, the electronic apparatus 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601 that may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage device 608 into a random access Memory (Random Access Memory, RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a liquid crystal display (Liquid Crystal Display, LCD for short), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer-readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above-described embodiments.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a local area network (Local Area Network, LAN for short) or a wide area network (Wide Area Network, WAN for short), or it may be connected to an external computer (e.g., connected via the internet using an internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. The name of the unit does not in any way constitute a limitation of the unit itself, for example the first acquisition unit may also be described as "unit acquiring at least two internet protocol addresses".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
According to a first aspect, according to one or more embodiments of the present disclosure, there is provided a code testing method, comprising: executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; executing the second test case through a second version code to obtain a second back test execution result; and comparing the first return execution result with the second return execution result, and generating a return report corresponding to the second version code according to the comparison result, wherein the return report is used for correcting the second version code.
According to one or more embodiments of the present disclosure, the method further comprises: determining a first difference code in the second version code, which is different from the first version code; automatically generating a differential test case based on the first differential code; and generating the second test case according to the differential test case and the first test case corresponding to the first version code.
According to one or more embodiments of the present disclosure, the generating the second test case according to the differential test case and the first test case corresponding to the first version code includes: determining a second difference code in the first version code, which is different from the second version code; and removing the test case corresponding to the second difference code from the first test case, and adding the difference test case to obtain the second test case.
According to one or more embodiments of the present disclosure, the method further comprises: executing a first test case through the first version code to obtain a first regression execution result; executing the first test case through the second version code to obtain a second regression execution result; and comparing the first regression execution result with the second regression execution result, and generating a regression report corresponding to the second version code according to the comparison result so as to correct the second version code according to the regression report.
According to one or more embodiments of the present disclosure, if the first version code is an initial code of a corresponding branch, the first test case is automatically generated according to the first version code.
According to one or more embodiments of the present disclosure, the method further comprises: analyzing the return test report and the regression report to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of tested code units, a plurality of attribution information and a corresponding relation among the three; and generating a failure test case report according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case report is used for correcting the second version code.
According to one or more embodiments of the present disclosure, the generating a report of a failure test case according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information, and the correspondence relation includes: generating a failure test case record corresponding to the attribution information according to a first identifier corresponding to the attribution information and a second identifier corresponding to the attribution information aiming at each attribution information; and generating a failure test case report according to the failure test case records respectively corresponding to the attribution information.
According to one or more embodiments of the present disclosure, the method further comprises: analyzing the failure test case report, generating a reminding message according to an analysis result, and pushing the reminding message to a target user.
According to one or more embodiments of the present disclosure, the generating a reminder message according to the parsing result includes: if the analysis result indicates that the test case in the second test case fails to be executed in the first version code and the second version code, a first abnormality reminding message is generated; the first exception reminding message indicates that a new error is introduced into a corresponding tested code in the second version code; and/or if the analysis result indicates that the test case in the second test case fails to be executed in one of the first version code and the second version code, generating a confirmation reminding message; the confirmation reminding message indicates whether the modification of the corresponding tested code in the second test case accords with the expected design or not; if the analysis result indicates that the test case in the first test case fails to be executed in the first version code and is executed successfully in the second version code, a repair reminding message is generated; the repair reminding message indicates that the problem of the corresponding tested code in the first version code is repaired; if the analysis result indicates that the test case in the first test case is successfully executed in the first version code and fails to be executed in the second version code, generating a second abnormality reminding message; the second exception prompting message indicates that a new error is introduced into a corresponding tested code in the second version code.
In a second aspect, according to one or more embodiments of the present disclosure, there is provided a code testing apparatus comprising: the execution module is used for executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code and a first test case corresponding to the first version code; the execution module is further used for executing the second test case through a second version code to obtain a second return test execution result; and the comparison module is used for comparing the first return execution result with the second return execution result, generating a return report corresponding to the second version code according to the comparison result, and correcting the second version code by the return report.
In accordance with one or more embodiments of the present disclosure, the execution module is further to determine a first difference code of the second version code that is different from the first version code;
automatically generating a differential test case based on the first differential code;
and generating the second test case according to the differential test case and the first test case corresponding to the first version code.
According to one or more embodiments of the present disclosure, the execution module is further to: determining a second difference code in the first version code, which is different from the second version code; and removing the test case corresponding to the second difference code from the first test case, and adding the difference test case to obtain the second test case.
According to one or more embodiments of the present disclosure, the execution module is further to: executing a first test case through the first version code to obtain a first regression execution result; executing the first test case through the second version code to obtain a second regression execution result; the comparison module is also used for: and comparing the first regression execution result with the second regression execution result, and generating a regression report corresponding to the second version code according to the comparison result so as to correct the second version code according to the regression report.
According to one or more embodiments of the present disclosure, if the first version code is an initial code of a corresponding branch, the first test case is automatically generated according to the first version code.
According to one or more embodiments of the present disclosure, the execution module is further to: analyzing the return test report and the regression report to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of tested code units, a plurality of attribution information and a corresponding relation among the three; and generating a failure test case report according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case report is used for correcting the second version code.
According to one or more embodiments of the present disclosure, the execution module is specifically configured to: generating a failure test case record corresponding to the attribution information according to a first identifier corresponding to the attribution information and a second identifier corresponding to the attribution information aiming at each attribution information; and generating a failure test case report according to the failure test case records respectively corresponding to the attribution information.
According to one or more embodiments of the present disclosure, the execution module is further to: analyzing the failure test case report, generating a reminding message according to an analysis result, and pushing the reminding message to a target user.
According to one or more embodiments of the present disclosure, the execution module is specifically configured to: if the analysis result indicates that the test case in the second test case fails to be executed in the first version code and the second version code, a first abnormality reminding message is generated; the first exception reminding message indicates that a new error is introduced into a corresponding tested code in the second version code; and/or if the analysis result indicates that the test case in the second test case fails to be executed in one of the first version code and the second version code, generating a confirmation reminding message; the confirmation reminding message indicates whether the modification of the corresponding tested code in the second test case accords with the expected design or not; if the analysis result indicates that the test case in the first test case fails to be executed in the first version code and is executed successfully in the second version code, a repair reminding message is generated; the repair reminding message indicates that the problem of the corresponding tested code in the first version code is repaired; if the analysis result indicates that the test case in the first test case is successfully executed in the first version code and fails to be executed in the second version code, generating a second abnormality reminding message; the second exception prompting message indicates that a new error is introduced into a corresponding tested code in the second version code.
In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes the computer-executable instructions stored by the memory to cause the at least one processor to perform the code testing method as described above in the first aspect and the various possible designs of the first aspect.
In a fourth aspect, according to one or more embodiments of the present disclosure, there is provided a computer-readable storage medium having stored therein computer-executable instructions which, when executed by a processor, implement the code testing method of the first aspect and the various possible designs of the first aspect as described above.
In a fifth aspect, according to one or more embodiments of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the code testing method according to the first aspect and the various possible designs of the first aspect as described above
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (13)

1. A code testing method, comprising:
executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code;
Executing the second test case through a second version code to obtain a second back test execution result;
and comparing the first return execution result with the second return execution result, and generating a return result corresponding to the second version code according to the comparison result, wherein the return result is used for correcting the second version code.
2. The method according to claim 1, wherein the method further comprises:
determining a first difference code in the second version code, which is different from the first version code;
automatically generating a differential test case based on the first differential code;
and generating the second test case according to the differential test case and the first test case corresponding to the first version code.
3. The method of claim 2, wherein the generating the second test case from the differential test case and the first test case corresponding to the first version code comprises:
determining a second difference code in the first version code, which is different from the second version code;
and removing the test case corresponding to the second difference code from the first test case, and adding the difference test case to obtain the second test case.
4. A method according to any one of claims 1-3, wherein the method further comprises:
executing a first test case through the first version code to obtain a first regression execution result;
executing the first test case through the second version code to obtain a second regression execution result;
and comparing the first regression execution result with the second regression execution result, and generating a regression result corresponding to the second version code according to the comparison result, wherein the regression result is used for correcting the second version code.
5. The method of claim 4, wherein the first test case is automatically generated based on the first version code if the first version code is an initial code of a corresponding branch.
6. The method according to claim 4, wherein the method further comprises:
analyzing the return test result and the regression result to obtain first identifiers of a plurality of target test cases with failed execution, second identifiers of a plurality of code units to be tested, a plurality of attribution information and a corresponding relation among the three;
and generating a failure test case result according to the plurality of first identifiers, the plurality of second identifiers, the plurality of attribution information and the corresponding relation, wherein the failure test case result is used for correcting the second version code.
7. The method of claim 6, wherein generating a failure test case result from the plurality of first identifications, the plurality of second identifications, the plurality of attribution information, and the correspondence relation comprises:
generating a failure test case record corresponding to the attribution information according to a first identifier corresponding to the attribution information and a second identifier corresponding to the attribution information aiming at each attribution information;
and generating a failure test case result according to the failure test case records respectively corresponding to the attribution information.
8. The method of claim 6, wherein the method further comprises:
analyzing the failure test case result, generating a reminding message according to the analysis result, and pushing the reminding message to a target user.
9. The method of claim 6, wherein generating the alert message based on the parsing result comprises:
if the analysis result indicates that the test case in the second test case fails to be executed in the first version code and the second version code, a preset abnormality reminding message is generated; the preset abnormity reminding message indicates that a new error is introduced into a corresponding tested code in the second version code; and/or
If the analysis result indicates that the test case in the second test case fails to be executed in one version code of the first version code and the second version code, generating a confirmation reminding message; and the confirmation reminding message indicates whether the modification of the corresponding tested code in the second test case accords with the expected design or not.
10. A code testing apparatus, comprising:
the execution module is used for executing a second test case corresponding to the second version code through the first version code to obtain a first return test execution result; the first version code is a code of a previous version of the second version code; the second test case is generated according to the second version code and a first test case corresponding to the first version code;
the execution module is further used for executing the second test case through a second version code to obtain a second return test execution result;
and the comparison module is used for comparing the first return execution result with the second return execution result, generating a return result corresponding to the second version code according to the comparison result, and correcting the second version code by the return result.
11. An electronic device, comprising: a processor and a memory;
the memory stores computer-executable instructions;
the processor executing computer-executable instructions stored in the memory, causing the processor to perform the code testing method of any one of claims 1 to 9.
12. A computer readable storage medium having stored therein computer executable instructions which, when executed by a processor, implement the code testing method of any of claims 1 to 9.
13. A computer program product comprising a computer program which, when executed by a processor, implements the method of code testing according to any one of claims 1 to 9.
CN202210771474.0A 2022-06-30 2022-06-30 Code testing method and device Pending CN117370142A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210771474.0A CN117370142A (en) 2022-06-30 2022-06-30 Code testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210771474.0A CN117370142A (en) 2022-06-30 2022-06-30 Code testing method and device

Publications (1)

Publication Number Publication Date
CN117370142A true CN117370142A (en) 2024-01-09

Family

ID=89406531

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210771474.0A Pending CN117370142A (en) 2022-06-30 2022-06-30 Code testing method and device

Country Status (1)

Country Link
CN (1) CN117370142A (en)

Similar Documents

Publication Publication Date Title
US9152731B2 (en) Detecting a broken point in a web application automatic test case
US20150007148A1 (en) Identifying Test Cases Based on Changed Test Code
CN112650685B (en) Automatic test method, device, electronic equipment and computer storage medium
CN103294563B (en) A kind of method and system installation unit being carried out to version conflict inspection
AU2016250350A1 (en) Orchestrating and providing a regression test
CN110674047B (en) Software testing method and device and electronic equipment
CN112131116B (en) Automatic regression testing method for embedded software
CN107562419B (en) Software development support method and system
JP2015011372A (en) Debug support system, method, program, and recording medium
US9779014B2 (en) Resilient mock object creation for unit testing
CN111597069A (en) Program processing method, program processing apparatus, electronic device, and storage medium
CN116225886A (en) Test case generation method, device, equipment, storage medium and program product
CN111506904B (en) Method and device for online bug repair
CN117370142A (en) Code testing method and device
CN112882921B (en) Fault simulation method and device
CN109960659B (en) Method and device for detecting application program
CN111382057A (en) Test case generation method, test method and device, server and storage medium
CN117827626A (en) Test method, test device, test apparatus, test program, and test program
CN114546816B (en) Test method, platform, device, electronic equipment and storage medium
CN115543227B (en) Cross-system data migration method, system, electronic device and storage medium
CN113806229B (en) Test script multiplexing method, device, equipment, medium and product for interface change
CN116501634A (en) Test case management method, device, medium and electronic equipment
CN115858329A (en) Interactive component testing method and device, electronic equipment and storage medium
CN117609077A (en) Method and device for rechecking configuration parameters, electronic equipment and storage medium
CN114327475A (en) Function duplicate name checking method, device, equipment, readable storage medium and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination