[go: up one dir, main page]

CN107153608B - Code detection method and code detection device - Google Patents

Code detection method and code detection device Download PDF

Info

Publication number
CN107153608B
CN107153608B CN201610122040.2A CN201610122040A CN107153608B CN 107153608 B CN107153608 B CN 107153608B CN 201610122040 A CN201610122040 A CN 201610122040A CN 107153608 B CN107153608 B CN 107153608B
Authority
CN
China
Prior art keywords
code
test
function
case
unexecuted
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
CN201610122040.2A
Other languages
Chinese (zh)
Other versions
CN107153608A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201610122040.2A priority Critical patent/CN107153608B/en
Publication of CN107153608A publication Critical patent/CN107153608A/en
Application granted granted Critical
Publication of CN107153608B publication Critical patent/CN107153608B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage 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)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention provides a code detection method, which comprises the following steps: performing code coverage rate test on the test codes by using the test case to acquire code coverage rate information of the detection codes; acquiring a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code; acquiring an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code; acquiring a corresponding retest case according to the upper layer calling function; and performing code coverage rate test on the unexecuted test code by using the retest case. The code coverage rate test is carried out on the unexecuted test code by the code detection method and the code detection device according to the retest case obtained by the upper layer calling function, so that the code can be well detected, and meanwhile, the detection cost is low, the detection time is short, and the detection steps are simpler.

Description

