CN112579475A - Code testing method, device, equipment and readable storage medium - Google Patents
Code testing method, device, equipment and readable storage medium Download PDFInfo
- Publication number
- CN112579475A CN112579475A CN202011638116.XA CN202011638116A CN112579475A CN 112579475 A CN112579475 A CN 112579475A CN 202011638116 A CN202011638116 A CN 202011638116A CN 112579475 A CN112579475 A CN 112579475A
- Authority
- CN
- China
- Prior art keywords
- code
- test
- target
- test result
- branch
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3676—Test management for coverage analysis
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3692—Test 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 invention relates to a test management technology, and discloses a code test method, which comprises the following steps: responding to a code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code; configuring the dependency relationship of the branch codes to obtain target codes; performing interface test, operation test and code coverage rate test on the target code to obtain a target test result; and sending the target test result to terminal equipment corresponding to the code test request initiator. The invention also relates to a block chain technology, and the target test result can be deployed in the block chain. The invention also provides a code testing device, an electronic device and a readable storage medium. The invention can improve the efficiency of code testing.
Description
Technical Field
The present invention relates to the field of test management, and in particular, to a code testing method and apparatus, an electronic device, and a readable storage medium.
Background
With the rapid development of the internet technology, the software development technology becomes an important engine for boosting the internet technology, and therefore, the code test in the software development process is more and more emphasized by people.
However, the existing code testing method is affected by the overall progress of the code, the code needs to be tested after the development is completed, the newly added code cannot be tested in real time, the problem in the development cannot be fed back in time, and the testing efficiency is low.
Disclosure of Invention
The invention provides a code testing method, a code testing device, electronic equipment and a computer readable storage medium, and mainly aims to improve the code testing efficiency.
In order to achieve the above object, the present invention provides a code testing method, including:
responding to a code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code;
configuring the dependency relationship of the branch codes to obtain target codes;
performing interface test, operation test and code coverage rate test on the target code to obtain a target test result;
and sending the target test result to terminal equipment corresponding to the code test request initiator.
Optionally, the obtaining a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code includes:
extracting a code path in the code test request;
acquiring the code to be tested in a preset code library according to the code path;
and writing the code to be tested into a pre-constructed extension branch to obtain the branch code.
Optionally, the performing an interface test, an operation test, and a code coverage test on the target code to obtain a target test result includes:
sending an interface state and an interface delay test request to an interface of the target code by using the interface code test to obtain an interface test result;
compiling the object code in a preset running environment by using a preset test frame to obtain a running test result;
carrying out code coverage rate test on the target code to obtain a code coverage rate test result;
and summarizing the interface test result, the operation result and the code coverage rate test result to obtain the target test result.
Optionally, the performing a code coverage test on the target code to obtain a code coverage test result includes:
performing instrumentation on the target code to obtain a target code instrumentation file;
acquiring a preset main branch code according to the target code, merging the main branch code and the target code to obtain a system source code, and packaging the system source code to obtain a system operation package;
carrying out target code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file;
and calculating and analyzing according to the test code instrumentation file and the target code instrumentation file to obtain a code coverage rate test result.
Optionally, the performing, by using a preset system tester, an object code operation test on the system operation package to obtain a test code instrumentation file includes:
testing the target code of the system operation package by using a local testing machine to obtain a local test result;
testing the target code of the system operation package by using a server testing machine to obtain a server testing result;
and combining the local test result and the server test result to obtain the test code instrumentation file.
Optionally, the performing dependency configuration on the branch code to obtain a target code includes:
analyzing the branch codes to obtain dependency relationship information;
extracting calling path information in the dependency relationship information;
and acquiring a corresponding dependent code in a preset code library according to the calling path information, and inserting the dependent code into the branch code to obtain the target code.
Optionally, the sending the target test result to the terminal device corresponding to the code test request initiator includes:
judging whether the target test result is normal or not;
if the target test result is normal, merging the extension branch where the target code is located to a preset code main branch corresponding to the extension branch, and sending the target test result to terminal equipment corresponding to the code test request initiator;
and if the target test result is abnormal, sending the target test result to the terminal equipment corresponding to the code test request initiator.
In order to solve the above problem, the present invention also provides a code testing apparatus, including:
the code configuration module is used for responding to a code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code; configuring the dependency relationship of the branch codes to obtain target codes;
the code testing module is used for carrying out interface testing, operation testing and code coverage rate testing on the target code to obtain a target testing result;
and the test result pushing module is used for sending the target test result to the terminal equipment corresponding to the code test request initiator.
In order to solve the above problem, the present invention also provides an electronic device, including:
a memory storing at least one computer program; and
and the processor executes the computer program stored in the memory to realize the code testing method.
In order to solve the above problem, the present invention also provides a computer-readable storage medium having at least one computer program stored therein, the at least one computer program being executed by a processor in an electronic device to implement the code testing method described above.
According to the embodiment of the invention, the code to be tested is obtained according to the code test request, and the code to be tested is subjected to code isolation configuration to obtain the branch code, so that the code test is more flexible, is not influenced by the main branch code, and has higher efficiency; the dependency relationship configuration is carried out on the branch codes to obtain target codes, so that the code calling time is saved, and the efficiency of subsequent code testing is improved; performing interface test, operation test and code coverage rate test on the target code to obtain a target test result; and sending the target test result to the terminal equipment corresponding to the code test request initiator, flexibly performing code acceptance and combination according to the test result, not influencing the overall progress of code development, and being safer and more efficient. Therefore, the code testing method, the code testing device, the electronic equipment and the computer-readable storage medium provided by the embodiment of the invention improve the code testing efficiency.
Drawings
FIG. 1 is a flowchart illustrating a code testing method according to an embodiment of the present invention;
FIG. 2 is a detailed flowchart illustrating obtaining the code coverage test result according to an embodiment of the present invention;
FIG. 3 is a detailed flowchart illustrating obtaining the instrumentation file of the test code according to an embodiment of the present invention;
FIG. 4 is a block diagram of a code testing apparatus according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an internal structure of an electronic device implementing a code testing method according to an embodiment of the present invention;
the implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the invention provides a code testing method. The execution subject of the code testing method includes, but is not limited to, at least one of electronic devices such as a server and a terminal, which can be configured to execute the method provided by the embodiments of the present application. In other words, the code testing method may be performed by software or hardware installed in the terminal device or the server device, and the software may be a block chain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like.
Referring to fig. 1, a flowchart of a code testing method according to an embodiment of the present invention is shown, where in the embodiment of the present invention, the code testing method includes:
s1, responding to the code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code;
in the embodiment of the invention, the code test request is test request information of a newly added function code developed by a developer of a certain company, and the code test request comprises function information of code realization and a code path, wherein the code path is a storage path of the code in a code library.
Further, the obtaining of the code to be tested according to the code test request in the embodiment of the present invention includes: and extracting a code path in the code test request, and acquiring a code to be tested in a preset code library according to the code path, wherein the code library can be a Git warehouse managed in a GitHub.
Because the stability and functionality of the code to be tested are verified, the code to be tested cannot be directly written into a preset code main branch, wherein the code main branch is a code main branch in a development project corresponding to the target code, and therefore, a code isolation configuration operation needs to be performed on the code to be tested, and the code to be tested is prevented from influencing the code main branch, the method includes: and writing the code to be tested into a pre-constructed extension branch to obtain the branch code, wherein the extension branch is a feature branch, and the main branch is a master branch.
S2, carrying out dependency configuration on the branch codes to obtain target codes;
in order to better test the branch code, in an embodiment of the present invention, performing dependency configuration on the branch code to obtain the target code includes: and analyzing the branch codes to obtain the dependency relationship information. The dependency relationship information sign may be related information of a dependent code, and includes: the method comprises the steps of calling paths of the dependent codes and place occupying keywords of the dependent codes, wherein the calling paths are storage paths of the dependent codes, and the place occupying keywords are keywords representing the dependent codes in the branch codes. For example, the branch code includes a function module code 01, and the function module code 01 implements a module function by calling a function module code 02 in a preset code library, so that the function module code 01 depends on the function module code 02, and the related information of the function module code 02 called in the branch code is dependency relationship information, including: the calling path information of the function module code 02 and the position occupying key words of the function module code 02. In specific implementation, the program development end may analyze the branch code in various ways to obtain the dependency relationship information. For example, the branch code may be directly subjected to character string analysis, and the dependency information may be analyzed in the branch code.
Further, in the embodiment of the present invention, the call path information in the dependency relationship information is extracted, the corresponding dependency code is obtained in a preset code library according to the call path information, and the dependency code is inserted into the branch code, so as to obtain the target code. Further, in the embodiment of the present invention, inserting the dependent code into the branch code includes: and extracting place-occupying keywords in the dependency relationship information, and replacing the place-occupying keywords in the branch codes with the dependency codes to obtain the target codes.
According to the embodiment of the invention, the target code is obtained by configuring the dependency relationship of the branch code, so that the code calling time is saved, and the efficiency of subsequent code testing is improved.
S3, performing interface test, operation test and code coverage rate test on the target code to obtain a target test result;
in the embodiment of the present invention, an interface test code is constructed according to a preset test rule, and an interface state and an interface delay test request are sent to an interface of the target code by using the interface code test to obtain an interface test result.
Further, in the embodiment of the present invention, the object code is compiled in a preset operating environment by using a preset test framework to obtain an operating test result, where the test framework is a Web UI automation test framework, the preset operating environments are different browser environments, and then the object code is called and compiled in different browser environments, if the object code can be compiled and run normally in the preset operating environment, it represents that the object code can run compatibly in the preset operating environment, that is, the operating result is normal, and if the object code cannot be compiled and run normally in the preset operating environment, it represents that the object code cannot run compatibly in the preset operating environment, that is, the operating result is abnormal.
Since the object code is in a specific development system, in order to test the object code more conveniently, another embodiment of the present invention may further perform an interface test and an operation test on the object code through a preset proxy server.
Further, the target code operation test can only test the operation condition of the target code, and cannot reflect the influence of the target code on the whole project code, and in order to test the influence of the target on the whole project code, the target code is subjected to a code coverage rate test.
In detail, referring to fig. 2, in the embodiment of the present invention, the performing a code coverage test on the target code includes:
s31, performing instrumentation on the target code to obtain a target code instrumentation file;
further, in the embodiment of the present invention, the target code is instrumented to form a target code instrumentation file, which is used to compare with a code instrumentation file tested subsequently to obtain a code coverage rate. Preferably, the code instrumentation file in the present invention includes: the method comprises the steps of code lines for marking instrumented code in the line number of system source code, code parameters and a configuration file, wherein the code parameters refer to instrumented code content, and the configuration file is used for characterizing instrumented code logic.
In detail, the instrumentation of the object code to form an object code instrumentation file includes: identifying whether code instrumentation limit points exist in the target code; if no code instrumentation limit point exists, marking an instrumentation point in the target code by using a code instrumentation statement; if the code instrumentation limit points exist, utilizing the code instrumentation statements to mark instrumentation points at the tail ends of the code lines of the target codes; and acquiring a code line and a configuration file of the target code, and summarizing the code line, the configuration file and the pile inserting points to obtain the target code pile inserting file.
Preferably, the code instrumentation restriction point comprises: functions, objects, classes, etc., the code instrumentation constraint points are identified by js scripts.
Preferably, the code instrumentation statement is compiled through a JavaScript script, and the instrumentation point is used for marking the target code.
The instrumentation based on the target code avoids instrumentation tests on all source codes of the system project, and prevents instrumentation codes from mixing into the source codes of the system according to code instrumentation limit points.
Further, the embodiment of the invention also comprises the step of uploading the target code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
S32, acquiring a preset main branch code according to the target code, merging the main branch code and the target code to obtain a system source code, and packaging the system source code to obtain a system operation package;
in the embodiment of the invention, the main branch code is a code in a main branch of a code in a development project corresponding to the target code; the main branch code is obtained through a preset code identification script, wherein the preset code identification script is compiled through a JavaScript language.
In at least one embodiment of the present invention, the packaging the system source code to obtain a system operation package includes: acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment; and storing the system source code into the local warehouse according to the storage dependence to form a system operation package.
Wherein, the code compiling environment is an integrated environment for compiling the system source code, such as Myeclipse, Eclipse, sublime, etc.; the storage dependency refers to a directory location where the system source code is stored; the local warehouse can be a maven warehouse, the format of the system operation package is jar package, and the system operation package can be operated in a front-end browser.
And S33, carrying out target code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file.
In a preferred embodiment of the present invention, the preset system tester includes a local tester and a server tester, and the code instrumentation file test of the local tester and the server tester can more comprehensively understand the running coverage of the target code in the system running package, so that the code coverage of the target code can be more accurately tested. Preferably, the server tester is a hit tester.
In detail, referring to fig. 3, the performing, by using a preset system tester, an object code operation test on the system operation package to obtain a test code instrumentation file includes:
s41, testing the object code of the system operation package by using a local testing machine to obtain a local test result;
s42, testing the object code of the system operation package by using a server testing machine to obtain a server test result;
and S43, combining the local test result and the server test result to obtain the test code instrumentation file.
Wherein the S41 includes: and running the object code of the system running package by using the local testing machine, and recording the coverage record of the object code of the system running package when the object code runs in the local testing machine until the object code of the system running package finishes running in the local testing machine, thereby obtaining a local testing result. Wherein the overlay record of the object code is recorded by a get () command in the local tester.
Further, the local test result and the server test result are merged, that is, the local test result and the server test result are averaged.
Further, it is to be stated that the test code instrumentation file includes: run code lines, run code parameters, and run configuration files for the object code.
Furthermore, the embodiment of the invention also comprises the step of uploading the test code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
And S34, calculating and analyzing according to the test code instrumentation file and the target code instrumentation file to obtain a code coverage rate test result.
In a preferred implementation of the present invention, the code coverage of the test code instrumentation file and the target code instrumentation file is calculated in the server, which can ensure the safety of the calculation environment of the code coverage.
In an alternative embodiment, the code coverage of the test code instrumentation file and the target code instrumentation file is calculated using the following method:
ρX,Y=E(XY+μXμY+σXσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the target code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing object code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXConfiguration file, sigma, representing instrumentation files for test codesYAnd E represents the expected code coverage rate of the test code instrumentation file and the target code instrumentation file.
Further, according to the code coverage rate, a code coverage rate test result is obtained, and the higher the code coverage rate is, the smaller the influence of the target code on the whole project code is proved to be, the more stable the target code is, so that if the code coverage rate is lower than a preset coverage rate threshold value, the coverage rate test result is normal; if the code coverage rate is not lower than a preset coverage rate threshold value, the coverage rate test result is abnormal, and the interface test result, the operation result and the coverage rate test result are summarized to obtain the target result.
In another embodiment of the present invention, in order to ensure the privacy of data, the target test result may be stored in a block link point.
And S4, sending the target test result to the terminal equipment corresponding to the code test request initiator.
In the embodiment of the present invention, sending the target test result to the terminal device corresponding to the code test request initiator includes: and judging whether the target test result is normal or not, wherein if the interface test result, the operation result and the coverage rate test result are normal, the target test result is normal, and if any one of the interface test result, the operation result and the coverage rate test result is abnormal, the target test result is abnormal. Further, if the target test result is normal, merging the extension branch where the target code is located to a preset code main branch corresponding to the extension branch, sending the target test result to terminal equipment corresponding to the code test request initiator, and completing the code test, wherein the code main branch is a code main branch in a development project corresponding to the target code; and if the target test result is abnormal, sending the target test result to the terminal equipment corresponding to the code test request initiator to complete the code test.
FIG. 4 is a functional block diagram of the code testing apparatus according to the present invention.
The code testing apparatus 100 of the present invention may be installed in an electronic device. According to the implemented functions, the code testing device may include a text processing module 101, an image processing module 102, and an answer calculation pushing module 103, which may also be referred to as a unit, and refers to a series of computer program segments that can be executed by a processor of an electronic device and can perform fixed functions, and are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the code configuration module 101 is configured to respond to a code test request, obtain a code to be tested according to the code test request, and perform code isolation configuration on the code to be tested to obtain a branch code; and carrying out dependency configuration on the branch codes to obtain target codes.
In the embodiment of the invention, the code test request is test request information of a newly added function code developed by a developer of a certain company, and the code test request comprises function information of code realization and a code path, wherein the code path is a storage path of the code in a code library.
Further, in the embodiment of the present invention, the obtaining, by the code configuration module 101, a code to be tested according to the code test request includes: and extracting a code path in the code test request, and acquiring a code to be tested in a preset code library according to the code path, wherein the code library can be a Git warehouse managed in a GitHub.
Since the stability and functionality of the code to be tested are verified, the code to be tested cannot be directly written into a preset code main branch, where the code main branch is a code main branch in a development project corresponding to the target code, and therefore, the code configuration module 101 needs to perform code isolation configuration operation on the code to be tested, so as to prevent the code to be tested from affecting the code main branch, including: and writing the code to be tested into a pre-constructed extension branch to obtain the branch code, wherein the extension branch is a feature branch, and the main branch is a master branch.
In order to better test the branch code, in an embodiment of the present invention, the code configuration module 101 performs dependency configuration on the branch code to obtain the target code, where the operation of the branch code may need to depend on other functional codes, and the calling between different codes is time-consuming and affects efficiency of code testing, and includes: and analyzing the branch codes to obtain the dependency relationship information. The dependency relationship information sign may be related information of a dependent code, and includes: the method comprises the steps of calling paths of the dependent codes and place occupying keywords of the dependent codes, wherein the calling paths are storage paths of the dependent codes, and the place occupying keywords are keywords representing the dependent codes in the branch codes. For example, the branch code includes a function module code 01, and the function module code 01 implements a module function by calling a function module code 02 in a preset code library, so that the function module code 01 depends on the function module code 02, and the related information of the function module code 02 called in the branch code is dependency relationship information, including: the calling path information of the function module code 02 and the position occupying key words of the function module code 02. In specific implementation, the program development end may analyze the branch code in various ways to obtain the dependency relationship information. For example, the branch code may be directly subjected to character string analysis, and the dependency information may be analyzed in the branch code.
Further, in the embodiment of the present invention, the code configuration module 101 extracts call path information in the dependency relationship information, obtains a corresponding dependency code in a preset code library according to the call path information, and inserts the dependency code into the branch code to obtain the target code. Further, in this embodiment of the present invention, the inserting the dependent code into the branch code by the code configuration module 101 includes: and extracting place-occupying keywords in the dependency relationship information, and replacing the place-occupying keywords in the branch codes with the dependency codes to obtain the target codes.
According to the embodiment of the invention, the target code is obtained by configuring the dependency relationship of the branch code, so that the code calling time is saved, and the efficiency of subsequent code testing is improved.
The code testing module 102 is configured to perform an interface test, an operation test, and a code coverage test on the target code to obtain a target test result.
In this embodiment of the present invention, the code testing module 102 constructs an interface testing code according to a preset testing rule, and sends an interface state and an interface delay testing request to an interface of the target code by using the interface code test to obtain an interface testing result.
Further, in the embodiment of the present invention, the code testing module 102 compiles the object code in a preset operating environment by using a preset testing framework to obtain an operating testing result, where the testing framework is a Web UI automation testing framework, the preset operating environments are different browser environments, and then calls and compiles the object code in different browser environments, and if the object code can be compiled and run normally in the preset operating environment, it means that the object code can run compatibly in the preset operating environment, that is, the operating result is normal, and if the object code cannot be compiled and run normally in the preset operating environment, it means that the object code cannot run compatibly in the preset operating environment, that is, the operating result is abnormal.
Since the object code is in a specific development system, in order to test the object code more conveniently, the code testing module 102 according to another embodiment of the present invention may further perform an interface test and an operation test on the object code through a preset proxy server.
Further, the target code running test may only test the running condition of the target code, and may not reflect the influence of the target code on the entire project code, and in order to test the influence of the target on the entire project code, the code testing module 102 performs a code coverage rate test on the target code.
In detail, in the embodiment of the present invention, the code coverage rate test on the target code by the code test module 102 by using the following means includes:
performing instrumentation on the target code to obtain a target code instrumentation file;
further, in the embodiment of the present invention, the target code is instrumented to form a target code instrumentation file, which is used to compare with a code instrumentation file tested subsequently to obtain a code coverage rate. Preferably, the code instrumentation file in the present invention includes: the method comprises the steps of code lines for marking instrumented code in the line number of system source code, code parameters and a configuration file, wherein the code parameters refer to instrumented code content, and the configuration file is used for characterizing instrumented code logic.
In detail, the instrumentation of the object code to form an object code instrumentation file includes: identifying whether code instrumentation limit points exist in the target code; if no code instrumentation limit point exists, marking an instrumentation point in the target code by using a code instrumentation statement; if the code instrumentation limit points exist, utilizing the code instrumentation statements to mark instrumentation points at the tail ends of the code lines of the target codes; and acquiring a code line and a configuration file of the target code, and summarizing the code line, the configuration file and the pile inserting points to obtain the target code pile inserting file.
Preferably, the code instrumentation restriction point comprises: functions, objects, classes, etc., the code instrumentation constraint points are identified by js scripts.
Preferably, the code instrumentation statement is compiled through a JavaScript script, and the instrumentation point is used for marking the target code.
The instrumentation based on the target code avoids instrumentation tests on all source codes of the system project, and prevents instrumentation codes from mixing into the source codes of the system according to code instrumentation limit points.
Further, the embodiment of the invention also comprises the step of uploading the target code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
And acquiring a preset main branch code according to the target code, merging the main branch code and the target code to obtain a system source code, and packaging the system source code to obtain a system operation package.
In the embodiment of the invention, the main branch code is a code in a main branch of a code in a development project corresponding to the target code; the main branch code is obtained through a preset code identification script, wherein the preset code identification script is compiled through a JavaScript language.
In at least one embodiment of the present invention, the packaging the system source code to obtain a system operation package includes: acquiring a code compiling environment of the system source code, and establishing storage dependence of the system source code and a local warehouse in the code compiling environment; and storing the system source code into the local warehouse according to the storage dependence to form a system operation package.
Wherein, the code compiling environment is an integrated environment for compiling the system source code, such as Myeclipse, Eclipse, sublime, etc.; the storage dependency refers to a directory location where the system source code is stored; the local warehouse can be a maven warehouse, the format of the system operation package is jar package, and the system operation package can be operated in a front-end browser.
And carrying out target code testing on the system operation package by using a preset system testing machine to obtain a test code instrumentation file.
In a preferred embodiment of the present invention, the preset system tester includes a local tester and a server tester, and the code instrumentation file test of the local tester and the server tester can more comprehensively understand the running coverage of the target code in the system running package, so that the code coverage of the target code can be more accurately tested. Preferably, the server tester is a hit tester.
In detail, the code testing module 102 performs the target code running test on the system running package by using the following means to obtain a test code instrumentation file, including:
testing the target code of the system operation package by using a local testing machine to obtain a local test result;
testing the target code of the system operation package by using a server testing machine to obtain a server testing result;
and combining the local test result and the server test result to obtain the test code instrumentation file.
The code testing module 102 tests the target code of the system operation package by using the following means to obtain a local test result; the method comprises the following steps: and running the object code of the system running package by using the local testing machine, and recording the coverage record of the object code of the system running package when the object code runs in the local testing machine until the object code of the system running package finishes running in the local testing machine, thereby obtaining a local testing result. Wherein the overlay record of the object code is recorded by a get () command in the local tester.
Further, the local test result and the server test result are merged, that is, the local test result and the server test result are averaged.
Further, it is to be stated that the test code instrumentation file includes: run code lines, run code parameters, and run configuration files for the object code.
Furthermore, the embodiment of the invention also comprises the step of uploading the test code instrumentation file to a server, so that the safety of the code coverage rate test is ensured.
And calculating and analyzing according to the test code instrumentation file and the target code instrumentation file to obtain a code coverage rate test result.
In a preferred implementation of the present invention, the code coverage of the test code instrumentation file and the target code instrumentation file is calculated in the server, which can ensure the safety of the calculation environment of the code coverage.
In an alternative embodiment, the code coverage of the test code instrumentation file and the target code instrumentation file is calculated using the following method:
ρx,Y=E(XY+μXμY+σXσY)
where ρ isX,YRepresenting code coverage, X representing the code line of the target code instrumentation file, Y representing the code line of the test code instrumentation file,. mu.XCode parameter, μ, representing object code instrumentation fileYCode parameter, σ, representing a test code instrumentation fileXConfiguration file, sigma, representing instrumentation files for test codesYAnd E represents the expected code coverage rate of the test code instrumentation file and the target code instrumentation file.
Further, according to the code coverage rate, a code coverage rate test result is obtained, and the higher the code coverage rate is, the smaller the influence of the target code on the whole project code is proved to be, the more stable the target code is, so that if the code coverage rate is lower than a preset coverage rate threshold value, the coverage rate test result is normal; if the code coverage rate is not lower than a preset coverage rate threshold value, the coverage rate test result is abnormal, and the interface test result, the operation result and the coverage rate test result are summarized to obtain the target result.
In another embodiment of the present invention, in order to ensure the privacy of data, the target test result may be stored in a block link point.
The test result pushing module 103 is configured to send the target test result to a terminal device corresponding to the code test request initiator.
In this embodiment of the present invention, the sending module 103 sends the target test result to the terminal device corresponding to the code test request initiator by using the following means, including: and judging whether the target test result is normal or not, wherein if the interface test result, the operation result and the coverage rate test result are normal, the target test result is normal, and if any one of the interface test result, the operation result and the coverage rate test result is abnormal, the target test result is abnormal. Further, if the target test result is normal, merging the extension branch where the target code is located to a preset code main branch corresponding to the extension branch, sending the target test result to terminal equipment corresponding to the code test request initiator, and completing the code test, wherein the code main branch is a code main branch in a development project corresponding to the target code; and if the target test result is abnormal, sending the target test result to the terminal equipment corresponding to the code test request initiator to complete the code test.
Fig. 5 is a schematic structural diagram of an electronic device implementing the code testing method according to the present invention.
The electronic device 1 may comprise a processor 10, a memory 11 and a bus, and may further comprise a computer program, such as a code test program 12, stored in the memory 11 and executable on the processor 10.
The memory 11 includes at least one type of readable storage medium, which includes flash memory, removable hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device 1, such as a removable hard disk of the electronic device 1. The memory 11 may also be an external storage device of the electronic device 1 in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device 1. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device 1. The memory 11 may be used not only to store application software installed in the electronic device 1 and various types of data, such as codes of a code test program, etc., but also to temporarily store data that has been output or is to be output.
The processor 10 may be composed of an integrated circuit in some embodiments, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same or different functions, including one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the whole electronic device by using various interfaces and lines, and executes various functions and processes data of the electronic device 1 by running or executing programs or modules (e.g., code test programs, etc.) stored in the memory 11 and calling data stored in the memory 11.
The bus may be a PerIPheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
Fig. 5 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device 1 may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so as to implement functions of charge management, discharge management, power consumption management, and the like through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device 1 may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
Further, the electronic device 1 may further include a network interface, and optionally, the network interface may include a wired interface and/or a wireless interface (such as a WI-FI interface, a bluetooth interface, etc.), which are generally used for establishing a communication connection between the electronic device 1 and other electronic devices.
Optionally, the electronic device 1 may further comprise a user interface, which may be a Display (Display), an input unit (such as a Keyboard), and optionally a standard wired interface, a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in the electronic device 1 and for displaying a visualized user interface, among other things.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The code test program 12 stored in the memory 11 of the electronic device 1 is a combination of a plurality of computer programs, which when run in the processor 10, may implement:
responding to a code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code;
configuring the dependency relationship of the branch codes to obtain target codes;
performing interface test, operation test and code coverage rate test on the target code to obtain a target test result;
and sending the target test result to terminal equipment corresponding to the code test request initiator.
Specifically, the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to fig. 1 for a specific implementation method of the computer program, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. The computer readable medium may be non-volatile or volatile. The computer-readable medium may include: any entity or device capable of carrying said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
Embodiments of the present invention may also provide a computer-readable storage medium, where the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program may implement:
responding to a code test request, acquiring a code to be tested according to the code test request, and performing code isolation configuration on the code to be tested to obtain a branch code;
configuring the dependency relationship of the branch codes to obtain target codes;
performing interface test, operation test and code coverage rate test on the target code to obtain a target test result;
and sending the target test result to terminal equipment corresponding to the code test request initiator.
Further, the computer usable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
Furthermore, it is obvious that the word "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011638116.XA CN112579475A (en) | 2020-12-31 | 2020-12-31 | Code testing method, device, equipment and readable storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202011638116.XA CN112579475A (en) | 2020-12-31 | 2020-12-31 | Code testing method, device, equipment and readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN112579475A true CN112579475A (en) | 2021-03-30 |
Family
ID=75145204
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202011638116.XA Pending CN112579475A (en) | 2020-12-31 | 2020-12-31 | Code testing method, device, equipment and readable storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN112579475A (en) |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113626325A (en) * | 2021-08-05 | 2021-11-09 | 杭州遥望网络科技有限公司 | Interface testing method, device and equipment in code iterative updating |
| CN114416537A (en) * | 2021-12-30 | 2022-04-29 | 浙江吉利控股集团有限公司 | Unit testing method, server, client and storage medium |
| CN115357474A (en) * | 2022-07-11 | 2022-11-18 | 深圳壹账通智能科技有限公司 | Local test method, device, equipment and storage medium |
| GB2619324A (en) * | 2022-05-31 | 2023-12-06 | The Court Of Edinburgh Napier Univ | Software management system |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107450933A (en) * | 2017-08-18 | 2017-12-08 | 郑州云海信息技术有限公司 | A software continuous integration method and system |
| CN109240734A (en) * | 2018-07-17 | 2019-01-18 | 北京奇虎科技有限公司 | Code submits method and device |
| CN109388403A (en) * | 2018-09-26 | 2019-02-26 | 广州视源电子科技股份有限公司 | Dependency injection method, device, equipment and storage medium |
| CN109960643A (en) * | 2017-12-22 | 2019-07-02 | 网宿科技股份有限公司 | A kind of code test method and device |
| CN110532189A (en) * | 2019-07-18 | 2019-12-03 | 中国人民财产保险股份有限公司 | A kind of continuous integration system, method and device |
| CN111352651A (en) * | 2020-03-31 | 2020-06-30 | 中国建设银行股份有限公司 | Code branch management method and device |
-
2020
- 2020-12-31 CN CN202011638116.XA patent/CN112579475A/en active Pending
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107450933A (en) * | 2017-08-18 | 2017-12-08 | 郑州云海信息技术有限公司 | A software continuous integration method and system |
| CN109960643A (en) * | 2017-12-22 | 2019-07-02 | 网宿科技股份有限公司 | A kind of code test method and device |
| CN109240734A (en) * | 2018-07-17 | 2019-01-18 | 北京奇虎科技有限公司 | Code submits method and device |
| CN109388403A (en) * | 2018-09-26 | 2019-02-26 | 广州视源电子科技股份有限公司 | Dependency injection method, device, equipment and storage medium |
| CN110532189A (en) * | 2019-07-18 | 2019-12-03 | 中国人民财产保险股份有限公司 | A kind of continuous integration system, method and device |
| CN111352651A (en) * | 2020-03-31 | 2020-06-30 | 中国建设银行股份有限公司 | Code branch management method and device |
Cited By (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113626325A (en) * | 2021-08-05 | 2021-11-09 | 杭州遥望网络科技有限公司 | Interface testing method, device and equipment in code iterative updating |
| CN114416537A (en) * | 2021-12-30 | 2022-04-29 | 浙江吉利控股集团有限公司 | Unit testing method, server, client and storage medium |
| GB2619324A (en) * | 2022-05-31 | 2023-12-06 | The Court Of Edinburgh Napier Univ | Software management system |
| CN115357474A (en) * | 2022-07-11 | 2022-11-18 | 深圳壹账通智能科技有限公司 | Local test method, device, equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112579475A (en) | Code testing method, device, equipment and readable storage medium | |
| CN111459495B (en) | Unit test code file generation method, electronic device and storage medium | |
| Nguyen et al. | Detection of embedded code smells in dynamic web applications | |
| CN113778898A (en) | User interface automatic testing method and device, electronic equipment and storage medium | |
| CN113238929B (en) | Code testing method and device based on Mock data, electronic equipment and storage medium | |
| CN112559337A (en) | Code coverage rate testing method and device, electronic equipment and storage medium | |
| CN113377661A (en) | Interface testing method and device, electronic equipment and storage medium | |
| CN112506779A (en) | Software interface testing method and device, electronic equipment and storage medium | |
| CN114185797A (en) | Front-end code checking method and device, electronic equipment and readable storage medium | |
| CN114385497A (en) | Test environment generation method and device, electronic equipment and storage medium | |
| CN113051171A (en) | Interface test method, device, equipment and storage medium | |
| CN112667244B (en) | Data verification method, device, electronic equipment and computer readable storage medium | |
| CN112486490B (en) | Front-end code packaging method and device, electronic equipment and storage medium | |
| CN112527655B (en) | Software version quality abnormality detection method and device, electronic equipment and storage medium | |
| CN113032275A (en) | Method and device for testing field, electronic equipment and storage medium | |
| CN113176993A (en) | Case testing method and device, electronic equipment and storage medium | |
| CN115809076A (en) | ECU software automation integration method and system | |
| CN115033489A (en) | Code resource detection method and device, electronic equipment and storage medium | |
| CN112686759B (en) | Account reconciliation monitoring method, device, equipment and medium | |
| CN113485970A (en) | Data monitoring method and device, electronic equipment and storage medium | |
| CN113505079A (en) | Application program testing method, device, equipment and medium | |
| CN111400191A (en) | Web page security testing method, device and computer readable storage medium | |
| CN108885574B (en) | System for monitoring and reporting performance and correctness issues at design, compilation, and runtime | |
| CN117251187A (en) | Kernel updates, task processing methods, computing devices and computer storage media | |
| CN113064797B (en) | Front-end monitoring method and device, electronic equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| RJ01 | Rejection of invention patent application after publication | ||
| RJ01 | Rejection of invention patent application after publication |
Application publication date: 20210330 |