CN113688031A - Testing positioning method based on byte code enhancement technology - Google Patents

Testing positioning method based on byte code enhancement technology Download PDF

Info

Publication number
CN113688031A
CN113688031A CN202110801329.8A CN202110801329A CN113688031A CN 113688031 A CN113688031 A CN 113688031A CN 202110801329 A CN202110801329 A CN 202110801329A CN 113688031 A CN113688031 A CN 113688031A
Authority
CN
China
Prior art keywords
code
test
bytecode
enhancement
positioning
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.)
Granted
Application number
CN202110801329.8A
Other languages
Chinese (zh)
Other versions
CN113688031B (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.)
Shanghai Pudong Development Bank Co Ltd
Original Assignee
Shanghai Pudong Development Bank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Pudong Development Bank Co Ltd filed Critical Shanghai Pudong Development Bank Co Ltd
Priority to CN202110801329.8A priority Critical patent/CN113688031B/en
Publication of CN113688031A publication Critical patent/CN113688031A/en
Application granted granted Critical
Publication of CN113688031B publication Critical patent/CN113688031B/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/3688Test management for test execution, e.g. scheduling of test suites
    • 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/362Debugging of software
    • G06F11/3644Debugging of software by instrumenting at runtime
    • 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
    • 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/368Test management for test version control, e.g. updating test cases to a new software version
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

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 testing and positioning method based on byte code enhancement technology, which comprises the following steps: configuring a bytecode enhancement module; loading, analyzing and modifying a bytecode file corresponding to the source code based on a bytecode enhancement technology to obtain bytecode static data; based on a bytecode enhancement technology, adding event embedding points on source code logic, and acquiring test information and code execution dynamic data during testing by adopting a test case; and performing test positioning based on the byte code static data, the test information and the code execution dynamic data. Compared with the prior art, the method has the advantages of simplicity, high efficiency, intelligence and the like.

Description

