CN112256556A - Test method and test device using test case - Google Patents
Test method and test device using test case Download PDFInfo
- Publication number
- CN112256556A CN112256556A CN202010954062.1A CN202010954062A CN112256556A CN 112256556 A CN112256556 A CN 112256556A CN 202010954062 A CN202010954062 A CN 202010954062A CN 112256556 A CN112256556 A CN 112256556A
- Authority
- CN
- China
- Prior art keywords
- code
- test case
- information
- line number
- change
- 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; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
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 discloses a test method and a test device by using a test case, wherein the test method comprises the following steps: injecting a calling code in front of a method body of a method executed by the code; when the method is executed, matching and recording related information of the method and test case information, wherein the related information of the method comprises a method name and position information; setting monitoring at a code submitting entrance, and acquiring a change code of a branch and a line number of the change code when monitoring a branch submitting code; when compiling before the branch is issued, acquiring a line number interval of a change code of the branch; comparing the line number intervals of the obtained change codes to obtain a method set corresponding to the change; and obtaining a test case set matched with the method set by utilizing multiple threads according to the method set corresponding to the change, and pushing the test case set to a test case executing party.
Description
Technical Field
The invention relates to the technical field of software testing, in particular to a testing method and a testing device by using a test case.
Background
In the prior art, when the code executed by the test case is obtained, the code covered by executing the case is counted and recorded by a tester, so that a great deal of effort of the tester is required to count the mapping relation, and the code modification is difficult to update in real time.
Disclosure of Invention
Aiming at the problems in the related art, the invention provides a test method and a test device by using test cases, which can automatically screen related test case sets and effectively improve the efficiency of a CI production line on the premise of ensuring the quality.
The technical scheme of the invention is realized as follows:
according to an aspect of the present invention, there is provided a test method using a test case, including:
injecting a calling code in front of a method body of a method executed by the code;
when the method is executed, matching and recording related information of the method and test case information, wherein the related information of the method comprises a method name and position information;
setting monitoring at a code submitting entrance, and acquiring a change code of a branch and a line number of the change code when monitoring a branch submitting code;
when compiling before the branch is issued, acquiring a line number interval of a change code of the branch;
comparing the line number intervals of the obtained change codes to obtain a method set corresponding to the change;
and obtaining a test case set matched with the method set by utilizing multiple threads according to the method set corresponding to the change, and pushing the test case set to a test case executing party.
According to the embodiment of the invention, the corresponding relation between the test case and the code is obtained by utilizing multithreading.
According to the embodiment of the invention, the line number interval for obtaining the change code of the branch comprises the following steps: acquiring the line number information of each file change code through the api, and recording the line number information into a database; preprocessing the loaded class when the branch is compiled before being issued; the position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
According to the embodiment of the invention, the matching and recording of the relevant information of the method and the test case information comprises the following steps: and when the related information of the method and the matched test case information reach a preset number, starting a thread to record the related information and the matched test case information into the database.
According to another aspect of the present invention, there is provided a test apparatus using a test case, including:
the injection module is used for injecting calling codes in front of the method bodies of the methods executed by the codes;
the recording module is used for matching and recording the related information of the method and the test case information when the method is executed, wherein the related information of the method comprises a method name and position information;
the monitoring module is used for setting monitoring at a code submitting entrance and acquiring a change code of a branch and a line number of the change code when a branch submitting code is monitored;
the line number acquisition module is used for acquiring a line number interval of a change code of a branch when the branch is compiled before being issued, and comparing the line number interval of the change code to obtain a method set corresponding to the change;
and the pushing module is used for obtaining a test case set matched with the method set according to the method set corresponding to the change and pushing the test case set to the test case executor.
According to the embodiment of the invention, the corresponding relation between the test case and the code is obtained by utilizing multithreading.
According to an embodiment of the present invention, the row number obtaining module is configured to: acquiring the line number information of each file change code through the api, and recording the line number information into a database; preprocessing the loaded class when the branch is compiled before being issued; the position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
According to an embodiment of the present invention, the recording module is further configured to: and when the related information of the method and the matched test case information reach a preset number, starting a thread to record the related information and the matched test case information into the database.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a flow diagram of a method of testing using test cases in accordance with an embodiment of the present invention;
FIG. 2 is a flowchart of a testing method using test cases according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present invention.
FIG. 1 is a flow diagram of a testing method using test cases according to an embodiment of the present invention. As shown in FIG. 1, the testing method of the present invention may include the following steps S102-S112.
Step S102, injecting calling code in front of the method body of the method executed by the code.
And step S104, when the method is executed, matching and recording the related information of the method and the test case information, wherein the related information of the method comprises a method name and position information.
In some embodiments, matching and recording the relevant information of the method and the test case information at step S104 includes: and when the related information of the method and the matched test case information reach a preset number, starting a thread to record the related information and the matched test case information into the database.
And step S106, setting monitoring at the code submitting entrance, and acquiring the change code of the branch and the line number of the change code when monitoring a branch submitting code.
Step S108, when compiling before branch issue, obtaining the line number interval of the change code of the branch.
In some embodiments, obtaining the line number interval of the change code of the branch at step S108 may include: acquiring the line number information of each file change code through the api, and recording the line number information into a database; and preprocessing the loaded class when the branch is compiled before being issued. The position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
And step S110, comparing the line number intervals of the obtained change codes to obtain a method set corresponding to the change.
And step S112, obtaining a test case set matched with the method set according to the method set corresponding to the change, and pushing the test case set to a test case executor.
In some embodiments, multiple threads are utilized to obtain test case and code correspondence. In some embodiments, multiple threads are utilized to match a set of methods to a set of test cases.
FIG. 2 is a flowchart of a testing method using test cases according to an embodiment of the present invention. The test method of the present invention and the related art that may be used are described below with reference to the non-limiting example shown in fig. 2. The test method of the present invention may be referred to as an accurate test in the following description. The corresponding relation of the use case and the method is generated by using the byte code technology in the byte code injection process.
When the test case is executed, automatically synchronizing case information to a server in a tcp way; and then, using a javasissist library to inject codes into the method, injecting a line of calling codes in front of each method body, and matching the related information (including the name of the method and the position of the class file) of the method with the case information when the method is executed, and recording the information into a memory. In some embodiments, when the amount of the associated information of the test cases and methods reaches a predetermined amount (for example, 1000 pieces), a thread is started to record the information in a database.
In the compiling and deploying process, a java-agent technology is used for obtaining an accurate test case set.
Monitoring is set at a code submitting inlet, when a certain branch of a git warehouse submits a code, a precise test can acquire a change code of the branch, acquire a line number of each file change code through an api of the git, and record the information of the change line numbers into a database, as shown in the following table 1.
TABLE 1
When a certain branch is compiled before release, the loaded class is preprocessed by using a java-agent technology, and a methodInfo of a javasist library is called to obtain line number intervals of all methods in the code change class, as shown in the following table 2. And then, cross comparison is carried out according to the obtained change line number to obtain a method set corresponding to the change.
TABLE 2
And after the changed method set is obtained, matching the changed method set with the acquired corresponding relation to obtain a test case set, and pushing the test case set to a case executing party.
TABLE 3
The byte code technology and the java-agent technology are usually used together, are generally used for code instrumentation, and are usually used for code coverage analysis. The invention obtains an accurate test case set by using the technology.
In the process of obtaining the corresponding relation between the test case and the code and matching the accurate test case, the invention also uses the multithreading technology.
According to different complexity of the system, the data volume of the corresponding relation of the test cases and the method can reach millions to tens of millions, and multithreading technology is needed to process the data volume during forward and reverse tracing, so that the accurate test tool can synchronously finish the acquisition of the corresponding relation when the case is executed, the system is kept stable, and the operation efficiency is accelerated while the system is kept stable
The multithreading technology is generally used for processing mass data in a short time, and the invention solves mass matching data generated in forward and reverse tracing, thereby finishing the effect of accurate test in a short time.
The precise test is a set of computer test auxiliary analysis system, the core components of the system comprise bidirectional tracing of use cases and codes, selection of intelligent regression test use cases, coverage rate analysis and the like, and the precise test technical system is formed by complete functions.
The precise test mainly serves testers, and application scenarios of the precise test include but are not limited to:
1) code difference comparison
Checking the number of the whole code lines of the system and the difference condition among all the versions of the codes, wherein the number of the code lines is increased or decreased, and the result report detailed to the code lines can avoid the entrainment transfer and help testers to quickly position key test points.
2) Relevant test case recommendation
By comparing the method link with the code and recommending the related test case, the method can help testers to effectively position the range of regression test, help development, understanding and searching for the influence points related to the changed code, and reduce bug generation.
3) Coverage analysis
And obtaining the operation trace of each case in the code through the relation between the coverage rate result and the method link, and assisting in testing and developing to quickly locate the defects when the test case fails to be executed.
In the software testing process of the precise test, the automatic bidirectional tracing of the acquired use cases and codes can be realized, meanwhile, the precise test can be perfectly embedded into the existing CI production line, and the execution efficiency of the CI production line is well improved.
In summary, the invention updates the incidence relation between the test cases and the code execution information in time through full-automatic data acquisition, automatically screens the related test case set, generates the change method set corresponding to the iteration by analyzing the branch difference codes, and then pushes the code information corresponding to a single test case, thereby effectively improving the efficiency of the CI production line on the premise of ensuring the quality.
According to another aspect of the invention, a test device using the test case is also provided. The test apparatus of the present invention may include:
the injection module is used for injecting calling codes in front of the method bodies of the methods executed by the codes;
the recording module is used for matching and recording the related information of the method and the test case information when the method is executed, wherein the related information of the method comprises a method name and position information;
the monitoring module is used for setting monitoring at a code submitting entrance and acquiring a change code of a branch and a line number of the change code when a branch submitting code is monitored;
the line number acquisition module is used for acquiring a line number interval of a change code of a branch when the branch is compiled before being issued, and comparing the line number interval of the change code to obtain a method set corresponding to the change;
and the pushing module is used for obtaining a test case set matched with the method set according to the method set corresponding to the change and pushing the test case set to the test case executor.
In some embodiments, multiple threads are utilized to obtain test case and code correspondence. In some embodiments, multiple threads are utilized to match a set of methods to a set of test cases.
In some embodiments, the row number acquisition module is to: acquiring the line number information of each file change code through the api, and recording the line number information into a database; and preprocessing the loaded class when the branch is compiled before being issued. The position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
In some embodiments, the recording module is further to: and when the related information of the method and the matched test case information reach a preset number, starting a thread to record the related information and the matched test case information into the database.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.
Claims (8)
1. A test method using a test case is characterized by comprising the following steps:
injecting a calling code in front of a method body of a method executed by the code;
when the method is executed, matching and recording related information of the method and test case information, wherein the related information of the method comprises a method name and position information;
setting monitoring at a code submitting entrance, and acquiring a change code of a branch and a line number of the change code when monitoring the branch submitting code;
when the branch is compiled before being issued, acquiring a line number interval of a change code of the branch;
comparing the line number intervals of the obtained change codes to obtain a method set corresponding to the change;
and obtaining a test case set matched with the method set by utilizing multithreading according to the method set corresponding to the change, and pushing the test case set to a test case executing party.
2. The test method of claim 1, further comprising obtaining correspondence between test cases and code using multiple threads.
3. The method of claim 1, wherein obtaining a line number interval of change code for the branch comprises:
acquiring the line number information of each file change code through the api, and recording the line number information into a database;
preprocessing the loaded class when the branch is compiled before being issued;
and the position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
4. The testing method of claim 1, wherein matching and recording the method-related information and test case information comprises:
and when the related information and the matched test case information of the method reach a preset number, starting a thread to record the related information and the matched test case information into a database.
5. A test apparatus using a test case, comprising:
the injection module is used for injecting calling codes in front of the method bodies of the methods executed by the codes;
the recording module is used for matching and recording the related information of the method and the test case information when the method is executed, wherein the related information of the method comprises a method name and position information;
the monitoring module is used for setting monitoring at a code submitting entrance, and acquiring a change code of a branch and a line number of the change code when a branch submitting code is monitored;
the line number acquisition module is used for acquiring a line number interval of a change code of the branch when the branch is compiled before being issued, and comparing the line number interval of the change code to obtain a method set corresponding to change;
and the pushing module is used for obtaining a test case set matched with the method set by utilizing multiple threads according to the method set corresponding to the change and pushing the test case set to a test case executing party.
6. The test apparatus according to claim 5, wherein the correspondence between the test cases and the code is obtained by using multiple threads.
7. The testing device of claim 5, wherein the row number obtaining module is configured to:
acquiring the line number information of each file change code through the api, and recording the line number information into a database;
preprocessing the loaded class when the branch is compiled before being issued;
and the position information is the position of the class file, and the line number interval of the method in the class is changed by using the position information.
8. The testing device of claim 5, wherein the recording module is further configured to:
and when the related information and the matched test case information of the method reach a preset number, starting a thread to record the related information and the matched test case information into a database.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010954062.1A CN112256556A (en) | 2020-09-11 | 2020-09-11 | Test method and test device using test case |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010954062.1A CN112256556A (en) | 2020-09-11 | 2020-09-11 | Test method and test device using test case |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112256556A true CN112256556A (en) | 2021-01-22 |
Family
ID=74232022
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010954062.1A Pending CN112256556A (en) | 2020-09-11 | 2020-09-11 | Test method and test device using test case |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112256556A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103577311A (en) * | 2012-07-26 | 2014-02-12 | 深圳市世纪光速信息技术有限公司 | Method and device for screening test cases |
US20170132119A1 (en) * | 2015-09-25 | 2017-05-11 | EMC IP Holding Company LLC | Method and device for retrieving test case based on code coverage |
CN109240911A (en) * | 2018-08-13 | 2019-01-18 | 腾讯科技(北京)有限公司 | Accurate test method, device and computer equipment |
CN109783382A (en) * | 2019-01-07 | 2019-05-21 | 郑州云海信息技术有限公司 | A kind of test method and system based on accurate test platform |
CN110941555A (en) * | 2019-11-26 | 2020-03-31 | 广州品唯软件有限公司 | Test case recommendation method and device, computer equipment and storage medium |
CN111563041A (en) * | 2020-05-08 | 2020-08-21 | 吴迪 | Test case on-demand accurate execution method |
-
2020
- 2020-09-11 CN CN202010954062.1A patent/CN112256556A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103577311A (en) * | 2012-07-26 | 2014-02-12 | 深圳市世纪光速信息技术有限公司 | Method and device for screening test cases |
US20170132119A1 (en) * | 2015-09-25 | 2017-05-11 | EMC IP Holding Company LLC | Method and device for retrieving test case based on code coverage |
CN109240911A (en) * | 2018-08-13 | 2019-01-18 | 腾讯科技(北京)有限公司 | Accurate test method, device and computer equipment |
CN109783382A (en) * | 2019-01-07 | 2019-05-21 | 郑州云海信息技术有限公司 | A kind of test method and system based on accurate test platform |
CN110941555A (en) * | 2019-11-26 | 2020-03-31 | 广州品唯软件有限公司 | Test case recommendation method and device, computer equipment and storage medium |
CN111563041A (en) * | 2020-05-08 | 2020-08-21 | 吴迪 | Test case on-demand accurate execution method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109189665B (en) | Method and device for recording, replaying and automatically testing data | |
CN101377759B (en) | Automatic interface test system | |
CN111209185B (en) | Keyword-based automated testing method and computer-readable storage medium | |
US20030088810A1 (en) | Methods and apparatus for determining software component sizes associated with errors | |
CN112631926B (en) | Code test coverage rate display method and device, computer equipment and storage medium | |
CN112650688B (en) | Automated regression testing method, associated device and computer program product | |
CN111563041A (en) | Test case on-demand accurate execution method | |
CN112148614B (en) | Regression testing method and device | |
WO2017044069A1 (en) | Automatic regression identification | |
CN111611154B (en) | Regression testing method, device and equipment | |
CN113220597B (en) | Test method, test device, electronic equipment and storage medium | |
CN112685316A (en) | Code execution path acquisition method and device, computer equipment and storage medium | |
CN113127280A (en) | API interface automatic input method and system | |
CN112612697A (en) | Software defect testing and positioning method and system based on byte code technology | |
CN110633199A (en) | Testing apparatus, method, and medium for block chain supporting intelligent contract | |
CN115794639B (en) | Visual test based on flow and visual simulation test system and method | |
CN112256556A (en) | Test method and test device using test case | |
CN112579440A (en) | Method and device for determining virtual test dependent object | |
CN109165155B (en) | Software defect repairing template extraction method based on cluster analysis | |
CN109101355B (en) | Processor debugging method for extracting error site characteristic test excitation | |
CN116069628A (en) | Intelligent-treatment software automatic regression testing method, system and equipment | |
CN109684205A (en) | System detection method, device, electronic equipment and storage medium | |
CN114691519A (en) | Interface automation test method, device, equipment and storage medium | |
US7516048B2 (en) | Externalized metric calculation engine | |
CN110597705B (en) | Program debugging method and device capable of repeatedly acquiring test data |
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 |