Code detection method and code detection device
Technical Field
The present invention relates to the field of detection, and in particular, to a code detection method and a code detection apparatus.
Background
With the development of science and technology, more and more applications are used on a terminal, and application tests, such as coverage rate tests of application codes, are performed before each application invests time to ensure the quality of published applications.
The existing coverage rate test of the application codes is that a tester checks whether a function or a code line is uncovered; for example, the tester manually checks which functions or codes of which files are not covered by the test, and the tester needs to think about what test cases are added to cover the functions or codes.
The coverage detection of the above application code has two drawbacks:
firstly, the coverage rate detection has a certain technical threshold, and a tester needs to know enough development codes, otherwise, the test range possibly influenced by the codes cannot be judged.
Secondly, the operation of detecting the uncovered code for the re-coverage needs a tester to find a corresponding upper-layer calling function according to the uncovered code, which is time-consuming and tedious.
Therefore, the existing code detection process has high cost, long detection time and complicated detection steps.
Disclosure of Invention
The embodiment of the invention provides a code detection method and a code detection device which have low detection cost, short detection time and simpler detection steps; the technical problems that the existing code detection method and the existing code detection device are high in detection cost, long in detection time and complex in detection steps are solved.
The embodiment of the invention provides a code detection method, which comprises the following steps:
performing code coverage rate test on the test codes by using the test case to acquire code coverage rate information of the detection codes; wherein the code coverage information comprises code parameters of unexecuted test code;
acquiring a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code;
acquiring an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code;
acquiring a corresponding retest case according to the upper layer call function; and
and performing code coverage rate test on the unexecuted test code by using the retest case.
An embodiment of the present invention further provides a code detection apparatus, which includes:
the code coverage rate information acquisition module is used for carrying out code coverage rate test on the test codes by using the test cases so as to acquire the code coverage rate information of the detection codes; wherein the code coverage information comprises code parameters of unexecuted test code;
the code function acquisition module is used for acquiring a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code;
the upper layer calling function obtaining module is used for obtaining an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code;
the retest case acquisition module is used for acquiring a corresponding retest case according to the upper layer calling function; and
and the testing module is used for carrying out code coverage rate testing on the unexecuted testing code by using the retest case.
Compared with the code detection method and the code detection device in the prior art, the code detection method and the code detection device can better complete the complete detection of the code by performing the code coverage rate test on the unexecuted test code according to the retest case obtained by the upper-layer calling function, and meanwhile, the detection cost is low, the detection time is short, and the detection steps are simpler; the technical problems that the existing code detection method and the code detection device are high in detection cost, long in detection time and complex in detection steps are solved.
Drawings
FIG. 1 is a flow chart of a first preferred embodiment of the code detection method of the present invention;
FIG. 2 is a flow chart of a second preferred embodiment of the code detection method of the present invention;
FIG. 3 is a flowchart of step S205 of a second preferred embodiment of the code detection method of the present invention;
FIG. 4 is a schematic structural diagram of a first preferred embodiment of the code detection apparatus of the present invention;
FIG. 5 is a schematic structural diagram of a second preferred embodiment of the code detection apparatus of the present invention;
FIG. 6 is a schematic structural diagram of a code function obtaining module of a second preferred embodiment of the code detecting apparatus of the present invention;
FIG. 7 is a schematic structural diagram of a retest case acquisition module according to a second preferred embodiment of the code detection apparatus of the present invention;
FIG. 8 is a flowchart of an embodiment of a code detection method and a code detection apparatus of the present invention;
fig. 9 is a schematic view of a working environment structure of an electronic device in which the code detection apparatus of the present invention is located.
Detailed Description
Referring to the drawings, wherein like reference numbers refer to like elements, the principles of the present invention are illustrated as being implemented in a suitable computing environment. The following description is based on illustrated embodiments of the invention and should not be taken as limiting the invention with regard to other embodiments that are not detailed herein.
In the description that follows, embodiments of the invention are described with reference to steps and symbols of operations performed by one or more computers, unless otherwise indicated. It will thus be appreciated that those steps and operations, which are referred to herein several times as being computer-executed, include being manipulated by a computer processing unit in the form of electronic signals representing data in a structured form. This manipulation transforms the data or maintains it at locations in the computer's memory system, which may reconfigure or otherwise alter the computer's operation in a manner well known to those skilled in the art. The data maintains a data structure that is a physical location of the memory that has particular characteristics defined by the data format. However, while the principles of the invention have been described in language specific to above, it is not intended to be limited to the specific details shown, since one skilled in the art will recognize that various steps and operations described below may be implemented in hardware.
The code detection apparatus of the present invention may be implemented using a variety of electronic devices including, but not limited to, personal computers, server computers, hand-held or laptop devices, mobile devices (such as mobile telephones, Personal Digital Assistants (PDAs), media players, and the like), multiprocessor systems, consumer electronics, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The electronic device is preferably a code detection server to better complete the complete detection of the code.
Referring to fig. 1, fig. 1 is a flowchart illustrating a code detection method according to a first preferred embodiment of the present invention. The code detection method of the preferred embodiment may be implemented using the electronic device described above, and includes:
step S101, using a test case to perform code coverage rate test on a test code so as to obtain code coverage rate information of a detection code;
step S102, according to the code parameters of the unexecuted test codes, obtaining code functions corresponding to the unexecuted test codes;
step S103, acquiring an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code;
step S104, acquiring a corresponding retest case according to the upper layer calling function;
step S105, using the retest case to perform code coverage rate test on the unexecuted test code;
the specific flow of each step of the code detection method of the present preferred embodiment is described in detail below.
In step S101, the code testing apparatus performs a coverage test on the test code by using a test case, where the test case is an application test flow specifically designed according to the test code, and is intended to detect whether all the test codes can normally run. Because the test case may not be able to detect all the test codes, the code detection apparatus may count the test coverage after detecting the test codes, so as to obtain the code coverage information of the test codes. The code coverage information includes code parameters of the unexecuted test codes in the test codes, the code parameters can be code positions of the unexecuted test codes and the like. Subsequently, the process goes to step S102.
In step S102, the code testing apparatus obtains a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code obtained in step S101. Since each line of test code may not be able to run independently, which is a part of a certain code function, here, the code function corresponding to the unexecuted test code is obtained through the code parameter of the unexecuted test code, so as to perform subsequent re-detection on the unexecuted test code. Subsequently, the process goes to step S103.
In step S103, the code testing apparatus obtains an upper layer call function corresponding to the code function according to the code function corresponding to the unexecuted test code obtained in step S102. The upper layer calling function is an upper layer function capable of calling a code function, and if the code function is a general keyboard input view control loading function, the upper layer calling function of the code function can be a flow monitoring function for adjusting a used flow page and flow monitoring of operation, and a calendar wallpaper setting function for setting a local reminding page of a calendar and calendar wallpaper operation. And calling a general keyboard input view control loading function when the flow monitoring function and the calendar wallpaper setting function run. Subsequently, the process goes to step S104.
In step S104, the code testing apparatus acquires a retest case using the upper layer call function according to the upper layer call function acquired in step S103. If the upper layer calling function is a flow monitoring function, the retest case can be a flow monitoring case for monitoring the flow of the current game application of the terminal, and the like. Subsequently, the process goes to step S105.
In step S105, the code testing apparatus performs a code coverage test on the unexecuted test code acquired in step S101 using the retest case acquired in step S104. The retest case is set according to the unexecuted test code, so that complete detection of the code can be well completed.
This completes the code detection process of the code detection method of the present preferred embodiment.
The code detection method of the preferred embodiment performs the code coverage rate test on the unexecuted test code through the retest case obtained according to the upper-layer call function, can well complete the complete detection of the code, and has the advantages of low detection cost, short detection time and simpler detection steps.
Referring to fig. 2, fig. 2 is a flowchart illustrating a code detection method according to a second preferred embodiment of the present invention. The code detection method of the preferred embodiment may be implemented using the electronic device described above, and includes:
step S201, using a test case to perform code coverage rate test on a test code through a coverage rate test tool to obtain code coverage rate information of a detection code;
step S202, acquiring a code line of the unexecuted test code;
step S203, acquiring a code function corresponding to a code line of the unexecuted test code;
step S204, scanning a code function corresponding to the unexecuted test code by using a static code scanning tool to obtain an upper layer calling function corresponding to the code function, wherein the static code scanning tool comprises a corresponding relation between the code function and at least one upper layer calling function;
step S205, obtaining a corresponding retest case according to the upper layer calling function;
step S206, the code coverage rate test is carried out on the unexecuted test code by using the retest case through the coverage rate test tool.
The specific flow of each step of the code detection method of the present preferred embodiment is described in detail below.
In step S201, the code testing apparatus performs a coverage test on the test code by using a test case through a coverage test tool such as lcov, where the test case is an application test flow specially designed according to the test code and is intended to detect whether all the test codes can normally run. Because the test case may not be able to detect all the test codes, the code detection apparatus may count the test coverage after detecting the test codes, so as to obtain the code coverage information of the test codes. The code coverage rate information includes code parameters of the unexecuted test code in the test code, and the code parameters can be code lines of the unexecuted test code, code execution times of the unexecuted test code, code effectiveness of the unexecuted test code and the like. Subsequently, the process goes to step S202.
In step S202, the code testing apparatus acquires the code line, i.e., the code position, of the unexecuted test code acquired in step S201, and then goes to step S203.
In step S203, the code testing apparatus acquires a code function corresponding to the unexecuted test code of the code position in step S202. Since each line of test code may not be able to run independently, which is a part of a certain code function, here, the code function corresponding to the unexecuted test code is obtained through the code line of the unexecuted test code, so as to perform subsequent re-detection on the unexecuted test code. Subsequently, the process goes to step S204.
In step S204, the code testing apparatus scans a code function corresponding to the unexecuted test code obtained in step S203 by using a static code scanning tool (e.g., an underpant, a doxygen, etc.), where the static code scanning tool includes a code function and a corresponding relationship of at least one upper layer calling function, and the upper layer calling function is an upper layer function that can call the code function; therefore, the code testing device can obtain the upper layer calling function corresponding to the code function. Subsequently, it goes to step S205.
In step S205, the code testing apparatus obtains a retest case using the upper layer call function according to the upper layer call function obtained in step S204. Referring to fig. 3, fig. 3 is a flowchart of step S205 of the code detection method according to the second preferred embodiment of the invention. The step S205 includes:
step S301, judging whether the use times of the upper layer calling function in the test case is zero or not; if the value is zero, go to step S302; if not, go to step S303.
Step S302, if the number of times of using the upper layer calling function in the test case is zero, the upper layer calling function is not used in the previous test case, and the retest case can be created by using the upper layer calling function; subsequently, the process goes to step S206.
In step S303, if the number of times of using the upper layer call function in the test case is not zero, it indicates that the upper layer call function has been used in the previous test case, and therefore the retest case cannot be created using the upper layer call function. Subsequently, the process goes to step S206.
In step S206, the code testing apparatus performs a code coverage test on the unexecuted test code acquired in step S201 using the retest case acquired in step S205 by using a coverage test tool such as lcov. The retest case is set according to the unexecuted test code, so that complete detection of the code can be well completed.
This completes the code detection process of the code detection method of the present preferred embodiment.
On the basis of the first preferred embodiment, the code detection method of the present preferred embodiment uses a static code scanning tool to obtain the upper layer call function, so that the obtained upper layer call function is more comprehensive and accurate; the detection accuracy of the retest case is further improved by judging the use times of the upper layer call function.
Referring to fig. 4, fig. 4 is a schematic structural diagram of a code detection apparatus according to a first preferred embodiment of the present invention. The code detection apparatus 40 includes a code coverage rate information acquisition module 41, a code function acquisition module 42, an upper-layer call function acquisition module 43, a retest case acquisition module 44, and a test module 45.
The code coverage rate information obtaining module 41 is configured to perform a code coverage rate test on the test code by using the test case to obtain code coverage rate information of the detection code; wherein the code coverage information includes code parameters for the unexecuted test code. The code function obtaining module 42 is configured to obtain a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code. The upper layer call function obtaining module 43 is configured to obtain an upper layer call function corresponding to the code function according to the code function corresponding to the unexecuted test code. The retest case obtaining module 44 is configured to obtain a corresponding retest case according to the upper layer call function. The test module 45 is used to perform code coverage testing on the unexecuted test code using the retest cases.
When the code detection apparatus 40 of the preferred embodiment is used, the code coverage rate information obtaining module 41 performs a coverage rate test on the test codes by using test cases, where the test cases are application test flows specially designed according to the test codes, and are used to detect whether all the test codes can normally run. Since the test case may not be able to detect all the test codes, the code coverage rate information obtaining module 41 may obtain the code coverage rate information of the test codes by counting the test coverage rates after the detection of the test codes is completed. The code coverage information includes code parameters of the unexecuted test codes in the test codes, the code parameters can be code positions of the unexecuted test codes and the like.
Then, the code function obtaining module 42 obtains a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code obtained by the code coverage rate information obtaining module 41. Since each line of test code may not be able to run independently, which is a part of a certain code function, here, the code function corresponding to the unexecuted test code is obtained through the code parameter of the unexecuted test code, so as to perform subsequent re-detection on the unexecuted test code.
Then, the upper layer call function obtaining module 43 obtains the upper layer call function corresponding to the code function according to the code function corresponding to the unexecuted test code obtained by the code function obtaining module 42. The upper layer calling function is an upper layer function capable of calling a code function, and if the code function is a general keyboard input view control loading function, the upper layer calling function of the code function can be a flow monitoring function for adjusting a used flow page and flow monitoring of operation, and a calendar wallpaper setting function for setting a local reminding page of a calendar and calendar wallpaper operation. And calling a general keyboard input view control loading function when the flow monitoring function and the calendar wallpaper setting function run.
Subsequently, the retest case acquisition module 44 acquires a retest case using the upper layer call function according to the upper layer call function acquired by the upper layer call function acquisition module 43. If the upper layer calling function is a flow monitoring function, the retest case may be a monitoring function for monitoring the flow of the current game application of the terminal, and the like.
Finally, the testing module 45 uses the retest cases obtained by the retest case obtaining module 44 to perform the code coverage test on the unexecuted test codes obtained by the code coverage information obtaining module. The retest case is set according to the unexecuted test code, so that complete detection of the code can be well completed.
This completes the code detection process of the code detection apparatus 40 of the present preferred embodiment.
The code detection device of the preferred embodiment performs the code coverage rate test on the unexecuted test code through the retest case obtained according to the upper-layer call function, can well complete the complete detection of the code, and has the advantages of low detection cost, short detection time and simpler detection steps.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a code detection apparatus according to a second preferred embodiment of the present invention. The code detection apparatus 50 includes a code coverage rate information acquisition module 51, a code function acquisition module 52, an upper-layer call function acquisition module 53, a retest case acquisition module 54, and a test module 55.
The code coverage rate information obtaining module 51 is configured to perform a code coverage rate test on the test code by using a test case through a coverage rate test tool; the code function obtaining module 52 is configured to obtain a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code; the upper layer calling function obtaining module 53 is configured to scan a code function corresponding to the unexecuted test code by using a static code scanning tool to obtain an upper layer calling function corresponding to the code function, where the static code scanning tool includes a corresponding relationship between the code function and at least one upper layer calling function; the retest case obtaining module 54 is configured to obtain a corresponding retest case according to the upper layer call function; the test module 55 is used to perform code coverage testing on the unexecuted test code using retest cases.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a code function obtaining module of a second preferred embodiment of the code detecting device of the present invention. The code function acquisition module 52 includes a code line acquisition unit 61 and a code function acquisition unit 62. A code line acquisition unit 61 for acquiring a code line on which the test code is not executed; the code function acquiring unit 62 is used for acquiring a code function corresponding to a code line of the unexecuted test code.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a retest case acquisition module of a second preferred embodiment of the code detection apparatus according to the present invention. The retest case acquisition module 54 includes a judgment unit 71 and a retest case creation unit 72. The judging unit 71 is configured to judge whether the number of times of use of the upper layer call function in the test case is zero. The retest case creation unit 72 is configured to create a retest case using an upper layer call function.
When the code detection apparatus 50 of the preferred embodiment is used, firstly, the code coverage information obtaining module 51 performs a coverage test on the test code by using a test case through a coverage test tool such as lcov, where the test case is an application test flow specially designed according to the test code and is intended to detect whether all the test codes can run normally. Because the test case may not be able to detect all the test codes, the code detection apparatus may count the test coverage after detecting the test codes, so as to obtain the code coverage information of the test codes. The code coverage rate information includes code parameters of the unexecuted test code in the test code, and the code parameters can be code lines of the unexecuted test code, code execution times of the unexecuted test code, code effectiveness of the unexecuted test code and the like.
Subsequently, the code line acquisition unit 61 of the code function acquisition module 52 acquires the code line, i.e., the code position, of the unexecuted test code acquired by the code coverage information acquisition module.
Then, the code function acquiring unit 62 of the code function acquiring module 52 acquires a code function corresponding to the unexecuted test code at the code position. Since each line of test code may not be able to run independently, which is a part of a certain code function, here, the code function corresponding to the unexecuted test code is obtained through the code line of the unexecuted test code, so as to perform subsequent re-detection on the unexecuted test code.
Then, the upper calling function obtaining module 53 uses a static code scanning tool (e.g., underpant and doxygen, etc.) to scan the code function corresponding to the unexecuted test code obtained by the code function obtaining module 52, because the static code scanning tool includes the code function and the corresponding relationship of at least one upper calling function, the upper calling function is an upper function that can call the code function; the upper layer calling function obtaining module 53 can obtain the upper layer calling function corresponding to the code function.
The retest case acquisition module 54 acquires a retest case using the upper call function, based on the upper call function acquired by the upper call function acquisition module 53. The method specifically comprises the following steps:
the judging unit 71 of the retest case acquiring module 54 judges whether the number of times of use of the upper layer call function in the test case is zero; if the number of times of use of the upper layer call function in the test case is zero, which indicates that the upper layer call function has not been used in the previous test case, the retest case creation unit 72 of the retest case acquisition module 54 creates a retest case using the upper layer call function. If the number of times of using the upper layer call function in the test case is not zero, it indicates that the upper layer call function has been used in the previous test case, and therefore the retest case acquisition module 54 does not create the retest case using the upper layer call function.
Finally, the test module 55 uses the retest case obtained by the retest case obtaining module 54 to perform the code coverage test on the unexecuted test code obtained by the code coverage information obtaining module through a coverage test tool such as lcov. The retest case is set according to the unexecuted test code, so that complete detection of the code can be well completed.
This completes the code detection process of the code detection apparatus 50 of the present preferred embodiment.
On the basis of the first preferred embodiment, the code detection device of the present preferred embodiment uses a static code scanning tool to obtain the upper layer call function, so that the obtained upper layer call function is more comprehensive and accurate; the detection accuracy of the retest case is further improved by judging the use times of the upper layer call function.
The following describes a specific operation principle of the code detection method and the code detection apparatus according to the present invention by using a specific embodiment. Referring to fig. 8, fig. 8 is a flowchart illustrating a code detection method and a code detection apparatus according to an embodiment of the invention. The specific embodiment is implemented by using a code detection server, and the code detection process comprises the following steps:
step S801, the code detection apparatus performs a coverage test on the test code by using the test case through a coverage test tool lcov, and obtains code coverage information, such as code coverage information.
SF:/Applications/Xcode 3.app/X.m
FN:126,_CGPointApplyAffineTransform
FNDA:0,_CGPointApplyAffineTransform
FNF:1
FNH:0
DA:129,4098624
DA:130,4098624
DA:131,4098624
DA:132,0
LF:3
LH:3
End_of_record
Wherein SF is the file name; FN is function initial line and function name; FNDA is function execution times and a function name; FNF is the total number of functions; FNH is the number of executed functions in the total number of functions; DA is the code line number and the number of times the current line is executed; LF is the total number of effective lines of the code; LH is the number of executed effective lines in the total number of the code effective lines; end _ of _ record is the "record" end.
In step S802, it is known from step S801 that the code in line 132 is an unexecuted test code, and then the code testing apparatus obtains a code function corresponding to the unexecuted test code. The code function is M/shareUI _ MINputListView.m- [ MINputListView read ], and the knowledge base content corresponding to the code function is a loading function of the universal keyboard input view control.
In step S803, the code testing apparatus scans the code function corresponding to the unexecuted test code using two static code scanning tools, i.e., an understand and a doxygen, so as to obtain the upper layer call function corresponding to the code function. In this particular embodiment, the code function
M/shareUI _ MINputListView.m- [ MINputListView read ] is M/MADJUUSUUSEDTrafcView controller.m- [ MADJUsedUsedUsedTracfyViewControlviewDidload ], and the used traffic page and the operated traffic monitoring function are adjusted; and
m/mwallpapapernotificationcontroller M- [ mwallpapapernotificationcontroller viewdidladoad ], sets a local reminder page of a calendar and a calendar wallpaper setting function of an operation.
Step S804, the code testing apparatus obtains the number of times of using the traffic monitoring function and the calendar wallpaper setting function in the test case, where, for example, the number of times of using the traffic monitoring function in the test case is 0, and the number of times of using the calendar wallpaper setting function in the test case is 2, since the calendar wallpaper setting function has been used in the test case, the traffic monitoring function is used here to create a retest case, and the retest case may be, for example, a traffic monitoring case that monitors the traffic of the current game application of the terminal.
In step S805, the code testing apparatus performs a code coverage test on the unexecuted test code acquired in step S804 by using the retest case acquired in step S804. The retest case is set according to the unexecuted test code, so that complete detection of the code can be well completed.
Thus, the code detection process of the code test method of the present embodiment is completed.
According to the code detection method and the code detection device, the code coverage rate test is carried out on the unexecuted test code according to the retest case obtained by the upper layer calling function, so that the complete detection of the code can be better completed, and meanwhile, the detection cost is low, the detection time is short, and the detection steps are simpler; the technical problems that the existing code detection method and the code detection device are high in detection cost, long in detection time and complex in detection steps are solved.
As used herein, the terms "component," "module," "system," "interface," "process," and the like are generally intended to refer to a computer-related entity: hardware, a combination of hardware and software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a controller and the controller can be a component. One or more components can reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between two or more computers.
Furthermore, the claimed subject matter may be implemented as a method, apparatus, or article of manufacture using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to implement the disclosed subject matter. The term "article of manufacture" as used herein is intended to encompass a computer program accessible from any computer-readable device, carrier, or media. Of course, those skilled in the art will recognize many modifications may be made to this configuration without departing from the scope or spirit of the claimed subject matter.
FIG. 9 and the following discussion provide a brief, general description of an operating environment for an electronic device in which an information presentation device in accordance with the present invention may be implemented. The operating environment of FIG. 9 is only one example of a suitable operating environment and is not intended to suggest any limitation as to the scope of use or functionality of the operating environment. Example electronic devices 912 include, but are not limited to, personal computers, server computers, hand-held or laptop devices, mobile devices (such as mobile phones, Personal Digital Assistants (PDAs), media players, and the like), multiprocessor systems, consumer electronics, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like.
Although not required, embodiments are described in the general context of "computer readable instructions" being executed by one or more electronic devices. Computer readable instructions may be distributed via computer readable media (discussed below). Computer readable instructions may be implemented as program modules, such as functions, objects, Application Programming Interfaces (APIs), data structures, etc. that perform particular tasks or implement particular abstract data types. Typically, the functionality of the computer readable instructions may be combined or distributed as desired in various environments.
FIG. 9 illustrates an example of an electronic device 912 including one or more embodiments of the information presentation apparatus of the present invention. In one configuration, electronic device 912 includes at least one processing unit 916 and memory 918. Depending on the exact configuration and type of electronic device, memory 918 may be volatile (such as RAM), non-volatile (such as ROM, flash memory, etc.) or some combination of the two. This configuration is illustrated in fig. 9 by dashed line 914.
In other embodiments, electronic device 912 may include additional features and/or functionality. For example, device 912 may also include additional storage (e.g., removable and/or non-removable) including, but not limited to, magnetic storage, optical storage, and the like. Such additional storage is illustrated in fig. 9 by storage 920. In one embodiment, computer readable instructions to implement one or more embodiments provided herein may be in storage 920. Storage 920 may also store other computer readable instructions to implement an operating system, an application program, and the like. Computer readable instructions may be loaded in memory 918 for execution by processing unit 916, for example.
The term "computer readable media" as used herein includes computer storage media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions or other data. Memory 918 and storage 920 are examples of computer storage media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by electronic device 912. Any such computer storage media may be part of electronic device 912.
Electronic device 912 may also include communication connection 926 that allows electronic device 912 to communicate with other devices. Communication connection 926 may include, but is not limited to, a modem, a Network Interface Card (NIC), an integrated network interface, a radio frequency transmitter/receiver, an infrared port, a USB connection, or other interfaces for connecting electronic device 912 to other electronic devices. Communication connection 926 may include a wired connection or a wireless connection. Communication connection 926 may transmit and/or receive communication media.
The term "computer readable media" may include communication media. Communication media typically embodies computer readable instructions or other data in a "modulated data signal" such as a carrier wave or other transport mechanism and includes any information delivery media. The term "modulated data signal" may include signals that: one or more of the signal characteristics may be set or changed in such a manner as to encode information in the signal.
The electronic device 912 may include input device(s) 924 such as keyboard, mouse, pen, voice input device, touch input device, infrared camera, video input device, and/or any other input device. Output device(s) 922 such as one or more displays, speakers, printers, and/or any other output device may also be included in device 912. Input device 924 and output device 922 may be connected to electronic device 912 via a wired connection, wireless connection, or any combination thereof. In one embodiment, an input device or an output device from another electronic device may be used as input device 924 or output device 922 for electronic device 912.
Components of electronic device 912 may be connected by various interconnects, such as a bus. Such interconnects may include Peripheral Component Interconnect (PCI), such as PCI express, Universal Serial Bus (USB), firewire (IEEE1394), optical bus structures, and the like. In another embodiment, components of electronic device 912 may be interconnected by a network. For example, memory 918 may be comprised of multiple physical memory units located in different physical locations interconnected by a network.
Those skilled in the art will realize that storage devices utilized to store computer readable instructions may be distributed across a network. For example, an electronic device 930 accessible via a network 928 may store computer readable instructions to implement one or more embodiments provided by the present invention. Electronic device 912 may access electronic device 930 and download a part or all of the computer readable instructions for execution. Alternatively, electronic device 912 may download pieces of the computer readable instructions, as needed, or some instructions may be executed at electronic device 912 and some at electronic device 930.
Various operations of embodiments are provided herein. In one embodiment, the one or more operations may constitute computer readable instructions stored on one or more computer readable media, which when executed by an electronic device, will cause the computing device to perform the operations. The order in which some or all of the operations are described should not be construed as to imply that these operations are necessarily order dependent. Those skilled in the art will appreciate alternative orderings having the benefit of this description. Moreover, it should be understood that not all operations are necessarily present in each embodiment provided herein.
Also, as used herein, the word "preferred" is intended to serve as an example, instance, or illustration. Any aspect or design described herein as "preferred" is not necessarily to be construed as advantageous over other aspects or designs. Rather, use of the word "preferred" is intended to present concepts in a concrete fashion. The term "or" as used in this application is intended to mean an inclusive "or" rather than an exclusive "or". That is, unless specified otherwise or clear from context, "X employs A or B" is intended to include either of the permutations as a matter of course. That is, if X employs A; b is used as X; or X employs both A and B, then "X employs A or B" is satisfied in any of the foregoing examples.
Also, although the disclosure has been shown and described with respect to one or more implementations, equivalent alterations and modifications will occur to others skilled in the art based upon a reading and understanding of this specification and the annexed drawings. The present disclosure includes all such modifications and alterations, and is limited only by the scope of the appended claims. In particular regard to the various functions performed by the above described components (e.g., elements, resources, etc.), the terms used to describe such components are intended to correspond, unless otherwise indicated, to any component which performs the specified function of the described component (e.g., that is functionally equivalent), even though not structurally equivalent to the disclosed structure which performs the function in the herein illustrated exemplary implementations of the disclosure. In addition, while a particular feature of the disclosure may have been disclosed with respect to only one of several implementations, such feature may be combined with one or more other features of the other implementations as may be desired and advantageous for a given or particular application. Furthermore, to the extent that the terms "includes," has, "" contains, "or variants thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term" comprising.
Each functional unit in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium. The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. Each apparatus or system described above may perform the method in the corresponding method embodiment.
In summary, although the present invention has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present invention, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention, therefore, the scope of the present invention shall be determined by the appended claims.