Testing positioning method based on byte code enhancement technology
Technical Field
The invention relates to the technical field of software development and testing, in particular to a testing and positioning method based on a byte code enhancement technology.
Background
At present, the common black box test in the software test comprises the measures of system integration test, user acceptance test and the like which are all initiated by a test department, relevant test cases are compiled, and automatic test or manual test is executed. Because the tester cannot know the internal operation structure and situation of the program, both the tester and the developer cannot know whether the black case is sufficient. Therefore, when writing test cases, the tester needs to communicate with the developer for a long time to determine the test range and boundary involved in the test.
The existing test scheme does not analyze the correlation between source codes and code execution records, and also does not analyze the calling relationship between classes and methods between the source codes, so that the source codes have no great significance to testers, and therefore, the code execution records and the coverage rate information thereof are also a data isolated island for the testers, so that the testers do not have correct benchmarks when writing test cases, and can only determine test contents through continuous communication with developers.
Disclosure of Invention
The present invention is directed to a method for testing and positioning based on bytecode enhancement technology, which overcomes the above-mentioned drawbacks of the prior art.
The purpose of the invention can be realized by the following technical scheme:
a testing and positioning method based on byte code enhancement technology comprises the following steps:
configuring a bytecode enhancement module;
loading, analyzing and modifying a bytecode file corresponding to the source code based on a bytecode enhancement technology to obtain bytecode static data;
based on a bytecode enhancement technology, adding event embedding points on source code logic, and acquiring test information and code execution dynamic data during testing by adopting a test case;
and performing test positioning based on the byte code static data, the test information and the code execution dynamic data.
Preferably, the specific way of configuring the bytecode enhancement module is as follows: initializing a bytecode enhancement module, connecting a JVM virtual machine of the enhancement module through an Agent module, attaching an Agent tool program to the JVM of each test system by using an Attach Api provided by the JVM after the start of each test system is finished, loading enhancement extension and reading enhancement configuration.
Preferably, the bytecode static data includes members, methods, and annotation information related to each category of the source code, and method calls, member initializations and calls, exception intervals, and code line records corresponding to the respective category.
Preferably, the manner of acquiring the bytecode static data includes:
loading corresponding jar package information in the existing program, analyzing a class file through a byte code enhancement technology, scanning the content of the class file from beginning to end, calling AgentClassVisitor to acquire members, methods and annotation information related to the class corresponding to the class file each time the corresponding content of the class file is scanned, and calling AgentMethodVisitor to acquire method calls, member initialization and calls, abnormal intervals and code line records related to the corresponding class.
Preferably, the event buried point setting position comprises the starting position and the ending position of the source code and the position after each line of codes.
Preferably, when a test case is used for testing, when a certain code is executed, the corresponding event embedded point behind the code is triggered to generate corresponding code execution dynamic data.
Preferably, the test information includes a system name, an application name, a service name, service information in the request distributed architecture component, a test identifier, a case identifier, a user identifier, and a request identifier.
Preferably, the code execution dynamic data is log data, and the log data records the execution condition or coverage or not corresponding to the current code.
Preferably, the bytecode static data, the test information and the code execution dynamic data are collected by the Kafka log module and sent to the test platform for unified processing for test positioning.
Preferably, the performing test positioning specifically includes positioning a code execution record and a coverage rate of a test case related to the source code.
Compared with the prior art, the invention has the following advantages:
(1) the method is simpler: the tester can directly obtain the test range of the current test through the developed code change;
(2) more efficient: the tester participates in the development work of the code level to a certain extent, and a plurality of problems which are difficult to communicate can be reflected from code change;
(3) more intelligent: the test platform can recommend a test case according to the code change to obtain the maximum coverage of the code, and the test platform is more accurate than blind full test.
Drawings
Fig. 1 is a flowchart illustrating an implementation of a test positioning method based on a bytecode enhancement technology according to the present invention.
Detailed Description
The invention is described in detail below with reference to the figures and specific embodiments. Note that the following description of the embodiments is merely a substantial example, and the present invention is not intended to be limited to the application or the use thereof, and is not limited to the following embodiments.
Examples
A testing and positioning method based on byte code enhancement technology comprises the following steps:
1. the specific mode of configuring the bytecode enhancement module is as follows: initializing a bytecode enhancement module, connecting a JVM virtual machine of the enhancement module through an Agent module, attaching an Agent tool program to the JVM of each test system by using an Attach Api provided by the JVM after the start of each test system is finished, loading enhancement extension and reading enhancement configuration.
2. And loading, analyzing and modifying a bytecode file corresponding to the source code based on a bytecode enhancement technology to obtain bytecode static data, wherein the bytecode static data comprises members, methods and annotation information related to each category of the source code, and method calls, member initialization and calls, abnormal intervals and code line records corresponding to the corresponding categories.
The manner of acquiring the bytecode static data includes:
loading corresponding jar package information in the existing program, analyzing a class file through a byte code enhancement technology, scanning the content of the class file from beginning to end, calling AgentClassVisitor to acquire members, methods and annotation information related to the class corresponding to the class file each time the corresponding content of the class file is scanned, and calling AgentMethodVisitor to acquire method calls, member initialization and calls, abnormal intervals and code line records related to the corresponding class.
3. Based on the bytecode enhancement technology, event embedding points are added on the source code logic, and test information and code execution dynamic data are obtained during testing by adopting a test case.
The event buried point setting position includes the start and end positions of the source code and after each line of code. When a test case is tested, when a certain code is executed, the corresponding event embedded point behind the code is triggered to generate corresponding code execution dynamic data.
The test information comprises a system name, an application name, a service name, service information in a request distributed architecture component, a test identifier, a case identifier, a user identifier and a request identifier.
The code execution dynamic data is log data, and the log data records the execution condition or coverage or not corresponding to the current code.
4. And performing test positioning based on the byte code static data, the test information and the code execution dynamic data. The static data, the test information and the code execution dynamic data of the byte codes are collected by the Kafka log module and sent to the test platform for unified processing for test positioning. The test positioning specifically includes positioning code execution records related to source codes and coverage of test cases, and specifically:
after the test platform obtains the above contents, the following contents can be obtained by combining with the analysis of the source code program:
(1) checking the global code coverage rate;
(2) displaying the global coverage condition of the current class code corresponding to the source code;
(3) statically analyzing class dependency relationships from the class file;
(4) displaying which classes the current class depends on corresponding to the source codes;
(5) recommending to display the current classes referenced by those classes;
(6) checking the code coverage condition related to the execution of a certain use case based on the use case;
(7) displaying a certain use case method calling path;
(8) displaying the current branch related to the code coverage condition corresponding to the source code;
(9) displaying the code coverage condition related to the current change corresponding to the source code;
(10) checking the coverage condition of the current change in the corresponding code of the use case of a certain time by the execution use case;
(11) displaying case execution records corresponding to the source codes;
(12) the corresponding source code recommends using some use case execution to obtain maximum coverage.
According to the method, after the start of each test system is completed, the JVM virtual machine is connected through an Agent module, a byte code file corresponding to the existing service of the test system is loaded, analyzed and modified, the static data of the existing byte code is obtained, and event embedded point information is added to the original service logic, so that the test information and the code execution condition in the current context are obtained in the service execution process. Therefore, the key points of the invention mainly comprise two data acquisition methods of byte code static data and code execution dynamic data. After the byte code static data and the code execution dynamic data are obtained, the test information and the source code can be combined to determine the correlation between the code execution record related to the source code and the data such as the coverage rate of the code execution record. Furthermore, testers can directly acquire the test range of the current test through the developed code change, the testers participate in the development work of the code level to a certain extent, a plurality of problems difficult to communicate can be reflected from the code change, and the test platform can recommend test cases according to the code change to acquire the maximum coverage of the code, so that the test is more accurate than blind full test.
The above embodiments are merely examples and do not limit the scope of the present invention. These embodiments may be implemented in other various manners, and various omissions, substitutions, and changes may be made without departing from the technical spirit of the present invention.

