CN111782516A - Code testing method and device and storage medium - Google Patents

Code testing method and device and storage medium Download PDF

Info

Publication number
CN111782516A
CN111782516A CN202010592585.6A CN202010592585A CN111782516A CN 111782516 A CN111782516 A CN 111782516A CN 202010592585 A CN202010592585 A CN 202010592585A CN 111782516 A CN111782516 A CN 111782516A
Authority
CN
China
Prior art keywords
code
test case
change
tested
historical
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
CN202010592585.6A
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.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp 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 Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202010592585.6A priority Critical patent/CN111782516A/en
Publication of CN111782516A publication Critical patent/CN111782516A/en
Pending legal-status Critical Current

Links

Images

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/3676Test management for coverage analysis
    • 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

Abstract

The embodiment of the application provides a code testing method, a device and a storage medium, wherein the method comprises the following steps: acquiring a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged; adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules; and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.

Description

Code testing method and device and storage medium
Technical Field
The present application relates to the field of software testing, and in particular, to a code testing method and apparatus, and a storage medium.
Background
The test case scientifically organizes and summarizes the behavior activities of the software test, and aims to convert the behavior of the software test into a manageable mode. Meanwhile, the test case is also one of the methods for specifically quantifying the test. In the construction process of the software test case, after information is provided by mostly based on a project group or research and development personnel, a test range is selected by the experience of test experts, and the test coverage rate cannot be verified, so that the construction of the test case is unreasonable, and the problems of incomplete test case coverage and low code test accuracy are caused.
Disclosure of Invention
The embodiment of the application provides a code testing method and device and a storage medium, so that test cases can be covered comprehensively, and the code testing accuracy is further improved.
The technical scheme of the application is realized as follows:
the application provides a code testing method, which comprises the following steps:
acquiring a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged;
adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules;
and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.
The application provides a code testing device, the code testing device includes:
the acquisition unit is used for acquiring a code to be tested;
the determining unit is used for determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged;
the adjusting unit is used for adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules;
and the selecting unit is used for selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.
The application provides a code testing device, the code testing device includes: a processor, a memory, and a communication bus; the processor, when executing the operating program stored in the memory, implements the method of any of the above.
The present application provides a storage medium having stored thereon a computer program which, when executed by a processor, implements a method as in any one of the above.
The embodiment of the application provides a code testing method, a device and a storage medium, wherein the method comprises the following steps: acquiring a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged; adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules; and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case. By adopting the implementation scheme, the code testing device generates the association rule between the historical test case and the historical code for the historical test case and the historical code which meet the preset code test coverage rate, and when the code test case determines the change code and the change type in the code to be tested, the code testing device selects the first test case corresponding to the change code based on the association rule, so that the corresponding test case can be automatically selected when the code changes, and the test case can be reasonably constructed, so that the test case coverage is more comprehensive, and the code testing accuracy is improved.
Drawings
FIG. 1 is a system architecture diagram of an exemplary code testing device;
FIG. 2 is an exemplary correlation diagram of test cases and code;
FIG. 3 is an exemplary correlation diagram of test cases and code after code modification;
FIG. 4 is a first flowchart of a code testing method according to an embodiment of the present disclosure;
fig. 5 is a schematic flowchart illustrating a code testing apparatus according to an embodiment of the present application, where association rules between historical test cases and historical codes are established;
fig. 6 is a schematic diagram of an exemplary selected test case provided in an embodiment of the present application;
FIG. 7 is a first diagram illustrating an exemplary association rule between a test case and code according to an embodiment of the present application;
FIG. 8 is a second diagram illustrating an exemplary association rule between a test case and code according to an embodiment of the present application;
fig. 9 is a schematic flowchart illustrating a process of implementing test case selection by an exemplary code testing apparatus according to an embodiment of the present application;
FIG. 10 is a system architecture diagram of an exemplary code testing device provided by an embodiment of the present application;
fig. 11 is a first schematic structural diagram of a code testing apparatus according to an embodiment of the present disclosure;
fig. 12 is a schematic structural diagram of a code testing apparatus according to an embodiment of the present application.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the present application. And are not intended to limit the present application.
The test range of the existing software test is determined by a test expert based on a test case system and a Bug system, as shown in fig. 1, the test coverage rate determined by the existing test range has the problem that scientific verification cannot be performed, the existing test range may cause the problem of missing test or multiple tests, for example, as shown in fig. 2, a test case a is used for testing a code 1, a test case B is used for testing a code 2, a test case C is used for testing a code 3, the code coverage rate corresponding to fig. 2 is 5%, when a code 4, a code 5 and a code 3 are added and the code 2 is modified, as shown in fig. 3, a test case D is added and a test case E is added and the test case C is deleted, however, for a test case which is not covered by the newly added code 5, and after the code 2 is modified, the code 2 does not correspondingly modify the corresponding test case B, at this time, the code 5 and the code 2 are missed, and a test case E without code coverage appears, and at this time, the code coverage rate corresponding to fig. 3 is 4%, so that the test case can be selected by the existing test expert means, and the corresponding test case can not be accurately adjusted when the code is added, modified or deleted, so that the code coverage rate can not be scientifically verified.
The present application is proposed to solve the above problems, and is specifically discussed by the following embodiments.
Example one
An embodiment of the present application provides a code testing method, as shown in fig. 4, the method may include:
s101, obtaining a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged.
The code testing method provided by the embodiment of the application is suitable for a scene of selecting the test case to perform code testing on the source code in the software program.
In the embodiment of the application, a tester inputs a code to be tested into a code testing device, the code testing device obtains the code to be tested and judges whether the code to be tested changes, and under the condition that the code to be tested changes, the change code and the change type in the code to be tested are determined. Specifically, the code testing device comprises a code comparison model, the code testing device determines a first historical code based on a code to be tested, wherein the version of the first historical code is lower than that of the code to be tested, when the code testing device finds the first historical code, the code to be tested and the first historical code are input into the code comparison model, and the code comparison model is used for comparing the code to be tested with the first historical code to obtain a change code and a change type corresponding to the change code.
In practical application, when a software version is upgraded or a developer modifies a code according to Bug submitted by a tester, operations of adding a code, modifying the code, deleting the code and/or merging the code are generated, and at the moment, the code to be tested is changed.
In the embodiment of the present application, the variation types include: the method includes deleting a code and deleting a non-code, wherein the non-deleted code includes at least one of a newly added code, a modified code and a combined code, and is specifically selected according to an actual situation, and the embodiment of the application is not specifically limited.
Optionally, the code comparison model may be: WinMerge, Diffuse, Beyou Complex, AltovaDiffDog, AptDiff, Code Complex and the like, which are specifically selected according to actual conditions, and the embodiment of the application is not specifically limited.
Further, under the condition that it is determined that the code to be tested has not changed, the code testing apparatus establishes an association rule between the historical test case and the historical code, specifically, as shown in fig. 5:
s201, under the condition that the code to be tested is judged not to be changed, an initial test case corresponding to the code to be tested is obtained.
In the embodiment of the application, under the condition that the code to be tested is judged not to be changed, a tester firstly selects an initial test case for the code to be tested manually, and inputs the code to be tested and the corresponding initial test case into a code testing device, and at the moment, the code testing device obtains the code to be tested and the initial test case corresponding to the code to be tested.
S202, adjusting the initial test case based on the preset code test coverage rate to obtain the adjusted initial test case.
After the code testing device obtains the initial test case corresponding to the code to be tested, the code testing device adjusts the initial test case based on the preset code testing coverage rate to obtain the adjusted initial test case.
In the embodiment of the application, a preset code test coverage rate is preset and is used as a standard for adjusting the initial test case, the code test device adjusts the initial test case according to the preset code test coverage rate, and the adjustment of the initial test case is stopped until the adjusted initial test case meets the preset code test coverage rate.
In the embodiment of the present application, the adjusting of the initial test case may include deleting the test case and adding a new test case, which is specifically selected according to an actual situation, and the embodiment of the present application is not specifically limited.
In the embodiment of the application, a code coverage rate tool is arranged in a code testing device, a code to be tested and an initial test case are input into the code coverage rate tool, the code coverage rate tool determines a code covered by the initial test case according to the initial test case, a change code testing coverage rate is determined according to the code covered by the initial test case and the code to be tested, then the change code testing coverage rate is compared with a preset code testing coverage rate, the initial test case is adjusted under the condition that the change code testing coverage rate is smaller than the preset code testing coverage rate, and the adjusting operation is stopped until the code covered by the adjusted initial test case is larger than or equal to the preset code testing coverage rate.
Illustratively, the code is displayed on the display interface of the code coverage tool, and the code covered by the test cases is highlighted, assuming that the preset code test coverage is 90%, as shown in fig. 6, the initial test cases are TC _ Func _ Project _ Photos _0010 and TC _ Func _ Project _ Photos _0020, wherein the detection points corresponding to TC _ Func _ Project _ Photos _0010 are Photos certification, the detection points corresponding to TC _ Func _ Project _ Photos _0020 are photo deletion, the code test coverage corresponding to the initial test case measured by the code coverage tool is 40%, the detection points corresponding to test cases TC _ Func _ Project _ Photos _0011 and TC _ Func _ Project _ Photos _0021 are photo addition, the detection points corresponding to TC _ Func _ Project _ Photos _0011 are photo addition, and the detection points corresponding to test cases are still added to the test cases TC _ Func _ Project _ Photos _0021, and the test cases are still added to the detection points of the test cases are added to be photo deletion, and the test cases are added to the test cases of TC _ Func _ Project _, representing that the newly added test case does not improve the code test coverage, deleting the newly added test case TC _ Func _ Project _ Photos _0011 and TC _ Func _ Project _ Photos _0021, re-selecting the test case from the test case library, when the newly added codes TC _ Func _ Project _ Photos _0030, TC _ Func _ Project _ Photos _0040, TC _ Func _ Project _ Photos _0050 and TC _ Func _ Project _ FaceUnlock _0010 are used, the detection point corresponding to TC _ Func _ Project _ Photos _0030 is photo edited, the detection point corresponding to TC _ Func _ Project _ Photos _0040 is a More menu, and the detection point corresponding to TC _ Func _ Project _ Photos _0050 is a check point corresponding to the photo edited, and the detection point corresponding to TC _ Func _ Project _ Photos _0 is adjusted to be selected as a detection point corresponding to be a More menu, and the sharing rate of the test case is adjusted to be added when the test coverage of the detection point is detected, and the test case sharing rate is up to the sharing test case is up to the test case.
S203, machine learning is carried out on the code to be tested and the adjusted initial test case, and an association rule is established.
And after the code testing device obtains the adjusted initial test case which meets the preset code testing coverage rate, the code testing device performs machine learning on the code to be tested and the adjusted initial test case, and establishes an association rule.
In the embodiment of the application, machine learning or data mining is performed on the code to be tested and the adjusted initial test case, and an association rule between the adjusted initial test case and the code to be tested is determined, wherein the association rule comprises support degree and confidence degree. It should be noted that the code to be tested and the adjusted initial test case are used as the historical test case and the historical code during the next code test, and then the verification of the changed code and the selection process of the test case are performed on the code input in the next code test.
Fig. 7 is an exemplary association rule between a test case and a code, where the association rule between the test case and the code includes four columns of association rule, code, test case, and operation type, and when the association rule between the test case and the code is initially established, the three columns of association rule, code, and test case are filled according to the adjusted initial test case and the code to be tested. FIG. 7 includes two association rules, where the test case field of association rule 1 is filled in 1, and the code field of association rule 1 is filled in 25; test case field 2 of association rule 2 is filled in, and code field 22 of association rule 2 is filled in.
It can be understood that when a test range is defined at the beginning stage of a project, association rules between test cases and codes can be established according to machine learning or big data mining, and then the test cases are intelligently selected, so that the test cases reach the preset code test coverage rate.
S102, adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules.
After the code testing device finds the change codes in the codes to be tested and the change types corresponding to the change codes, the code testing device adjusts association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules.
In the embodiment of the application, the code coverage rate of the historical test case in the association rule meets the preset code test coverage rate, and the version of the historical code in the association rule is lower than that of the code to be tested.
In the embodiment of the application, machine learning is performed on the change type and the change code, and the change type and the change code are updated into the association rule to obtain the first association rule.
Illustratively, as shown in fig. 8, when a code C is added, an association rule 3 is added to the association rules, C is filled in a code field of the association rule 3, and the addition is filled in an operation type field of the association rule 3. When the code 19 is modified, the association rule 1 corresponding to the code 19 is searched in the association rule, the code field of the association rule 1 is updated to 19, and the modification is filled in the operation type field of the association rule 1.
S103, selecting a first test case corresponding to the change code based on the first association rule, and realizing a code test process of the code to be tested based on the first test case and the historical test case.
And when the code testing device tests the code of the code to be tested, the code testing device tests the code of the code to be tested based on the first test case and the historical test case.
In the embodiment of the application, based on a first association rule, a first test case corresponding to a change code is selected to be divided into two scenes, wherein the first scene is a test case which is associated with the change code and is searched from the first association rule under the condition that the change type is code deletion; determining the test case associated with the change code as a first test case; the second scenario is that under the condition that the change type is non-code deletion, a first test case corresponding to the change code is selected from a preset test case library.
Further, after a first test case corresponding to the change code is selected based on the first association rule, the historical test case in the first association rule is updated by using the first test case and the change type to obtain an updated historical test case, and the updated historical test case is adjusted based on the preset code test coverage rate to obtain an adjusted historical test case; on one hand, the code to be tested is tested by utilizing the adjusted historical test case, so that the code testing process of the code to be tested is realized based on the first test case and the historical test case; on the other hand, machine learning is carried out on the code to be tested and the adjusted historical test case, and an association rule between the code to be tested and the adjusted historical test case is established.
Specifically, under the condition that the change type is code deletion, deleting a first test case in the first association rule; and under the condition that the change type is non-code deletion, determining a test case field corresponding to the code to be tested in the first association rule, and updating the first test case to the test case field corresponding to the code to be tested. Exemplarily, under the condition that the change type is the newly added code, adding a first test case into a test case field corresponding to the code to be tested; and under the condition that the change type is the modified code, searching a test case associated with the code to be tested from the association rule, and updating the test case associated with the code to be tested by using the first test case.
In practical application, a flow chart of a test case selection flow realized by a code testing device is shown in fig. 9, 1, a code to be tested and a test case corresponding to the code to be tested are obtained;
2. judging whether the code to be tested has code change or not;
3. under the condition that the code change of the code to be tested is judged, determining a change code and a change type in the code to be tested by using a code comparison tool;
4. performing machine learning on the change codes and the change types, and updating the change codes and the change types into association rules between historical test cases and historical codes to obtain first association rules;
5. selecting a test case for the change code by using a first association rule, and executing 1;
6. under the condition that the code to be tested is judged not to be changed, a code coverage rate tool is utilized to carry out code coverage rate detection on the test case, and the code coverage rate corresponding to the test case is obtained;
7. comparing the code coverage rate corresponding to the test case with a preset code coverage rate;
8. under the condition that the code coverage rate corresponding to the test case is greater than or equal to the preset code coverage rate, machine learning is carried out on the test case and the code to obtain an association rule, code testing is carried out on the code by using the test case, and a test result is output;
9. and under the condition that the code coverage rate corresponding to the test case is smaller than the preset code coverage rate, updating the test case to obtain an updated test case, and executing the step 1.
In practical application, corresponding to the code testing flow of fig. 9, a system architecture schematic diagram of the code testing apparatus is shown in fig. 10, and a testing range of a code is determined by a test case system, a Bug system, a code coverage rate tool, and a code comparison tool, where the test case in the testing range needs to satisfy a preset code coverage rate, and the test case and the code are subjected to machine learning under the condition that the test case in the testing range satisfies the preset code coverage rate, so as to obtain an association rule between the test case and the code; under the condition that the test cases in the test range do not meet the preset code coverage rate, determining the change codes by using a code comparison tool, and intelligently selecting the test cases corresponding to the change codes from a test case library by using machine learning; the test range of the code is determined by the test case system, the Bug system and the code coverage rate tool in the process of defining the test range at the beginning of the project, and the test range of the code is determined by the test case system, the Bug system, the code coverage rate tool and the code comparison tool in the process of modifying the Bug or upgrading the software version.
The code testing device generates an association rule between the historical test case and the historical code for the historical test case and the historical code which meet the preset code testing coverage rate, and when the code test case determines the change code and the change type in the code to be tested, the code testing device selects the first test case corresponding to the change code based on the association rule, so that the corresponding test case can be automatically selected when the code changes, and the test case can be reasonably constructed, so that the test case coverage is more comprehensive, and the code testing accuracy is improved.
Example two
The embodiment of the application provides a code testing device 1. As shown in fig. 11, the code testing apparatus 1 includes:
an obtaining unit 10, configured to obtain a code to be tested;
the determining unit 11 is configured to determine a change code in the code to be tested and a change type corresponding to the change code under the condition that it is determined that the code to be tested changes;
the adjusting unit 12 is configured to adjust association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules;
and the selecting unit 13 is configured to select a first test case corresponding to the change code based on the first association rule, so as to implement a code test process of the code to be tested based on the first test case and the historical test case.
Optionally, the apparatus further comprises: a code comparing unit;
the determining unit 11 is further configured to determine a first history code based on the code to be tested;
the code comparison unit is used for comparing the code to be tested with the first historical code by using a code comparison model to obtain the change code and the change type.
Optionally, the apparatus further comprises: a machine learning unit;
the machine learning unit is configured to perform machine learning on the change type and the change code, and update the change type and the change code to the association rule to obtain the first association rule.
Optionally, the determining unit 11 is further configured to, when the change type is a code deletion, search a test case associated with the change code from the first association rule; determining a test case associated with the change code as the first test case;
the selecting unit 13 is further configured to select the first test case corresponding to the change code from a preset test case library when the change type is non-code deletion.
Optionally, the apparatus further comprises: an updating unit and a code testing unit;
the updating unit is configured to update the historical test case in the first association rule by using the first test case and the change type, so as to obtain an updated historical test case;
the adjusting unit 12 is further configured to adjust the updated historical test case based on a preset code test coverage rate to obtain an adjusted historical test case
And the code testing unit is used for performing code testing on the code to be tested by utilizing the adjusted historical test case.
Optionally, the obtaining unit 10 is further configured to obtain an initial test case corresponding to the code to be tested, when it is determined that the code to be tested has not changed;
the adjusting unit 12 is further configured to adjust the initial test case based on the preset code test coverage to obtain an adjusted initial test case;
the machine learning unit is further configured to perform machine learning on the code to be tested and the adjusted initial test case, and establish the association rule.
Optionally, the non-code deletion includes: at least one of the new code, the modified code, and the merged code.
Optionally, the code coverage of the historical test case meets a preset code test coverage, and the version of the historical code is lower than that of the code to be tested.
The code testing device provided by the embodiment of the application obtains a code to be tested, and determines a change code in the code to be tested and a change type corresponding to the change code under the condition that the code to be tested is judged to be changed; adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules; and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case. Therefore, according to the code testing device provided by the embodiment, the code testing device generates the association rule between the historical test case and the historical code for the historical test case and the historical code which meet the preset code testing coverage rate, and when the code testing case determines the change code and the change type in the code to be tested, the code testing device selects the first test case corresponding to the change code based on the association rule, so that the corresponding test case can be automatically selected when the code changes, and the test case can be reasonably constructed, so that the test case coverage is more comprehensive, and the code testing accuracy is improved.
Fig. 12 is a schematic diagram of a composition structure of a code testing apparatus 1 according to an embodiment of the present application, and in practical applications, based on the same disclosure concept of the foregoing embodiment, as shown in fig. 12, the code testing apparatus 1 according to the present embodiment includes: a processor 14, a memory 15, and a communication bus 16.
In a specific embodiment, the obtaining unit 10, the determining unit 11, the adjusting unit 12, the selecting unit 13, the code comparing unit, the machine learning unit, the updating unit and the code testing unit may be implemented by a Processor 14 located on the code testing apparatus 1, and the Processor 14 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic image Processing Device (PLD), a Field Programmable Gate Array (FPGA), a CPU, a controller, a microcontroller and a microprocessor. It is understood that the electronic device for implementing the above-mentioned processor function may be other devices, and the embodiment is not limited in particular.
In the embodiment of the present application, the communication bus 16 is used for realizing connection communication between the processor 14 and the memory 15; the processor 14 implements the following code testing method when executing the execution program stored in the memory 15:
acquiring a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged; adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules; and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.
In the above embodiment, the processor 14 is further configured to determine a first history code based on the code to be tested; and comparing the codes to be tested with the first historical codes by using a code comparison model to obtain the change codes and the change types.
In the above embodiment, the processor 14 is further configured to perform machine learning on the change type and the change code, and update the change type and the change code into the association rule, so as to obtain the first association rule.
In the above embodiment, the processor 14 is further configured to, when the change type is a code deletion, search a test case associated with the change code from the first association rule; determining a test case associated with the change code as the first test case; and under the condition that the change type is non-code deletion, selecting the first test case corresponding to the change code from a preset test case library.
In the above embodiment, the processor 14 is further configured to update the historical test case in the first association rule by using the first test case and the change type, so as to obtain an updated historical test case; adjusting the updated historical test case based on a preset code test coverage rate to obtain an adjusted historical test case; and performing code testing on the code to be tested by using the adjusted historical test case.
In the above embodiment, the processor 14 is further configured to obtain an initial test case corresponding to the code to be tested, when it is determined that the code to be tested has not changed; adjusting the initial test case based on the preset code test coverage rate to obtain an adjusted initial test case; and performing machine learning on the code to be tested and the adjusted initial test case, and establishing the association rule.
In the above embodiment, the non-code deletion includes: at least one of the new code, the modified code, and the merged code.
In the above embodiment, the code coverage of the historical test case meets a preset code test coverage, and the version of the historical code is lower than that of the code to be tested.
The embodiment of the application provides a storage medium, on which a computer program is stored, and the computer readable storage medium stores one or more programs, which can be executed by one or more processors and applied to a code testing device, and the computer program implements the code testing method.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling an image display device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present disclosure.
The above description is only a preferred embodiment of the present application, and is not intended to limit the scope of the present application.