Claims (9)

1. A code detection method, comprising:
performing code coverage rate test on the test code by using the test case to acquire code coverage rate information of the test code; wherein the code coverage information comprises code parameters of unexecuted test code;
acquiring a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code;
acquiring an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code;
obtaining a corresponding retest case according to the upper layer call function, wherein the obtaining of the corresponding retest case comprises the following steps:
judging whether the use times of the upper layer calling function in the test case is zero or not;
if the value is zero, the retest case is created by using the upper layer calling function; and
and performing code coverage rate test on the unexecuted test code by using the retest case.
2. The code detection method according to claim 1, wherein the step of performing the code coverage test on the test code by using the test case specifically comprises:
performing code coverage test on the test code by using the test case through a coverage test tool;
the step of performing the code coverage rate test on the unexecuted test code by using the retest case specifically comprises:
and performing code coverage rate testing on the unexecuted test code by using the retest case through the coverage rate testing tool.
3. The code detection method according to claim 1, wherein the step of obtaining the code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code comprises:
acquiring a code line of the unexecuted test code; and
and acquiring a code function corresponding to the code line of the unexecuted test code.
4. The code detection method according to claim 1, wherein the step of obtaining, according to the code function corresponding to the unexecuted test code, the upper-layer call function corresponding to the code function includes:
and scanning a code function corresponding to the unexecuted test code by using a static code scanning tool to obtain an upper layer calling function corresponding to the code function, wherein the static code scanning tool comprises a corresponding relation between the code function and at least one upper layer calling function.
5. A code detection apparatus, comprising:
the code coverage rate information acquisition module is used for carrying out code coverage rate test on the test codes by using the test cases so as to acquire the code coverage rate information of the test codes; wherein the code coverage information comprises code parameters of unexecuted test code;
the code function acquisition module is used for acquiring a code function corresponding to the unexecuted test code according to the code parameter of the unexecuted test code;
the upper layer calling function obtaining module is used for obtaining an upper layer calling function corresponding to the code function according to the code function corresponding to the unexecuted test code;
the retest case acquisition module is used for acquiring a corresponding retest case according to the upper layer calling function; the retest case acquisition module includes:
the judging unit is used for judging whether the using times of the upper layer calling function in the test case is zero or not; and
a retest case creation unit configured to create the retest case using the upper layer call function; and
and the testing module is used for carrying out code coverage rate testing on the unexecuted testing code by using the retest case.
6. The code detection apparatus according to claim 5, wherein the code coverage information obtaining module is specifically configured to perform a code coverage test on the test code by using a test case through a coverage test tool;
the test module is specifically configured to perform, by using the retest case, a code coverage test on the unexecuted test code by using the coverage test tool.
7. The code detection apparatus according to claim 5, wherein the code function obtaining module comprises:
a code line acquisition unit, configured to acquire a code line of the unexecuted test code; and
and the code function acquisition unit is used for acquiring a code function corresponding to the code line of the unexecuted test code.
8. The code detection apparatus according to claim 5, wherein the upper layer calling function obtaining module is specifically configured to scan a code function corresponding to the unexecuted test code using a static code scanning tool to obtain an upper layer calling function corresponding to the code function, where the static code scanning tool includes a correspondence between the code function and at least one upper layer calling function.
9. A computer readable storage medium having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, which is loaded and executed by a processor to implement a code detection method according to any one of claims 1 to 4.
CN201610122040.2A 2016-03-02 2016-03-02 Code detection method and code detection device Active CN107153608B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610122040.2A CN107153608B (en) 2016-03-02 2016-03-02 Code detection method and code detection device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610122040.2A CN107153608B (en) 2016-03-02 2016-03-02 Code detection method and code detection device

