CN115729821A - Code testing method and device, electronic equipment and storage medium - Google Patents

Code testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115729821A
CN115729821A CN202211468283.3A CN202211468283A CN115729821A CN 115729821 A CN115729821 A CN 115729821A CN 202211468283 A CN202211468283 A CN 202211468283A CN 115729821 A CN115729821 A CN 115729821A
Authority
CN
China
Prior art keywords
code
logic judgment
return
testing
layer
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
CN202211468283.3A
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.)
Ping An Bank Co Ltd
Original Assignee
Ping An Bank 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 Ping An Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211468283.3A priority Critical patent/CN115729821A/en
Publication of CN115729821A publication Critical patent/CN115729821A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application provides a code testing method, a code testing device, electronic equipment and a storage medium, wherein the code testing method comprises the following steps: determining a multi-layer logic judgment code in the code to be tested; in the multilayer logic judgment codes, modifying a return function of at least one layer of logic judgment codes to enable the return function to return an abnormal result; and testing based on the modified code to be tested. By implementing the embodiment, the code coverage rate in the test process can be improved.

Description

Code testing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of software testing technologies, and in particular, to a code testing method and apparatus, an electronic device, and a storage medium.
Background
Software Testing (english: software Testing) describes a process used to facilitate the identification of the correctness, integrity, security, and quality of Software. In other words, software testing is a process of auditing or comparing between actual output and expected output. The classical definition of software testing is: the process of operating a program under specified conditions to discover program errors, to measure software quality, and to evaluate whether it meets design requirements.
Code coverage (English) is a measure in software testing and describes the proportion and degree of testing of source Code in a program, and the proportion is called Code coverage.
In the testing process, the coverage rate of partial abnormal codes is difficult to trigger every iteration, and the coverage rate of 100% incremental codes is difficult to achieve.
Disclosure of Invention
In view of this, an object of the embodiments of the present application is to provide a code testing method, apparatus, electronic device and storage medium, which can improve code coverage rate in software testing.
In a first aspect, an embodiment of the present application provides a method, including:
determining a multi-layer logic judgment code in the code to be tested;
in the multilayer logic judgment codes, modifying a return function of at least one layer of logic judgment codes to enable the return function to return an abnormal result;
and testing based on the modified code to be tested.
In the implementation process, different from the prior art, the logic judgment code in the code to be tested modifies the return function of at least one layer of logic judgment code, so that the return function returns an abnormal result, and during testing, the logic judgment code where the return function is located is detected because of abnormality and can be tested, and therefore, the code coverage rate of the whole code block in the testing process is improved.
Further, the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code to make the return function return an abnormal result includes:
carrying out a normal test process on the code to be tested to obtain the code coverage rate;
judging whether the code coverage rate meets a preset condition or not;
and if the code coverage rate does not meet the preset condition, modifying a return function of at least one layer of logic judgment codes, and enabling the return function to return an abnormal result.
In the implementation process, the code to be tested is subjected to a normal test process to obtain the code coverage rate, and the code coverage rate can reflect whether the code is fully tested or not to a certain extent, so that a preset condition is set based on the code coverage rate, and only when the code coverage rate does not accord with the preset condition, at least one layer of return function of the logic judgment code is modified to enable the return function to return an abnormal result. Based on the above embodiment, the code coverage rate can be improved, and meanwhile, the good return function of each logic judgment code is prevented from being modified, so that resources and time are saved.
Further, the code to be tested includes: starting a function;
modifying the starting function to enable the starting function to bind the code to be tested and the testing module when the starting function is called;
the bound test module is used for receiving a test request, wherein the test request comprises: the logic judges the identification information of the code;
the test module is further configured to modify the return function of the logic determination code according to the identification information, so that the modified return function returns an abnormal result.
In the implementation process, the code to be tested comprises: and the test module modifies a return function of the logic judgment code according to the identification information, so that the modified return function can return an abnormal result. Based on the implementation mode, automatic modification can be realized, the codes to be tested are decoupled, and the flexibility of code testing is improved.
Further, in the multi-layer logic judgment code, the step of modifying a return function of at least one layer of logic judgment code to make the return function return an abnormal result includes:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
and transforming different return functions in different examples to enable the return functions to return abnormal results.
In the implementation process, when testing the code to be tested, the test is carried out based on the minimum service unit, the integrity and the accuracy of the service can be verified, and the logic judgment codes of different layers of the multilayer logic judgment codes in different examples are modified; the logic judgment code to be tested can be completely tested.
Further, the method further comprises:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
building a plurality of call chains based on the plurality of instances;
the step of testing based on the modified code to be tested comprises the following steps:
and sending a service test request to the plurality of call chains to obtain a service test result.
In the implementation process, because the different services are independently tested in the testing process, in order to improve the integrity and comprehensiveness of the test, a plurality of call chains are constructed based on the copied multiple instances, and the service test requests are respectively sent to the call chains to obtain the service test results.
Further, the step of judging whether the code coverage rate meets a preset condition includes:
and judging whether the code coverage rate exceeds a preset threshold value.
In the implementation process, the preset condition is the code coverage rate, and when the code coverage rate exceeds a preset threshold value, it can be determined that the current test degree of the code to be tested is insufficient, so that the code to be tested needs to be modified, and the modified code is retested to obtain a higher code coverage rate.
Further, the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code to make the return function return an abnormal result includes:
and modifying a return function of the unexecuted first-layer logic judgment code in the multi-layer logic judgment codes to enable the return result of the return function to be abnormal.
In the implementation process, the logic judgment codes are executed layer by layer, so that the first layer of logic judgment codes are modified, and the code coverage rate in the test process can be accurately improved.
In a second aspect, an embodiment of the present application provides a code testing apparatus, including:
the logic judgment code determining module is used for determining multi-layer logic judgment codes in the codes to be tested;
the function modification module is used for modifying a return function of at least one layer of logic judgment codes in the multilayer logic judgment codes to enable the return function to return an abnormal result;
and the testing module is used for testing based on the modified code to be tested.
In the implementation process, different from the prior art, the return function of at least one layer of logic judgment code is modified by the logic judgment code in the code to be tested in the embodiment of the application, so that the return function returns an abnormal result, and during testing, the logic judgment code where the return function is located is detected due to abnormality and can be tested, and therefore, the code coverage rate of the whole code block in the testing process is improved.
In a third aspect, an electronic device provided in an embodiment of the present application includes: memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to any of the first aspect when executing the computer program.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having instructions stored thereon, which, when executed on a computer, cause the computer to perform the method according to any one of the first aspect.
Additional features and advantages of the disclosure will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the above-described technology disclosed herein.
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of a code testing method according to an embodiment of the present application;
FIG. 2 is a schematic structural diagram of a code testing apparatus according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined or explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not to be construed as indicating or implying relative importance.
Software Testing (english: software Testing) describes a process used to facilitate the identification of the correctness, integrity, security, and quality of Software. In other words, software testing is a process of auditing or comparing between actual output and expected output. The classical definition of software testing is: the process of operating a program under specified conditions to discover program errors, to measure software quality, and to evaluate whether it meets design requirements.
Code coverage (English) is a measure in software testing and describes the proportion and degree of testing of source Code in a program, and the proportion is called Code coverage.
In the testing process, the coverage rate of partial abnormal codes is difficult to trigger every iteration, and the coverage rate of 100% incremental codes is difficult to achieve.
Example 1
Referring to fig. 1, an embodiment of the present application provides a code testing method, including:
s1: determining a multi-layer logic judgment code in the code to be tested;
s2: in the multilayer logic judgment codes, modifying a return function of at least one layer of logic judgment codes to enable the return function to return an abnormal result;
s3: and testing based on the modified code to be tested.
In the above embodiment, the logic determination code is used to determine the return result of the return function, so that the code coverage rate in the code test can be gradually improved by continuously modifying the return result of the return function.
In the implementation process, different from the prior art, the logic judgment code in the code to be tested modifies the return function of at least one layer of logic judgment code, so that the return function returns an abnormal result, and during testing, the logic judgment code where the return function is located is detected because of abnormality and can be tested, and therefore, the code coverage rate of the whole code block in the testing process is improved.
In a possible embodiment, S2 comprises: and acquiring a judgment type in the logic judgment code, and modifying a return result of the return function based on the judgment type.
For example, the first layer logic judgment code and the second layer logic judgment code of the logic judgment code are both used for judging whether the return result of the return function is empty, and if the return result of the return function is an empty object, the first layer logic judgment code does not continue to go down after an error is reported, but directly reports the error, so that the code coverage rate is reduced.
In a possible implementation manner, the step of modifying, in the multi-layer logic judgment code, a return function of at least one layer of logic judgment code so that the return function returns an abnormal result includes:
carrying out a normal test process on the code to be tested to obtain the code coverage rate;
judging whether the code coverage rate meets a preset condition or not;
and if the code coverage rate does not accord with the preset condition, modifying a return function of at least one layer of logic judgment codes, and enabling the return function to return an abnormal result.
In the implementation process, the code to be tested is subjected to a normal test process to obtain the code coverage rate, and the code coverage rate can reflect whether the code is fully tested or not to a certain extent, so that a preset condition is set based on the code coverage rate, and only when the code coverage rate does not accord with the preset condition, at least one layer of return function of the logic judgment code is modified to enable the return function to return an abnormal result. Based on the above embodiment, the code coverage rate can be improved, and meanwhile, the good return function of each logic judgment code is prevented from being modified, so that resources and time are saved.
Further, the step of judging whether the code coverage rate meets a preset condition includes:
and judging whether the code coverage rate exceeds a preset threshold value.
In the implementation process, the preset condition is the code coverage rate, and when the code coverage rate exceeds a preset threshold value, it can be determined that the current test degree of the code to be tested is insufficient, so that the code to be tested needs to be modified, and the modified code is retested to obtain a higher code coverage rate.
In one possible embodiment, the code to be tested comprises: starting a function;
modifying the starting function to enable the starting function to bind the code to be tested and the testing module when the starting function is called;
the bound test module is used for receiving a test request, wherein the test request comprises: the logic judges the identification information of the code;
the test module is further configured to modify the return function of the logic determination code according to the identification information, so that the modified return function returns an abnormal result.
Illustratively, the test module is a charcabled tool, an agent of the charcabled is deployed on the application server, and binding is performed in a start function of the code to be tested, that is, the start function sends out an http request for mounting the agent to the application pid during start, and the application pid executes the agent mount. The code to be tested further encapsulates an http request for injecting exception into the logic judgment code, wherein url corresponding to the http request comprises: the address of the chaosblade service, a command of a result returned by the chaosblade tampering method, a name of the service to be tested, a path of a class name, a name of a method and a returned value after tampering. And initiating http request call (the method is on a call link), triggering abnormal code call when the method is called, and capturing the abnormality to improve the coverage rate of the abnormal code.
In the implementation process, the code to be tested includes: the test module can receive a test request, the request comprises code representation information, and the test module modifies a return function of the logic judgment code according to the identification information, so that the modified return function can return an abnormal result. Based on the implementation mode, automatic modification can be realized, the codes to be tested are decoupled, and the flexibility of code testing is improved.
In a possible implementation manner, in the multi-layer logic judgment code, the step of modifying a return function of at least one layer of logic judgment code to make the return function return an abnormal result includes:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
and transforming different return functions in different examples to enable the return functions to return abnormal results.
In the implementation process, when testing the code to be tested, the test is carried out based on the minimum service unit, the integrity and the accuracy of the service can be verified, and the logic judgment codes of different layers of the multilayer logic judgment codes in different examples are modified; the logic judgment code to be tested can be completely tested.
In one possible embodiment, the method further comprises:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
building a plurality of call chains based on the plurality of instances;
the step of testing based on the modified code to be tested comprises the following steps:
and sending service test requests to the plurality of call chains to obtain service test results.
A service unit is a series of codes that perform a certain function.
In the implementation process, because testing is independently performed among different services in the testing process, in order to improve the integrity and comprehensiveness of the testing, a plurality of call chains are constructed based on the copied multiple instances, and the service testing requests are respectively sent to the call chains to obtain service testing results.
Further, the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code, so that the return function returns an abnormal result, includes:
and modifying a return function of the unexecuted first-layer logic judgment code in the multi-layer logic judgment codes to enable the return result of the return function to be abnormal.
In the implementation process, the logic judgment codes are executed layer by layer, so that the first layer of logic judgment codes are modified, and the code coverage rate in the test process can be accurately improved.
In the above embodiment, in order to further improve the code coverage rate in the test process, the return results of the return function of the logic judgment code may be modified step by step, or all the return results returned may be directly modified.
Example 2
Referring to fig. 2, an embodiment of the present application provides a code testing apparatus, including:
a logic judgment code determining module 1, configured to determine a multi-layer logic judgment code in a code to be tested;
a function modifying module 2, configured to modify a return function of at least one layer of logic judgment codes in the multiple layers of logic judgment codes, so that the return function returns an abnormal result;
and the testing module 3 is used for testing based on the modified code to be tested.
In the implementation process, different from the prior art, the logic judgment code in the code to be tested modifies the return function of at least one layer of logic judgment code, so that the return function returns an abnormal result, and during testing, the logic judgment code where the return function is located is detected because of abnormality and can be tested, and therefore, the code coverage rate of the whole code block in the testing process is improved.
In a possible implementation manner, the testing module 3 is further configured to perform a normal testing process on the code to be tested, so as to obtain a code coverage rate;
judging whether the code coverage rate meets a preset condition or not;
and if the code coverage rate does not meet the preset condition, modifying a return function of at least one layer of logic judgment codes, and enabling the return function to return an abnormal result.
In the implementation process, the code to be tested is subjected to a normal test process to obtain the code coverage rate, and the code coverage rate can reflect whether the code is fully tested or not to a certain extent, so that a preset condition is set based on the code coverage rate, and only when the code coverage rate does not meet the preset condition, the return function of at least one layer of logic judgment code is modified to enable the return function to return an abnormal result. Based on the above embodiment, the code coverage rate can be improved, and meanwhile, the good return function of each logic judgment code is prevented from being modified, so that resources and time are saved.
In one possible embodiment, the code to be tested comprises: starting a function;
modifying the starting function to enable the starting function to bind the code to be tested and the testing module when the starting function is called;
the bound test module is used for receiving a test request, wherein the test request comprises: the logic judges the identification information of the code;
the test module is further configured to modify the return function of the logic determination code according to the identification information, so that the modified return function returns an abnormal result.
In the implementation process, the code to be tested comprises: the test module can receive a test request, the request comprises code representation information, and the test module modifies a return function of the logic judgment code according to the identification information, so that the modified return function can return an abnormal result. Based on the implementation mode, automatic modification can be realized, the codes to be tested are decoupled, and the flexibility of code testing is improved.
In a possible embodiment, the test module 3 is further configured to determine a minimum service unit of the logical decision code;
replicating multiple instances of the minimum service unit;
and transforming different return functions in different examples to enable the return functions to return abnormal results.
In the implementation process, when testing the code to be tested, the test is carried out based on the minimum service unit, the integrity and the accuracy of the service can be verified, and the logic judgment codes of different layers of the multilayer logic judgment codes in different examples are modified; the logic judgment code to be tested can be completely tested.
In a possible embodiment, the test module 3 is further configured to determine a minimum service unit of the logical decision code;
replicating multiple instances of the minimum service unit;
building a plurality of call chains based on the plurality of instances;
and sending a service test request to the plurality of call chains to obtain a service test result.
In the implementation process, because the different services are independently tested in the testing process, in order to improve the integrity and comprehensiveness of the test, a plurality of call chains are constructed based on the copied multiple instances, and the service test requests are respectively sent to the call chains to obtain the service test results.
In a possible embodiment, the testing module 3 is further configured to determine whether the code coverage exceeds a preset threshold.
In the implementation process, the preset condition is the code coverage rate, and when the code coverage rate exceeds a preset threshold value, it can be determined that the current test degree of the code to be tested is insufficient, so that the code to be tested needs to be modified, and the modified code is retested to obtain a higher code coverage rate.
In a possible implementation manner, the function modification module 2 is further configured to modify a return function of the first-layer logic judgment code that is not executed in the multiple-layer logic judgment code, so that a return result of the return function is an exception.
In the implementation process, the logic judgment codes are executed layer by layer, so that the first layer of logic judgment codes are modified, and the code coverage rate in the test process can be accurately improved.
Fig. 3 shows a block diagram of an electronic device according to an embodiment of the present disclosure, where fig. 3 is a block diagram of the electronic device. The electronic device may include a processor 31, a communication interface 32, a memory 33, and at least one communication bus 34. Wherein the communication bus 34 is used for realizing direct connection communication of these components. In the embodiment of the present application, the communication interface 32 of the electronic device is used for performing signaling or data communication with other node devices. The processor 31 may be an integrated circuit chip having signal processing capabilities.
The Processor 31 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor 31 may be any conventional processor or the like.
The Memory 33 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Read Only Memory (EPROM), an electrically Erasable Read Only Memory (EEPROM), and the like. The memory 33 stores computer readable instructions which, when executed by the processor 31, enable the electronic device to perform the various steps involved in the above-described method embodiments.
Optionally, the electronic device may further include a memory controller, an input output unit.
The memory 33, the memory controller, the processor 31, the peripheral interface, and the input/output unit are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components may be electrically connected to each other via one or more communication buses 34. The processor 31 is adapted to execute executable modules stored in the memory 33, such as software functional modules or computer programs comprised by the electronic device.
The input and output unit is used for providing a task for a user to create and start an optional time period or preset execution time for the task creation so as to realize the interaction between the user and the server. The input/output unit may be, but is not limited to, a mouse, a keyboard, and the like.
It will be appreciated that the configuration shown in fig. 3 is merely illustrative and that the electronic device may include more or fewer components than shown in fig. 3 or have a different configuration than shown in fig. 3. The components shown in fig. 3 may be implemented in hardware, software, or a combination thereof.
The embodiments of the present application further provide a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are run on a computer, a computer program is executed by a processor to implement the method of the method embodiments, and for avoiding repetition, details are not repeated here.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. 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 that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, an optical disk, or other various media capable of storing program codes.
The above embodiments are merely examples of the present application and are not intended to limit the scope of the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined or explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It should be noted that, in this document, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, 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 phrases "comprising a component of' 8230; \8230;" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that comprises the element.