Claims (11)

1. A method for code testing, the method comprising:
acquiring a code to be tested, and determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged;
adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules;
and selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.
2. The method of claim 1, wherein said determining a change code and a change type in said code to be tested comprises:
determining a first history code based on the code to be tested;
and comparing the codes to be tested with the first historical codes by using a code comparison model to obtain the change codes and the change types.
3. The method of claim 1, wherein the adjusting association rules between historical test cases and historical codes using the change codes and the change types to obtain first association rules comprises:
and performing machine learning on the change type and the change code, and updating the change type and the change code into the association rule to obtain the first association rule.
4. The method according to claim 3, wherein selecting the first test case corresponding to the change code based on the first association rule comprises:
under the condition that the change type is code deletion, searching a test case associated with the change code from the first association rule; determining a test case associated with the change code as the first test case;
and under the condition that the change type is non-code deletion, selecting the first test case corresponding to the change code from a preset test case library.
5. The method according to claim 3, wherein after the selecting the first test case corresponding to the change code based on the first association rule, the method further comprises:
updating the historical test case in the first association rule by using the first test case and the change type to obtain an updated historical test case;
adjusting the updated historical test case based on a preset code test coverage rate to obtain an adjusted historical test case;
and performing code testing on the code to be tested by using the adjusted historical test case.
6. The method of claim 1, wherein after obtaining the code to be tested, the method further comprises:
under the condition that the code to be tested is judged not to be changed, obtaining an initial test case corresponding to the code to be tested;
adjusting the initial test case based on the preset code test coverage rate to obtain an adjusted initial test case;
and performing machine learning on the code to be tested and the adjusted initial test case, and establishing the association rule.
7. The method of any of claims 1-6, wherein the non-code deletion comprises: at least one of the new code, the modified code, and the merged code.
8. The method of claim 1, wherein the code coverage of the historical test case meets a preset code test coverage, and wherein the version of the historical code is lower than the version of the code to be tested.
9. A code testing apparatus, characterized in that the code testing apparatus comprises:
the acquisition unit is used for acquiring a code to be tested;
the determining unit is used for determining a change code in the code to be tested and a change type corresponding to the change code under the condition that the code change of the code to be tested is judged;
the adjusting unit is used for adjusting association rules between the historical test cases and the historical codes by using the change codes and the change types to obtain first association rules;
and the selecting unit is used for selecting a first test case corresponding to the change code based on the first association rule so as to realize a code test process of the code to be tested based on the first test case and the historical test case.
10. A code testing apparatus, characterized in that the code testing apparatus comprises: a processor, a memory, and a communication bus; the processor, when executing the execution program stored in the memory, implements the method of any of claims 1-8.
11. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 8.
CN202010592585.6A 2020-06-24 2020-06-24 Code testing method and device and storage medium Pending CN111782516A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010592585.6A CN111782516A (en) 2020-06-24 2020-06-24 Code testing method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010592585.6A CN111782516A (en) 2020-06-24 2020-06-24 Code testing method and device and storage medium

