CN112860544B - Code detection method, device, equipment and computer readable storage medium - Google Patents

Code detection method, device, equipment and computer readable storage medium Download PDF

Info

Publication number
CN112860544B
CN112860544B CN202110081722.4A CN202110081722A CN112860544B CN 112860544 B CN112860544 B CN 112860544B CN 202110081722 A CN202110081722 A CN 202110081722A CN 112860544 B CN112860544 B CN 112860544B
Authority
CN
China
Prior art keywords
path
test case
modified
calling
module
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.)
Active
Application number
CN202110081722.4A
Other languages
Chinese (zh)
Other versions
CN112860544A (en
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.)
Fujian Weidun Science And Technology Group Co ltd
Linewell Software Co Ltd
Original Assignee
Fujian Weidun Science And Technology Group Co ltd
Linewell Software 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 Fujian Weidun Science And Technology Group Co ltd, Linewell Software Co Ltd filed Critical Fujian Weidun Science And Technology Group Co ltd
Priority to CN202110081722.4A priority Critical patent/CN112860544B/en
Publication of CN112860544A publication Critical patent/CN112860544A/en
Application granted granted Critical
Publication of CN112860544B publication Critical patent/CN112860544B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/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/362Software debugging
    • G06F11/3628Software debugging of optimised code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis

Landscapes

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

Abstract

The embodiment of the invention discloses a code detection method, which relates to the technical field of development code testing, and comprises the following steps: step 10, when detecting that a source file is modified and submitted, acquiring the source file before modification, comparing the source file before modification with the source file after modification, analyzing to obtain at least one modified method, and marking the modified method; step 20, carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method; step 30, analyzing the test case covering the logic path as an effective test case; and step 40, executing the effective test case on the modified source file to generate a test report. According to the code detection method, the code detection device, the code detection equipment and the computer readable storage medium, the logic path associated with the modified software code is found, then the effective test case is analyzed, and the automatic detection of the code is realized.

Description