Claims (10)

1. A testing and positioning method based on byte code enhancement technology is characterized by comprising the following steps:
configuring a bytecode enhancement module;
loading, analyzing and modifying a bytecode file corresponding to the source code based on a bytecode enhancement technology to obtain bytecode static data;
based on a bytecode enhancement technology, adding event embedding points on source code logic, and acquiring test information and code execution dynamic data during testing by adopting a test case;
and performing test positioning based on the byte code static data, the test information and the code execution dynamic data.
2. The method according to claim 1, wherein the specific manner of configuring the bytecode enhancement module is as follows: initializing a bytecode enhancement module, connecting a JVM virtual machine of the enhancement module through an Agent module, attaching an Agent tool program to the JVM of each test system by using an Attach Api provided by the JVM after the start of each test system is finished, loading enhancement extension and reading enhancement configuration.
3. The testing and positioning method based on the bytecode-enhanced technology according to claim 1, wherein the bytecode static data includes member, method, annotation information related to each category of the source code, and method call, member initialization and call, exception interval, and code line record corresponding to the corresponding category.
4. The method as claimed in claim 3, wherein the manner of obtaining the static data of the bytecode includes:
loading corresponding jar package information in the existing program, analyzing a class file through a byte code enhancement technology, scanning the content of the class file from beginning to end, calling AgentClassVisitor to acquire members, methods and annotation information related to the class corresponding to the class file each time the corresponding content of the class file is scanned, and calling AgentMethodVisitor to acquire method calls, member initialization and calls, abnormal intervals and code line records related to the corresponding class.
5. The method as claimed in claim 1, wherein the event burial point setting positions comprise the beginning and ending positions of the source codes and the position after each line of codes.
6. The method as claimed in claim 5, wherein when a test case is used for testing, and when a certain code is executed, the corresponding event embedding point behind the code is triggered to generate the corresponding code execution dynamic data.
7. The byte-code enhancement technology based test positioning method as claimed in claim 1, wherein the test information includes system name, application name, service information in request distributed architecture component, test identifier, case identifier, user identifier, and request identifier.
8. The method as claimed in claim 6, wherein the dynamic data of code execution is log data, and the log data records the execution status or coverage of the current code.
9. The method as claimed in claim 1, wherein the static data, test information and code execution dynamic data of the bytecode are collected by a Kafka log module and sent to a test platform for unified processing for test positioning.
10. The method as claimed in claim 1, wherein the performing test positioning specifically includes positioning code execution records and coverage of test cases related to source codes.
CN202110801329.8A 2021-07-15 2021-07-15 Test positioning method based on byte code enhancement technology Active CN113688031B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110801329.8A CN113688031B (en) 2021-07-15 2021-07-15 Test positioning method based on byte code enhancement technology

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110801329.8A CN113688031B (en) 2021-07-15 2021-07-15 Test positioning method based on byte code enhancement technology

Publications (2)

Publication Number Publication Date
CN113688031A true CN113688031A (en) 2021-11-23
CN113688031B CN113688031B (en) 2024-03-26

Family

ID=78577113

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110801329.8A Active CN113688031B (en) 2021-07-15 2021-07-15 Test positioning method based on byte code enhancement technology

Country Status (1)