Publications (1)

Publication Number Publication Date
CN111782516A true CN111782516A (en) 2020-10-16

Family

ID=72759805

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010592585.6A Pending CN111782516A (en) 2020-06-24 2020-06-24 Code testing method and device and storage medium

Country Status (1)

Country Link
CN (1) CN111782516A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568839A (en) * 2021-08-03 2021-10-29 京东科技控股股份有限公司 Method, device, equipment and medium for software testing and statistical test coverage rate
CN117290253A (en) * 2023-11-23 2023-12-26 苏州元脑智能科技有限公司 Code testing method, device, communication equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140245264A1 (en) * 2013-02-28 2014-08-28 International Business Machines Corporation Identifying Test Cases Based on Changed Test Code
CN110413506A (en) * 2019-06-19 2019-11-05 平安普惠企业管理有限公司 Test case recommended method, device, equipment and storage medium
CN110941555A (en) * 2019-11-26 2020-03-31 广州品唯软件有限公司 Test case recommendation method and device, computer equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140245264A1 (en) * 2013-02-28 2014-08-28 International Business Machines Corporation Identifying Test Cases Based on Changed Test Code
CN110413506A (en) * 2019-06-19 2019-11-05 平安普惠企业管理有限公司 Test case recommended method, device, equipment and storage medium
CN110941555A (en) * 2019-11-26 2020-03-31 广州品唯软件有限公司 Test case recommendation method and device, computer equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113568839A (en) * 2021-08-03 2021-10-29 京东科技控股股份有限公司 Method, device, equipment and medium for software testing and statistical test coverage rate
CN117290253A (en) * 2023-11-23 2023-12-26 苏州元脑智能科技有限公司 Code testing method, device, communication equipment and storage medium
CN117290253B (en) * 2023-11-23 2024-03-01 苏州元脑智能科技有限公司 Code testing method, device, communication equipment and storage medium