Code detection method, device, equipment and computer readable storage medium
Technical Field
The present invention relates to the field of development code testing technologies, and in particular, to a code detection method, apparatus, device, and computer readable storage medium.
Background
High quality coding is a crucial part of the software lifecycle. When a developer takes over a project that he has never previously participated in developing and is about to perform maintenance, the project may be unfamiliar. The pickup project is followed by new customer requirements, which requires the developer to modify a certain function point to meet the customer requirement changes. Developers cannot completely clear all related functions related to codes in the existing system in the process of analyzing the requirements. Other potential associated dysfunctions often occur after encoding, testing, and version release. The reason is that the correlation and influence points cannot be ensured in the process of changing and analyzing the demand, and developers often pull one's head to move the whole body to get burnt out.
Disclosure of Invention
The technical problem to be solved by the present invention is to provide a code detection method, apparatus, device and computer readable storage medium, which find a logic path associated with a modified software code, and then analyze an effective test case to implement automatic detection of the code.
In a first aspect, the present invention provides a code detection method, including:
step 10, when detecting that a source file is modified and submitted, acquiring the source file before modification, comparing the source file before modification with the source file after modification, analyzing to obtain at least one modified method, and marking the modified method;
step 20, carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
step 30, analyzing the test case covering the logic path as an effective test case;
and step 40, executing the effective test case on the modified source file to generate a test report.
Further, the step 20 specifically includes:
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording a second-level method name and a calling path, and then searching a third-level method for calling the second-level method upwards;
and step 23, searching upwards in the mode of step 22 until all the calling paths and the program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path is a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information.
Further, the step 30 specifically includes:
step 31, obtaining at least one first node with a program entry mark according to the logic path, and obtaining a method name and required parameter information of the first node;
step 32, searching at least one n +1 th node called by each n-th node downwards according to the logic path, when the n +1 th node can be found, obtaining the method name of the n +1 th node and the required parameter information, then continuing to search downwards, and when the n +1 th node cannot be found, finishing the current path search, wherein n is an integer greater than or equal to 1;
and step 33, analyzing the effective test cases covering the whole path according to the method name included by each path and the required parameter information.
Further, the step 33 specifically includes:
331, determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the method does not need the parameters, executing step 332, if the parameters are needed, generating the parameters by adopting a method for generating test data facing the path, and then executing step 332;
step 332, determining whether the method in the path is the marked modified method, if so, deleting the corresponding test case before the method in the path, then generating the test case and the test data for the method in the path, if not, detecting the method in the path, if not, generating the test case and the test data, and if the method in the path is not tested before, saving the test case.
In a second aspect, the present invention provides a code detection apparatus, including: the system comprises a modification marking module, a logic path searching module, a test case analyzing module and a detection module;
the modification marking module is used for acquiring a source file before modification when the source file is detected to be modified and submitted, analyzing and acquiring at least one modified method by comparing the source file before modification with the source file after modification, and marking the modified method;
the logic path searching module is used for carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
the test case analysis module is used for analyzing the test cases covering the logic paths as effective test cases;
the detection module is used for executing the effective test case on the modified source file to generate a test report.
Further, the logic path search module is specifically configured to execute the following steps:
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording the second-level method name and the calling path, and then searching a third-level method for calling the second-level method upwards;
and step 23, searching upwards in the mode of step 22 until all the calling paths and the program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path is a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information.
Further, the test case analysis module specifically includes: program entry searching module and path traversing module
A program entry searching module, configured to obtain at least one first node with a program entry mark according to the logic path, and obtain a method name and required parameter information of the first node;
the path traversal module is used for searching at least one (n + 1) th node called by each nth node downwards according to the logic path, acquiring the method name of the (n + 1) th node and required parameter information when the (n + 1) th node can be searched, then continuing to search downwards, and finishing the current path search when the (n + 1) th node cannot be searched, wherein n is an integer greater than or equal to 1;
and the test case generation module is used for analyzing the effective test cases covering the whole path according to the method name included by each path and the required parameter information.
Further, the test case generation module specifically includes: the device comprises a parameter generation module and a test case updating module;
the parameter generating module is used for determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the method does not need the parameters, executing the test case updating module, if the parameters are needed, generating the parameters by adopting a method for generating test data facing the paths, and then executing the test case updating module;
the test case updating module is used for determining whether the method in the path is the marked modified method or not, if so, deleting the corresponding test case before the method in the path, then generating the test case and the test data aiming at the method in the path, if not, detecting the method in the path, if the method in the path is not tested before, generating the test case and the test data, and when the test case is executed and passed, saving the test case.
In a third aspect, the present invention provides an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect when executing the program.
In a fourth aspect, the invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect.
One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
the modified method is marked, then global search is carried out, a logic path for calling or indirectly calling the method is obtained, a test case covering the logic path is analyzed to be used as an effective test case, execution is carried out to obtain a test report, and therefore the code quality is improved, the error rate is reduced, potential problems are known and avoided, and the maintenance risk of the control system is reduced.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
FIG. 1 is a flow chart of a method according to one embodiment of the present invention;
FIG. 2 is a schematic diagram of a logic path according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of an apparatus according to a second embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a third embodiment of the invention;
fig. 5 is a schematic structural diagram of a medium according to a fourth embodiment of the present invention.
Detailed Description
Example one
The present embodiment provides a method, as shown in fig. 1, which may include the following steps;
step 10, when detecting that a source file is modified and submitted, acquiring the source file before modification, comparing the source file before modification with the source file after modification, analyzing to obtain at least one modified method, and marking the modified method;
step 20, carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
step 30, analyzing the test case covering the logic path as an effective test case;
and step 40, executing the effective test case on the modified source file to generate a test report.
The modified method is marked, then global search is carried out, a logic path for calling or indirectly calling the method is obtained, a test case covering the logic path is analyzed to be used as an effective test case, execution is carried out to obtain a test report, and therefore code quality is improved, error rate is reduced, potential problems are known and avoided, and maintenance risks of a control system are controlled.
In a possible implementation manner, the step 20 specifically includes:
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording a second-level method name and a calling path, and then searching a third-level method for calling the second-level method upwards;
and step 23, searching upwards in the way of step 22 until all the calling paths and program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path can be stored as a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information.
In a specific embodiment, the step 20 is implemented as follows:
(1) finding out all methods for calling the marked method names;
(2) respectively confirming whether the found method call is marked or not (since the method with the same name can be found by searching the name of the method, but is not modified and marked, whether the marked method is called or not can be confirmed by executing the found method);
(3) if yes, returning the information of the calling method and recording the method (including the method name and the calling path) to avoid repeated and infinite recursion, and after recording, continuously searching the method upwards in the mode;
(4) if the confirmation is not yes, returning back (recursion returning) and simultaneously returning failure information and recording to prevent repeated searching next time;
(5) if the path belongs to the program entry, marking the entry point of the path;
(6) if other paths exist, other paths are continuously tried, and upward search is performed layer by layer in sequence, and finally all logic paths related to the modified method are analyzed.
Taking the Spring Boot project as an example, if the data link access layer is modified, the method called by the method in the service logic processing layer, the control layer, the AOP layer and other layers will be detected.
Finally, the found methods and the calling relations among the methods form a logic path of the final related service, the logic path can be stored in the form of a directed graph, as shown in fig. 2, each point in the graph corresponds to one method, and if the point is a program entry, the point is marked; if a calling relationship exists between the two methods, an edge exists between the two corresponding points, and the direction of the edge points to the calling method from the called method.
In a possible implementation manner, the step 30 specifically includes:
step 31, obtaining at least one first node with a program entry mark according to the logic path, and obtaining a method name and required parameter information of the first node;
step 32, searching at least one n +1 th node called by each n-th node downwards according to the logic path, when the n +1 th node can be found, obtaining the method name of the n +1 th node and the required parameter information, then continuing to search downwards, and when the n +1 th node cannot be found, finishing the current path search, wherein n is an integer greater than or equal to 1;
and step 33, analyzing the effective test cases covering the whole path according to the method name included in each path and the required parameter information.
In a possible implementation manner, the step 33 specifically includes:
331, determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the parameters are not needed, executing step 332, if the parameters are needed, generating the parameters by adopting a path-oriented test data generating method, or adopting a path-oriented test data generating method, aiming at generating test data for a specific specified path, such as a static symbol execution method, an interval arithmetic method, a dynamic korel method, a heuristic method and the like, and then executing step 332;
step 332, determining whether the method in the path is the marked modified method, if so, deleting the test case corresponding to the method in the path before, then generating the test case and the test data for the method in the path (namely, the content of the code modification at this time), if not, detecting the method in the path, if the method in the path has not been tested before, generating the test case and the test data, and when the test case passes the execution, saving the test case until the next interface is modified.
a. For the first time a parameter occurs, if a floating point number is required, a random number can be generated using the following formula:
Figure BDA0002909610640000071
wherein x is the last three digits of the current timestamp;
if an integer is needed, generating a random number by using the formula, multiplying by 100 and then rounding;
if a character or string is desired, the above formula is used to generate numbers between 65-97 and convert them to ASCII code.
b. The new parameters are brought into the method to obtain new parameters, and the new parameters are brought into the subsequent method to be sequentially executed. If the following method throws an error during shipment, returning the previous method to regenerate data and calling, if the error is still thrown after 10 times of attempts, generating an error report and indicating which parameter is in error, otherwise, saving the parameter until the path node is finished.
By finding the test case covering all logic paths as an effective test case, the comprehensiveness and the effectiveness of the test can be ensured. In the stored logic path data, first, a first node of a program entry is found through whether a program entry is marked, a method node to be called is found according to a first node arrow, information of the method node to be called is obtained, and the nodes are searched layer by layer downwards until a node modified at this time is found, as shown in fig. 2, the following example is shown:
(1) whether the first node is found through the program entrance mark or not is judged, and parameter data required by the method one is obtained at the program entrance according to the edge and the direction of the first node;
(2) searching downwards in sequence, and finding a second method, namely the method for current modification, according to the edge pointing to the first method; obtaining the information contained in the point, continuing to search downwards, and finding that the edge pointing to the point does not exist, so that the search of the path is finished;
(3) continuously traversing the paths of other program entries until all program entries are searched;
(4) after parameter information required by each path is acquired, analyzing the final effective test data covering the whole path:
and after traversing, obtaining test cases required by the test, then generating a condition path diagram of all paths between reaction conditions according to the conditions, selecting the cases covering the condition path diagram for the previously generated test cases, and selecting the cases covering the whole condition path diagram as the final effective test case.
After the test case construction is completed, the system executes the test case and generates a report, the report displays the service flow of the relevant module, and if the report has errors, the output information of the errors is stored. Therefore, developers do not need to manually find the test cases one by one, and the problem is solved at one time.
Based on the same inventive concept, the application also provides a device corresponding to the method in the first embodiment, which is detailed in the second embodiment.
Example two
In the present embodiment, there is provided a code detection apparatus, as shown in fig. 3, including: the system comprises a modification marking module, a logic path searching module, a test case analyzing module and a detection module;
the modification marking module is used for acquiring a source file before modification when the source file is detected to be modified and submitted, analyzing and acquiring at least one modified method by comparing the source file before modification with the source file after modification, and marking the modified method;
the logic path searching module is used for carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
the test case analysis module is used for analyzing the test case covering the logic path as an effective test case;
the detection module is used for executing the effective test case on the modified source file to generate a test report.
In a possible implementation manner, the logic path searching module is specifically configured to perform the following steps:
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording a second-level method name and a calling path, and then searching a third-level method for calling the second-level method upwards;
and step 23, searching upwards in the mode of step 22 until all the calling paths and the program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path is a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information.
In a possible implementation manner, the test case parsing module specifically includes: program entry searching module and path traversing module
A program entry searching module, configured to obtain at least one first node with a program entry mark according to the logic path, and obtain a method name and required parameter information of the first node;
the path traversal module is used for searching at least one (n + 1) th node called by each nth node downwards according to the logic path, acquiring the method name of the (n + 1) th node and required parameter information when the (n + 1) th node can be searched, then continuing to search downwards, and finishing the current path search when the (n + 1) th node cannot be searched, wherein n is an integer greater than or equal to 1;
and the test case generation module is used for analyzing the effective test cases covering the whole path according to the method name included by each path and the required parameter information.
In a possible implementation manner, the test case generation module specifically includes: the device comprises a parameter generation module and a test case updating module;
the parameter generating module is used for determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the parameters are not needed, executing the test case updating module, if the parameters are needed, generating the parameters by adopting a method for generating test data facing the path, and then executing the test case updating module;
the test case updating module is used for determining whether the method in the path is the marked modified method or not, if so, deleting the corresponding test case before the method in the path, then generating the test case and the test data aiming at the method in the path, if not, detecting the method in the path, if the method in the path is not tested before, generating the test case and the test data, and when the test case is executed and passed, saving the test case.
Since the apparatus described in the second embodiment of the present invention is an apparatus used for implementing the method of the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific structure and the deformation of the apparatus, and thus the details are not described herein. All the devices adopted in the method of the first embodiment of the present invention belong to the protection scope of the present invention.
Based on the same inventive concept, the application provides an electronic device embodiment corresponding to the first embodiment, which is detailed in the third embodiment.
EXAMPLE III
The embodiment provides an electronic device, as shown in fig. 4, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, any one of the first embodiment modes may be implemented.
Since the electronic device described in this embodiment is a device used for implementing the method in the first embodiment of the present application, based on the method described in the first embodiment of the present application, a specific implementation of the electronic device in this embodiment and various variations thereof can be understood by those skilled in the art, and therefore, how to implement the method in the first embodiment of the present application by the electronic device is not described in detail herein. The equipment used by those skilled in the art to implement the method in the embodiments of the present application is all within the protection scope of the present application.
Based on the same inventive concept, the application provides a storage medium corresponding to the fourth embodiment, which is described in detail in the fourth embodiment.
Example four
The present embodiment provides a computer-readable storage medium, as shown in fig. 5, on which a computer program is stored, and when the computer program is executed by a processor, any one of the embodiments can be implemented.
Since the computer-readable storage medium described in this embodiment is a computer-readable storage medium used for implementing the method in the first embodiment of the present application, a person skilled in the art can understand the specific implementation manner of the computer-readable storage medium and various modifications thereof based on the method described in the first embodiment of the present application, and therefore, how to implement the method in the embodiments of the present application by using the computer-readable storage medium is not described in detail here. Computer-readable storage media that can be used by those skilled in the art to implement the methods of the embodiments of the present application are all within the scope of the present application.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.