Publications (2)

Publication Number Publication Date
CN107153608A CN107153608A (en) 2017-09-12
CN107153608B true CN107153608B (en) 2020-06-26

Family

ID=59791466

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610122040.2A Active CN107153608B (en) 2016-03-02 2016-03-02 Code detection method and code detection device

Country Status (1)

Country Link
CN (1) CN107153608B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110134582A (en) * 2019-04-03 2019-08-16 口碑(上海)信息技术有限公司 The processing of test case and data processing method and device
CN110321144B (en) * 2019-06-27 2025-03-25 深圳前海微众银行股份有限公司 Offline source code identification method, device, equipment and storage medium
CN112416773B (en) * 2020-11-23 2024-10-01 通号万全信号设备有限公司 Cross-platform data visualization method
CN112685312B (en) * 2020-12-31 2024-07-02 广州品唯软件有限公司 Test case recommendation method and device for uncovered codes
CN113704094B (en) * 2021-08-06 2024-10-22 北京城市网邻信息技术有限公司 Test case knowledge base construction method and device, electronic equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090265694A1 (en) * 2008-04-18 2009-10-22 International Business Machines Corporation Method and system for test failure analysis prioritization for software code testing in automated test execution
CN103473171B (en) * 2013-08-28 2016-06-08 北京信息科技大学 A kind of fraction of coverage calling path based on function dynamically follows the tracks of method and device
CN103699385A (en) * 2013-12-23 2014-04-02 国云科技股份有限公司 Continuous code integration method