Claims (10)

1. A method for code testing, comprising:
determining a multi-layer logic judgment code in the code to be tested;
in the multilayer logic judgment codes, modifying a return function of at least one layer of logic judgment codes to enable the return function to return an abnormal result;
and testing based on the modified code to be tested.
2. The method for testing code according to claim 1, wherein the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code so that the return function returns an abnormal result includes:
carrying out a normal test process on the code to be tested to obtain a code coverage rate;
judging whether the code coverage rate meets a preset condition or not;
and if the code coverage rate does not accord with the preset condition, modifying a return function of at least one layer of logic judgment codes, and enabling the return function to return an abnormal result.
3. The code testing method of claim 2, wherein the code to be tested comprises: starting a function;
modifying the starting function to enable the starting function to bind the code to be tested and the testing module when the starting function is called;
the bound test module is used for receiving a test request, wherein the test request comprises: the logic judges the identification information of the code;
the test module is further configured to modify the return function of the logic determination code according to the identification information, so that the modified return function returns an abnormal result.
4. The code testing method according to claim 1, wherein the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code to make the return function return an abnormal result comprises:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
and transforming different return functions in different examples to enable the return functions to return abnormal results.
5. The code testing method of claim 2, wherein the method further comprises:
determining the minimum service unit of the logic judgment code;
replicating multiple instances of the minimum service unit;
building a plurality of call chains based on the plurality of instances;
the step of testing based on the modified code to be tested comprises the following steps:
and sending a service test request to the plurality of call chains to obtain a service test result.
6. The code testing method according to claim 2, wherein the step of determining whether the code coverage rate meets a predetermined condition comprises:
and judging whether the code coverage rate exceeds a preset threshold value.
7. The code testing method according to claim 1, wherein the step of modifying a return function of at least one layer of logic judgment code in the multi-layer logic judgment code to make the return function return an abnormal result comprises:
and modifying a return function of the unexecuted first-layer logic judgment code in the multi-layer logic judgment codes to enable the return result of the return function to be abnormal.
8. A code testing apparatus, comprising:
the logic judgment code determining module is used for determining a plurality of layers of logic judgment codes in the codes to be tested;
the function modification module is used for modifying a return function of at least one layer of logic judgment codes in the multilayer logic judgment codes to enable the return function to return an abnormal result;
and the testing module is used for testing based on the modified code to be tested.
9. An electronic device, comprising: memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium having stored thereon instructions which, when executed on a computer, cause the computer to perform the method of any one of claims 1-7.
CN202211468283.3A 2022-11-22 2022-11-22 Code testing method and device, electronic equipment and storage medium Pending CN115729821A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211468283.3A CN115729821A (en) 2022-11-22 2022-11-22 Code testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211468283.3A CN115729821A (en) 2022-11-22 2022-11-22 Code testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115729821A true CN115729821A (en) 2023-03-03