Claims (8)

1. A code detection method, comprising:
step 10, when detecting that a source file is modified and submitted, acquiring the source file before modification, comparing the source file before modification with the source file after modification, analyzing to obtain at least one modified method, and marking the modified method;
step 20, carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording a second-level method name and a calling path, and then searching a third-level method for calling the second-level method upwards;
step 23, searching upwards in the manner of step 22 until all the calling paths and program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path is a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information;
step 30, analyzing the test case covering the logic path as an effective test case;
and step 40, executing the effective test case on the modified source file to generate a test report.
2. The method of claim 1, wherein: the step 30 specifically includes:
step 31, obtaining at least one first node with a program entry mark according to the logic path, and obtaining a method name and required parameter information of the first node;
step 32, searching at least one n +1 th node called by each n-th node downwards according to the logic path, when the n +1 th node can be found, obtaining the method name of the n +1 th node and the required parameter information, then continuing to search downwards, and when the n +1 th node cannot be found, finishing the current path search, wherein n is an integer greater than or equal to 1;
and step 33, analyzing the effective test cases covering the whole path according to the method name included in each path and the required parameter information.
3. The method of claim 2, wherein: the step 33 specifically includes:
331, determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the method does not need the parameters, executing step 332, if the parameters are needed, generating the parameters by adopting a method for generating test data facing the path, and then executing step 332;
step 332, determining whether the method in the path is the marked modified method, if so, deleting the corresponding test case before the method in the path, then generating the test case and the test data for the method in the path, if not, detecting the method in the path, if not, generating the test case and the test data, and if the method in the path is not tested before, saving the test case when the test case passes execution.
4. A code detection apparatus characterized by: the method comprises the following steps: the system comprises a modification marking module, a logic path searching module, a test case analyzing module and a detection module;
the modification marking module is used for acquiring a source file before modification when the source file is detected to be modified and submitted, analyzing and acquiring at least one modified method by comparing the source file before modification with the source file after modification, and marking the modified method;
the logic path searching module is used for carrying out global search according to the marked modified method to obtain a logic path for calling or indirectly calling the modified method;
the logic path searching module is specifically configured to execute the following steps:
step 21, acquiring the modified methods one by one, searching according to the modified methods, and finding out a second-level method for calling the modified methods;
step 22, judging whether the second-level method is a program entry, if so, recording a second-level method name, a calling path and a program entry point, then returning to the step 21, if not, recording a second-level method name and a calling path, and then searching a third-level method for calling the second-level method upwards;
step 23, searching upwards in the manner of step 22 until all the calling paths and program entry points are found, and obtaining a logic path for calling or indirectly calling the modified method, wherein the logic path is a directed graph, and nodes in the directed graph comprise method names, program entry marks and required parameter information;
the test case analysis module is used for analyzing the test case covering the logic path as an effective test case;
the detection module is used for executing the effective test case on the modified source file to generate a test report.
5. The apparatus of claim 4, wherein: the test case analysis module specifically comprises: program entry searching module and path traversing module
A program entry searching module, configured to obtain at least one first node with a program entry mark according to the logic path, and obtain a method name and required parameter information of the first node;
the path traversal module is used for searching at least one (n + 1) th node called by each nth node downwards according to the logic path, acquiring the method name of the (n + 1) th node and required parameter information when the (n + 1) th node can be searched, then continuing to search downwards, and finishing the current path search when the (n + 1) th node cannot be searched, wherein n is an integer greater than or equal to 1;
and the test case generation module is used for analyzing the effective test cases covering the whole path according to the method name included by each path and the required parameter information.
6. The apparatus of claim 5, wherein: the test case generation module specifically includes: the device comprises a parameter generation module and a test case updating module;
the parameter generating module is used for determining whether the method in each path needs parameters one by one according to the method name and the required parameter information included in each path, if the method does not need the parameters, executing the test case updating module, if the parameters are needed, generating the parameters by adopting a method for generating test data facing the paths, and then executing the test case updating module;
the test case updating module is used for determining whether the method in the path is the marked modified method or not, if so, deleting the corresponding test case before the method in the path, then generating the test case and the test data aiming at the method in the path, if not, detecting the method in the path, if the method in the path is not tested before, generating the test case and the test data, and when the test case is executed and passed, saving the test case.
7. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 3 when executing the program.
8. A computer-readable 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 3.
CN202110081722.4A 2021-01-21 2021-01-21 Code detection method, device, equipment and computer readable storage medium Active CN112860544B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110081722.4A CN112860544B (en) 2021-01-21 2021-01-21 Code detection method, device, equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110081722.4A CN112860544B (en) 2021-01-21 2021-01-21 Code detection method, device, equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112860544A CN112860544A (en) 2021-05-28
CN112860544B true CN112860544B (en) 2022-09-30