Also Published As

Publication number Publication date
CN107153608A (en) 2017-09-12

Similar Documents

Publication Publication Date Title
CN107153608B (en) Code detection method and code detection device
CN106469165B (en) Bullet screen display method and bullet screen display device
CN106888236B (en) Session management method and session management device
CN113282488B (en) Terminal test method and device, storage medium and terminal
CN111079125A (en) Method and device for calling third-party library dynamic lifting authority by application program
CN110084298B (en) Method and device for detecting image similarity
CN110134604A (en) A method, device and computer equipment for unit or interface testing without code
CN112395188B (en) Test-oriented software project development method and device, electronic equipment and storage medium
CN111506904A (en) Method and device for online vulnerability repair
CN110673986A (en) Memory operation abnormity capturing method, device, terminal and storage medium
CN110889116B (en) Advertisement interception method and device and electronic equipment
CN110674050A (en) Memory out-of-range detection method and device, electronic equipment and computer storage medium
CN106844219A (en) Using detection method and apply detection means
CN113010416A (en) Bank counter transaction automatic testing method and device
CN107133169B (en) Application test packet generation method and generation device
CN109408387B (en) Page testing method and device
CN112818331A (en) Adb tool encryption control method, device, equipment and storage medium
CN111124627B (en) Method and device for determining call initiator of application program, terminal and storage medium
CN111125015B (en) Method, device, terminal and medium for classifying dump files
CN107515821B (en) Control testing method and device
CN116909823A (en) GPU pressure testing method and device, electronic equipment and storage medium
CN113986517B (en) API call log acquisition method and device, electronic equipment and storage medium
CN104572450B (en) A kind of method and device for detecting resource distribution
CN111258797B (en) Memory leak detection method, device, medium and electronic equipment
CN115168195A (en) Automatic testing method, system, 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
GR01 Patent grant
GR01 Patent grant