Similar Documents

Publication Publication Date Title
US9152521B2 (en) Systems and methods for testing content of mobile communication devices
US9990209B2 (en) Digital assistance device for facilitating multi-stage setup
CN107807841B (en) Server simulation method, device, equipment and readable storage medium
CN110502415B (en) Buried point setting method, device and equipment
CN110633205A (en) Method and device for detecting embedded point event, terminal equipment and medium
CN111782516A (en) Code testing method and device and storage medium
US20140033123A1 (en) User interface and method for comparing a local version of a profile to an online update
CN112052169A (en) Test management method, system, device and computer readable storage medium
CN113254331A (en) Model test method, device, storage medium and program product
CN111538523A (en) Differential upgrading method, device and storage medium
CN107341106B (en) Application compatibility detection method, development terminal and storage medium
US11422917B2 (en) Deriving software application dependency trees for white-box testing
CN115576600A (en) Code change-based difference processing method and device, terminal and storage medium
CN109032617B (en) Control method and control device for automatically deleting installation package
CN113138768A (en) Application package generation method and device, electronic equipment and readable storage medium
CN110348226B (en) Engineering file scanning method and device, electronic equipment and storage medium
CN112543104A (en) Application program packaging method and device, electronic equipment and storage medium
CN111400260A (en) File display method, display device, terminal device and readable storage medium
CN112214404A (en) Mobile application testing method and device, storage medium and electronic equipment
CN113806327A (en) Database design method and device and related equipment
CN115543391B (en) Application platform upgrading method and device, electronic equipment and readable storage medium
JP6574156B2 (en) Terminal device, event generation method, and event generation method program
CN114238099B (en) Method and device for gray scale test, electronic equipment and readable medium
CN117349166A (en) Automatic test method, device, equipment and medium for mobile terminal JSAPI interface
CN116501634A (en) Test case management method, device, medium and electronic equipment

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