Family

ID=76008711

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110081722.4A Active CN112860544B (en) 2021-01-21 2021-01-21 Code detection method, device, equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112860544B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484269A (en) * 2014-11-27 2015-04-01 北京广利核系统工程有限公司 Method for automatically generating testing script
CN110781086A (en) * 2019-10-23 2020-02-11 南京大学 Cross-project defect influence analysis method based on program dependency relationship and symbolic analysis

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102831056B (en) * 2012-07-31 2015-04-08 东南大学 Regression testing sample generating method based on modification impact analysis
US10019461B2 (en) * 2015-03-26 2018-07-10 Ca, Inc. Transparent and near-real time code deploys
CN106528399A (en) * 2015-09-15 2017-03-22 腾讯科技(深圳)有限公司 Test case determination method and apparatus
CN106407124B (en) * 2016-11-10 2019-03-12 中国工商银行股份有限公司 A kind of programming automation test method and system
CN111045944B (en) * 2019-12-11 2023-06-13 广州品唯软件有限公司 Regression testing method, device, system and computer readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104484269A (en) * 2014-11-27 2015-04-01 北京广利核系统工程有限公司 Method for automatically generating testing script
CN110781086A (en) * 2019-10-23 2020-02-11 南京大学 Cross-project defect influence analysis method based on program dependency relationship and symbolic analysis