Country Link
CN (1) CN113688031B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115237706A (en) * 2022-06-20 2022-10-25 平安科技(深圳)有限公司 Buried point data processing method and device, electronic equipment and storage medium
CN116756092A (en) * 2023-08-23 2023-09-15 深圳红途科技有限公司 System download file marking method, device, computer equipment and storage medium
CN118413363A (en) * 2024-04-24 2024-07-30 中信银行股份有限公司 Business data security enhancement method, device, equipment and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1276047A2 (en) * 2001-07-11 2003-01-15 Sun Microsystems, Inc. System controller for use in a distributed processing framework system and methods for implementing the same
KR20070052328A (en) * 2007-03-28 2007-05-21 텔레콤 이탈리아 소시에떼 퍼 아찌오니 Method and system for providing interactive service in digital television
CN106502896A (en) * 2016-10-21 2017-03-15 武汉斗鱼网络科技有限公司 A kind of generation method of function test code and device
CN107688530A (en) * 2017-04-06 2018-02-13 平安科技(深圳)有限公司 Method for testing software and device
CN112416794A (en) * 2020-12-03 2021-02-26 平安银行股份有限公司 Method, device and equipment for processing code coverage rate and storage medium
CN112612697A (en) * 2020-12-17 2021-04-06 航天信息股份有限公司 Software defect testing and positioning method and system based on byte code technology
CN113076253A (en) * 2021-04-16 2021-07-06 北京京东拓先科技有限公司 Test method and test device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1276047A2 (en) * 2001-07-11 2003-01-15 Sun Microsystems, Inc. System controller for use in a distributed processing framework system and methods for implementing the same
KR20070052328A (en) * 2007-03-28 2007-05-21 텔레콤 이탈리아 소시에떼 퍼 아찌오니 Method and system for providing interactive service in digital television
CN106502896A (en) * 2016-10-21 2017-03-15 武汉斗鱼网络科技有限公司 A kind of generation method of function test code and device
CN107688530A (en) * 2017-04-06 2018-02-13 平安科技(深圳)有限公司 Method for testing software and device
CN112416794A (en) * 2020-12-03 2021-02-26 平安银行股份有限公司 Method, device and equipment for processing code coverage rate and storage medium
CN112612697A (en) * 2020-12-17 2021-04-06 航天信息股份有限公司 Software defect testing and positioning method and system based on byte code technology
CN113076253A (en) * 2021-04-16 2021-07-06 北京京东拓先科技有限公司 Test method and test device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115237706A (en) * 2022-06-20 2022-10-25 平安科技(深圳)有限公司 Buried point data processing method and device, electronic equipment and storage medium
CN116756092A (en) * 2023-08-23 2023-09-15 深圳红途科技有限公司 System download file marking method, device, computer equipment and storage medium
CN116756092B (en) * 2023-08-23 2024-01-05 深圳红途科技有限公司 System download file marking method, device, computer equipment and storage medium
CN118413363A (en) * 2024-04-24 2024-07-30 中信银行股份有限公司 Business data security enhancement method, device, equipment and storage medium
CN118413363B (en) * 2024-04-24 2025-11-25 中信银行股份有限公司 Business data security enhancement methods, devices, equipment and storage media

Also Published As

Publication number Publication date
CN113688031B (en) 2024-03-26

Similar Documents

Publication Publication Date Title
US7647584B2 (en) Automation and isolation of software component testing
US8245194B2 (en) Automatically generating unit test cases which can reproduce runtime problems
CN113688031B (en) Test positioning method based on byte code enhancement technology
CN106201863A (en) A kind of method and apparatus obtaining code coverage
CN114416545B (en) Method, device and electronic device for determining test code coverage
CN112650670A (en) Application testing method, device, system, electronic equipment and storage medium
CN110716874B (en) Domestic operating system hardware compatibility testing method
CN115292418B (en) Cross-system business process automatic processing method and system
CN108132876B (en) Embedded software object code unit testing method based on injection mode
CN112099838B (en) Method, device and storage medium for determining version difference
CN113722233A (en) Code coverage rate determining method, system, storage medium and electronic equipment
Andriadi et al. The impact of shift-left testing to software quality in agile methodology: A case study
CN107622017B (en) Analysis method for universal automation software test
CN112612697A (en) Software defect testing and positioning method and system based on byte code technology
CN118193382B (en) Application testing methods, apparatus, devices, storage media, and program products
US8418151B2 (en) Date and time simulation for time-sensitive applications
CN119883932A (en) Software testing system, method, electronic equipment and storage medium
CN112506782A (en) Application program testing method, device, equipment and storage medium
CN114780952B (en) Detection method, system and storage medium for sensitive application call scene
CN113127367B (en) Defect detection method for Android dynamic permission application
CN115456628A (en) Intelligent contract viewing method and device based on block chain, storage medium and equipment
CN109976762B (en) Method and system for improving solid state disk firmware test efficiency
CN114816984A (en) JAVA program regression test method and test device
CN113138923A (en) Method and device for determining test range by analyzing modification code
CN111143221A (en) Test method and device

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