Family

ID=85297577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211468283.3A Pending CN115729821A (en) 2022-11-22 2022-11-22 Code testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115729821A (en)

Similar Documents

Publication Publication Date Title
CN106716972B (en) Semi-automatic failover
GB2493828A (en) Linking a test case error to a code segment to re-execute the test when the code segment is modified
CN111506341B (en) Software configuration information detection method, device and system
Marijan et al. Practical selective regression testing with effective redundancy in interleaved tests
CN112241350A (en) Micro-service evaluation method and device, computing device and micro-service detection system
CN110908910B (en) Block chain-based test monitoring method and device and readable storage medium
CN114844768A (en) Information analysis method and device and electronic equipment
CN112306568A (en) Service instance configuration method and device, electronic equipment and storage medium
CN114528201A (en) Abnormal code positioning method, device, equipment and medium
CN113094251B (en) Method and device for testing embedded system, computer equipment and storage medium
CN110908903B (en) Test method based on editable YAML file
CN115729821A (en) Code testing method and device, electronic equipment and storage medium
CN111752819B (en) Abnormality monitoring method, device, system, equipment and storage medium
CN112286786A (en) Database testing method and device and server
CN112131127B (en) Interface testing method, device and system and electronic equipment
CN114780412A (en) Page testing method, system, device and medium
CN110618943B (en) Security service test method and device, electronic equipment and readable storage medium
US8739130B2 (en) Quality assurance testing
CN114168108A (en) Code merging method and device, electronic equipment and computer readable storage medium
CN111475400A (en) Verification method of service platform and related equipment
CN111198798A (en) Service stability measuring method and device
CN113609111A (en) Big data testing method and system
CN110362464B (en) Software analysis method and equipment
CN107919980B (en) Evaluation method and device for clustered system
CN115080437A (en) Intelligent test method and device, electronic equipment and storage medium

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