Also Published As

Publication number Publication date
CN112860544A (en) 2021-05-28

Similar Documents

Publication Publication Date Title
US9983984B2 (en) Automated modularization of graphical user interface test cases
Chen et al. Star: Stack trace based automatic crash reproduction via symbolic execution
US8276126B2 (en) Determining causes of software regressions based on regression and delta information
US8312440B2 (en) Method, computer program product, and hardware product for providing program individuality analysis for source code programs
US10642726B2 (en) Method, apparatus, and system for blaming a test case/class for a survived mutation
CN108459967B (en) Web application test case generation method based on user interface state flow diagram
CN111104335B (en) C language defect detection method and device based on multi-level analysis
Chen et al. Coverage prediction for accelerating compiler testing
CN109542783B (en) Extended finite-state machine test data generation method based on variable segmentation
EP3682324A1 (en) Method and apparatus for finding long methods in code
CN114491566B (en) Fuzzy test method and device based on code similarity and storage medium
CN112035359A (en) Program testing method, program testing device, electronic equipment and storage medium
CN104021072A (en) Machine and methods for evaluating failing software programs
Saifullah et al. Learning from examples to find fully qualified names of api elements in code snippets
CN115659335A (en) Block chain intelligent contract vulnerability detection method and device based on mixed fuzzy test
US7729999B2 (en) Program verification and discovery using probabilistic inference
US20160239407A1 (en) Small scale integration test generation
CN112860544B (en) Code detection method, device, equipment and computer readable storage medium
US9489284B2 (en) Debugging method and computer program product
Sadiq et al. On the Evolutionary Relationship between Change Coupling and Fix-Inducing Changes.
CN113051153B (en) Application software vulnerability scanning method and related equipment
CN114462043A (en) Java anti-serialization vulnerability detection system and method based on reinforcement learning
CN113297069A (en) Software testing method and device based on target drive
CN114610320B (en) LLVM (LLVM) -based variable type information restoration and comparison method and system
CN117520199B (en) Numerical software defect detection method and device based on static symbol execution

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
GR01 Patent grant
GR01 Patent grant