Jacoco-based test analysis method, system and device and medium

A technology for test analysis and analysis tasks, applied in software testing/debugging, error detection/correction, instruments, etc., can solve problems such as the inability to quickly implement version difference comparison analysis

Active Publication Date: 2021-03-26
广州云从鼎望科技有限公司
9 Cites 0 Cited by

AI-Extracted Technical Summary

Problems solved by technology

If you want to know the code difference between the two versions, you need to download the code of the two versions and use tools to compare the ...
View more

Method used

The main implementation process of an embodiment of the technical solution of the present invention: increase jacocoagent in the startup script of test service, to pass in the project parameter of customization by described jacocoagent; Analyze the service corresponding to the described project parameter of importing information, generating an analysis task corresponding to the service information; and executing the analysis task regularly. That is, after adding the modified jacocoagent startup script to the service under test, jacocoagent collects execution information and transfers the data of the service under test to the analysis system according to the specified path to generate coverage analysis tasks and/or difference analysis tasks, and pass Scheduled task scanning determines the execution of corresponding analysis tasks. In this way, the test data of the service under test/test program is periodically transmitted to the analysis platform, which is convenient for the analysis platform to count the full/incremental coverage of the test from the code level during the test activities; For the covered part of the code, it can be deduced whether the test design in the...
View more

Abstract

The invention relates to the technical field of program testing, in particular to a jacoo-based test analysis method, system and device and a medium. The invention aims to solve the technical problemsof how to reduce the workload of manual configuration and automatically and efficiently obtain the full/incremental coverage rate statistical analysis of a test version and even the difference analysis of different versions. The method comprises the steps: customizing project parameters by performing secondary development on jacoo and modifying a jacocoagent source code, developing a jacoo-basedtest analysis system by using flask, uploading a jacocoagent.jar to a specified position of a server where a tested service is located, a tested service script is started by using a jacocoagent, and transmitting the corresponding project parameters of the corresponding tested service; generating a corresponding coverage rate analysis task and/or a difference analysis task according to the analysisproject parameters and the service information of the database, and regularly scanning and executing the tasks. Therefore, automatic analysis of a large number of tests can be achieved, and a simpleand easy-to-use tool for full-quantity/increment coverage rate analysis and difference analysis is provided for testers.

Application Domain

Software testing/debugging

Technology Topic

Rate analysisService information +14

Image

  • Jacoco-based test analysis method, system and device and medium
  • Jacoco-based test analysis method, system and device and medium
  • Jacoco-based test analysis method, system and device and medium

Examples

  • Experimental program(1)

Example Embodiment

[0045]Some embodiments of the invention will be described below with reference to the accompanying drawings. Those skilled in the art will appreciate that these embodiments are intended to illustrate the technical principles of the present invention, and are not intended to limit the scope of the invention.
[0046]In the description of the invention, "module", "processor" may include hardware, software, or a combination of both. A module may include a hardware circuit, a variety of suitable inductors, communication ports, and memory, or software portions, such as program code, or combinations of software and hardware. The processor can be a central processor, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor can be implemented in software, hardware mode implementation or both combined. Non-temporary computer readable storage media includes any suitable memory, such as a disk, hard disk, disc, flash memory, read-only memory, random access memory, and the like. The terms "a and / or b" indicate the possible combination of A and B, such as just A, just B or A and B. The term "at least one of at least one or b" or "at least one" in "A and B is similar to" A and / or B ", which may include just A, just B or A and B. The term "one" in the singular form "," this "can also contain a plural form.
[0047]Here, some of the terms involved in the present invention are explained here.
[0048]Jacoco, Java Code Coverage, is an open source coverage tool for Java languages. Jacoco can be embedded in Ant, Maven, or you can use the JavaAgent technology to monitor the Java program. JACOCO can implement an on-the-fly pile through JacocoAgent.jar, write ANT identifiable XML files, and generate reports through Jacocoant.jardump data. Jacoco includes a variety of scale coverage counters, including instruction level coverage, branches, CyclomaticComplexity, row coverage (non-Abstract Methods), Class overlay (Classes).
[0049]JacocoAgent: Jacoco uses class file tools to record line coverage data, using JavaAgent to detect class files in ON-the-fly mode. JacocoAgent can be used as a third party, plug-in in an XML file, solve the problem of obtaining the test code coverage when Maven compile; can also be configured to the service process through the JAR package to get the code coverage data in the server. JacocoAgent's Listener module listens to whether the request is received, and the JacocoAgent generates a test report based on the code coverage data when answering the Dump Request request.
[0050]ON-THE-FLY Mode: Jacoco is divided into three parts, the first part is injected and acquired, the second part is exported, the third part is generated, and the three parts can be separately executed separately. First, add -JavaAgent options to the start command line of the test program, specify JacocoAgent.jar as the agent. JacocoAgent collects execution information. There are three different exported data modes: 1) File system: JVM is stopped, data is exported to a local file; 2) TCP SocketServer: Listening port connections, get the execution data via the Socket connection. When the VM exits, you can select data reset and data export. 3) TCP Socket Client: When the JacocoAgent is connected to a given TCP side, execute the data to Socket when requesting, and when the VM exits, you can select data reset and data export.
[0051]Git: is an open source distributed version control system, which can be effectively dealt with high speed project management from a small to very large project. Git has a good version branch control, version number management, etc., applied to most Internet companies' actual project management. Based on the Jacoco acquisition coverage, the development of the modified source code (including the original version code and the modified version code) will be stored in the code warehouse preset by the server.
[0052]A main implementation process of one embodiment of the present invention: add JacocoAgent to the startup script of the test service to pass the custom item parameters through the JacocoAgent; analyze the service information corresponding to the incoming project parameters, generate Corresponding to the analysis task of the service information; the analysis task is performed timed. That is, the measured service is joined the modified JacocoAgent boot script, collects the execution information by JacocoAgent and passes the data of the measured service into the analysis system, generates the coverage analysis task and / or the difference analysis task, and passed Timers Task Scan Determines the implementation of the corresponding analysis tasks. In this way, the periodicity of the data of the test service / test program is periodically transmitted to the analysis platform, which is convenient for analysis platform to test all / incremental coverage from the code level during the test activity; in turn, it can be not in the coverage report The code covers the part, can be reversed in the previous test design, whether there is a waste code, etc .; Further, there is an incremental coverage between different test versions (two editions differential analysis status), which can be clarified for new or change Whether the code is tested in place; overcomes the defects of different test versions of differential comparisons, whereby the difference ratio is analyzed, the tester can select the functional case involved in the part of the code to test, narrow. Regression test range, improve test accuracy, save manpower and time.
[0053]figure 1 A schematic structural diagram of the implementation coverage and version difference analysis of one embodiment of the JOCO-based test analysis system according to the present invention.
[0054]Such asfigure 1 As shown, the system structure composition includes JacocoAgent module 1, JacocoAgent data receiving module 2, full amount coverage analysis module 3, incremental coverage analysis module 4, differential analysis module 5, timing task module 6, and front-end display module 7.
[0055]The JacocoAgent module 1 customizes the project name, service name, version number, code branch / code warehouse branch, platform IP, platform port by modifying the JacocoAgent source code, and automatically generates JacocoAgent's listening interface.
[0056]The JacocoAgent module 1 plus the -JavaAgent option in the start command line of the measured service, specifying JacocoAgent.jar as the agent, using the modified JacocoAgent to pass the specified parameters. After starting success, JacocoAgent collects execution information, the data of the test service automatically subscribes to test coverage platforms (as JACOCO-based test analysis system based on the present invention), and a first time period (for example, 5 minutes) Send a heartbeat to the test coverage platform. Thereby, the data generated after the measured service is started, and the coverage analysis (such as statistics), even differential analysis, and the like.
[0057]The JacocoAgent data receiving module 2 provides a data receiving interface communication with the transmitting interface of the JacocoAgent module 1. After the data receiving interface receives the data reported by the JacocoAgent module, the existing data displayed in the service management page in the front-end display module 7 is compared to the service name + version number + code branch of Jacoco uploaded service name + version number + code branch. That is, an overlay analysis task is generated.
[0058]Receive the data and comparison, specifically, for example: through the service management page, you can enter / configure the service name (Servicevename), branch (Gitbranc, refer to the code warehouse branch), will also match the corresponding gitlab warehouse address. , Username password, etc., and these data exist in the database (such as mysql); if the data uploaded by JacocoAgent (custom project parameters): Service name + version number + code branch is not matched with the record in the database (ie There is no such service information), the data parameters uploaded by JacocoAgent will not be retained and the measured service is not analyzed, that is, the corresponding GitLab warehouse address and password cannot be found, and cannot be analyzed; if JacocoAgent upload data (customization Project parameters): Service name + version number + code branch is recorded in the database, that is, the corresponding record, inserts the parameter into the corresponding table in the database, and triggers the analysis process.
[0059]Further, the coverage analysis task can be a full amount of coverage analysis task, or an incremental coverage analysis task, or simultaneously generates a full amount coverage analysis task and incremental coverage analysis task. Further, if you confirm that the service is available, there is a differential analysis task.
[0060]The full amount coverage analysis task is completed by the full amount coverage analysis module 3. The full amount coverage analysis module 3 pulls the source code of the corresponding service from the code warehouse, performs code packaging, moves source code, dependent package, and JAR packets to the specified directory, generate a configuration file according to the code directory, according to the configuration Documents are received by a full coverage.
[0061]Usually, after the programmer has been written in a program, the program will be uploaded to a specific code warehouse. When you need to test the code, you pull the current version of the code from the code repository, because the same version of the installer may be After many modifications during the development, each modification will generate a new version of the code. The code will be packaged to generate a corresponding test package after taking the code.
[0062]In a particular embodiment, the full amount coverage analysis module 3 uses Git Clone to pull the source code of the corresponding test service from the code warehouse, and clon the data into the new directory.
[0063]In a particular embodiment, the source code of the corresponding test service performs code packaging is a Maven package.
[0064]In a particular embodiment, the full amount coverage analysis module 3 generates the build.xml file executed by the ANT command based on the code directory, execute the Ant Run command to get the full amount coverage report in the HTML format.
[0065]The incremental coverage analysis task is completed by the incremental coverage analysis module 4. The incremental coverage analysis module 4 first determines whether the source code of the two versions has been successfully sucked, if it has been successfully successful, further confirm that the two versions of the Java file have differences, obtain the packet path with different files, generate a configuration file , To obtain an incremental coverage report for a differential file package based on the configuration file.
[0066]The two versions refer to the current version and the previous version, that is, an old version.
[0067]In a particular embodiment, the incremental coverage analysis module 4 generates the build.xml file executed by the ANT command, execute the ANT Run command to obtain a coverage report of a differential file package in the HTML format.
[0068]Further, incremental coverage analysis module 4 modifies the HTML file, accurate the coverage report to the class, generate incremental coverage reports.
[0069]The differential analysis task is performed by the difference analysis module 5. The difference analysis module 5 generates differential data one by one to each package and each file of the two versions, and stores in the database, such as MongoDB.
[0070]The timing task module 6 performs a full amount coverage analysis task, incremental coverage analysis task and differential analysis task, if the task of conforming the execution condition is scanned, the corresponding module 4, 5 or 6 performs the corresponding analysis.
[0071]The front end display module 7 includes a service management page, a coverage analysis management page, and a three front-end page of the differential analysis management page. The three front-end page and the corresponding background interface show JacocoAgent module 1, JacocoAgent data receiving module 2, full amount Coverage Analysis Module 3, incremental coverage analysis module 4, the result of the difference analysis module 5, the timing task module 6 executed.
[0072]figure 2 is based onfigure 1 A main step of one embodiment of one embodiment of a system of one embodiment of the system. Includes the following steps:
[0073]S201, increasing the JacocoAgent agent to incorporate the JacocoAgent agent in the startup script of the test service (ie, the service / to be tested).
[0074]Add JacocoAgent options to the startup script to be tested, specify JacocoAgent.jar as a proxy, incoming parameters.
[0075]Specifically, the JacocoAgent module 1 modifies the JacocoAgent source code to customize the item name, service name, version number, code branch, platform IP (service_ip), platform port (service_port) and other parameters, while randomly generates a listener interface. JacocoAgent Module 1 Upload JacocoAgent.jar to the specified location of the server in the server, join -JacocoAgent: $ {Path} = include: $ {path} = include: $ {pat} = amount = tcpserver, port = $ = tcpserver, port = $ = tcpserver, port = $ = { Coverage platform port}, address = $ {coverage platform IP}, localaddress = $ {current service 在}, serviceName = $ {service name}, namespace = $ {project name}, serviceversion = $ {publish version }, Gitbranch = $ {git branch or tag}, append = true, start service.
[0076]JacocoAgent collects execution information. The JacocoAgent.jar is used to specify the path to JacocoAgent. The startup script of the service will initiate an agent added in the service, charge parameters, and send the parameters to the JacocoAgent data receiving module 2.
[0077]Among them, each parameter meanings is as follows:
[0078]INCLUDES: Indicates that only the classes under the specified package are covered into the infusion analysis, and the default is *.
[0079]OUTPUT: Indicates the output of the coverage. Effective options include: File, TCPServer, TcpClient, None. In TCPServer mode, Jacoco will uniformly write the clouds and ports that are currently collected to the specified IP and ports when performing DUMP operations at the client.
[0080]Port: The original only TCPServer and TCPCPCPClient use, the port number of the listener, the original JacocoAgent default 6300, and here, according to the embodiment of the present invention, by modifying this port is overwritten by modifying the JacocoAgent code Rate Analysis The port number 5000 of the platform is the random port that is automatically generated after the modified JacocoAgent, which will be sent to the coverage analysis platform (ie Jacoco-based test analysis system) together in the background.
[0081]Address: Use TCPServer with TCPClient, represents the listening application server IP address or host name.
[0082]Localaddress: Indicates the IP of the server that is currently under test.
[0083]ServiceName: Represents the service name of the currently under test.
[0084]Namespace: Represents the item name of the currently beingatched service belonging.
[0085]ServiceVersion: Represents the release version number of the currently measured service.
[0086]gitbranch: Lists branches or labels.
[0087]Append: indicates how to increase the coverage data, and the default is TRUE. When the client is executed, if the Exec coverage file already exists, the cloud coverage data will be added directly at the end of the text, so that the overc overlay file has existed, then the cover coverage data Will get bigger and bigger. If it is changed to FALSE, the client will directly empty the original coverage file when the client executes DUMP operation, ensuring that the coverage file is only the coverage data of the wheel.
[0088]S202, process the data uploaded by JacocoAgent, generate coverage analysis tasks and / or differential analysis tasks.
[0089]The tester enters a record through the Service Management page, the record contains: project name, service name, release version number, code warehouse address, code warehouse branch, code warehouse username, and password. Using the system, if the tester only needs to pass the basic data of the service management page maintenance service, JacocoAgent will pass to the corresponding parameters, and the analysis process will be automatically performed.
[0090]The JacocoAgent data receiving module 2 receives the data reported by the JacocoAgent module 1, compared with the data entered by the service management page, determines whether the service information of Jacoco is uploaded, and if confirmed, the JacocoAgent The data receiving module generates a coverage analysis task that can be a full amount coverage analysis task, or an incremental coverage analysis task, or simultaneously generate full amount coverage analysis tasks and incremental coverage analysis tasks. Further, if you confirm that the service is available, there is a differential analysis task.
[0091]Among them, compare the data from the data and service management page uploaded by JacocoAgent, mainly to find the code warehouse address / username / password of the corresponding service name + version number + branch, follow-up analysis needs to download the source code to the warehouse address. On the server.
[0092]If JacocoAgent upload service name + version number + code branch is already configured in the service management page, the parameters carrying JacocoAgent contains the Namespace (project name) + Agent listener interface, updated to the coverage analysis and difference analysis of MySQL In the relevant table, the subsequent analysis process will find the service name + version number + branch in the table, which is also overwritten through the TCP-Server mode Dump through the TCP-Server mode DUMP through the Agent IP and Agent listener in the table. Rate data.
[0093]S203, scanning by the timing task module 6, if there is a full amount coverage analysis task existing intervals greater than the second time period, jump to step S204; if there is an incremental coverage analysis task that performs intervals greater than the second time period Skip to step S205.
[0094]Step S204, call the full amount coverage analysis module 3 for full coverage analysis, end the flow.
[0095]Step S205, calling the incremental coverage analysis module 4 for incremental coverage analysis, ending the flow.
[0096]Test staff can see the full / incremental coverage results directly in the coverage of the system, and click on the link to view the detailed report.
[0097]The code coverage data can include the number of rows that override the code accounts for the proportion of the number of rows of the total code, and the package, classes, methods, and row information of the code are covered.
[0098]In a particular embodiment, the second time period is 30 minutes.
[0099]Further, it can also be scanned by a timing task module 6, and if there is a coverage analysis task that does not perform overview analysis or differential analysis, the overview of the coverage analysis task is jumped to step S206.
[0100]S206, call the difference analysis module 5 for version difference analysis, end the process.
[0101]The differential analysis module performs task scanning, generates differential data, generates difference data, stored in the database one by one, and each package, and each file, in the database, such as MongoDB.
[0102]Test staff can see the difference analysis report directly at the differential analysis management page of the system.
[0103]In a particular embodiment, the report can be displayed in a tree structure, accurate to each line, convenient and easy to use.
[0104]image 3 It is a flow chart of the main steps of the coverage statistical task generation process in one embodiment of a JACOCO based test analysis method according to the present invention. It includes:
[0105]S301, start the Java program to be tested using JacocoAgent.
[0106]S302, process the data uploaded by JacocoAgent, determine if the corresponding service information exists according to the ServiceName, ServiceVersion, Gitbranch parameter information, if the item name, service name, or release version number uploaded by JacocoAgent does not exist, jump to step S303, if there is Skip to step S304.
[0107]Further, it is judged that JacocoAgent upload data can only pass the service name + version number + branch. Since the project name NameSpace is just which projects are used, the service management page is just a management service, and a service may deploy to multiple projects, but if multiple items are used by the same service, it only needs to be distributed once, thus It can omit the comparison of the item name.
[0108]Specifically, the JacocoAgent data receiving module 2 receives the data uploaded by the JacocoAgent module, which is compared to the data entered by the service management page. According to the serviceName, ServiceVersion, Gitbranch parameters, it is determined whether the information of the service that is uploaded by Jacoco exists. (Examples of the specific comparison of upload data can be found in the description of the aforementioned JacocoAgent data receiving module 2). For example, a simple understanding of the test service is an application, a JAR package of a Java program, service name + version number + code branch, can determine a unique warehouse code, JacocoAgent first step is to confirm the service name + version number + Whether the branch exists, if you confirm that the existence will insert the data into the coverage and differential analysis related tables, the analysis process is triggered by scanning coverage and difference analysis related tables.
[0109]S303 does not work.
[0110]S304, it is judged whether or not there is a release version number in the published version table already exists, if the release version number already exists, jump to step S303, if not, jump to step S305.
[0111]In an example, each service has a version number (large version number), for example, the 3.1.1.7.2.2.4 of Android, and during a large version number, there will be only one JAR package, There is a release version number, that is, during the research and development of the entire large version, development every time the test environment is subtled once, there will be a JAR package, each JAR package corresponds to a release version number. For example, CW-bat-service This service large version number is 2.4.5, which can correspond to N release versions: 2.4.5-T2011171128, 2.4.5-T2011191203, etc. The Knee has a ServiceVersion in the parameter modified by the JacocoAgent source code is actually 2.4.5-T2011171128 Release version number ReleaseRVersion. Contrast version number in the release version number and service management, for example, the version number of the text / symbol / number and service management page before the release version number is contrast: Suppose the service version number is 2.4.5 The release version number is 2.4.5-T2011192010, the previous text number "-" is compared, that is, 2.4.5.
[0112]Further, analysis of coverage and differences is to analyze every JAR package. The JAR package corresponding to different release versions is different, so every JacocoAgent uploaded data, you must confirm that the release version number is There is a record, no insertion, there is no action.
[0113]S305, add a new release message corresponding to the release version number to the published version table.
[0114]S306, determining whether the coverage analysis table has existed the coverage analysis task corresponding to the current service, if it already exists, jump to step S307, if not, jump to step S308.
[0115]S307, if there is already a coverage analysis task corresponding to the current service in the overlay analysis table, there is no need to establish a task, directly using the service_ip, Service_Port parameter update overlay analysis table existing coverage analysis task service_IP, service_port field And set the task status as a valid, end the process.
[0116]S308, if there is no coverage analysis task corresponding to the current service in the coverage analysis table, the JacocoAgent data receiving module adds a coverage analysis task to the coverage analysis table, the coverage analysis task can be a full amount of coverage analysis The task can also be an incremental coverage analysis task, or simultaneously generate full amount coverage analysis tasks and incremental coverage analysis tasks, end the process.
[0117]Among them, which coverage is determined by the content of the test phase, such as before the online test, regression test, etc., mainly focused on the change of the change point, and the use of incremental coverage is ideal, if it is a new function Test, more ideal for using a full amount of coverage.
[0118]The coverage analysis task can include a line coverage (Classes), a Class coverage, a BRANCHES, C1COVERAGE, method coverage (Non-Abstract Methods), Instruction Level Coverage (Instruction, C0COVERAGE) Analysis of CyclomaticComplexity and statement block coverage.
[0119]Figure 4 One embodiment of a JACOCO-based test statistical and analytical method according to the present invention is schematically diagram with respect to the main steps of differential analysis tasks.Figure 4 As shown, including the following steps:
[0120]S401, start the Java program to be tested using JacocoAgent.
[0121]S402, process JacocoAgent uploaded data, serviceName, serviceversion, gitbranch parameter information to determine if the service information exists, if the top of JacocoAgent is uploaded, the service name, or the release version number does not exist, jump to step S403, if there is, jump Go to step S404. The relationship between the upload data and the database is compared.
[0122]Specifically, the JacocoAgent data receiving module receives the data reported by the JacocoAgent module to compare the data entered by the service management page. According to the serviceName, ServiceVersion, the gitbranch parameter is determined whether the information of the service name and other services across JACOCO is present.
[0123]For example, a simple understanding of the test service is an application, a JAR package of a Java program, service name + version number + code branch, can determine a unique warehouse code, JacocoAgent first step is to confirm the service name + version number + Whether the branch exists, if you confirm that the existence will insert the data into the coverage and differential analysis related tables, the analysis process is triggered by scanning coverage and difference analysis related tables.
[0124]S403 does not work.
[0125]S404, it is judged whether or not there is a release version number in the published version table, if the release version number does not exist, jump to step S403, if already existing, jump to step S405.
[0126]In an example, each service has a version number (large version number), for example, the 3.1.1.7.2.2.4 of Android, and during a large version number, there will be only one JAR package, There is a release version number, that is, during the research and development of the entire large version, development every time the test environment is subtled once, there will be a JAR package, each JAR package corresponds to a release version number. For example, CW-bat-service This service large version number is 2.4.5, which can correspond to N release versions: 2.4.5-T2011171128, 2.4.5-T2011191203, etc. The knee is actually the serviceversion in the parameter of the JacocoAgent source code is actually 2.4.5-T2011171128 release version number ReleaseRVersion, the release number and service management version number is contracted, for example, the text of the version number "-" before The version number provided in the symbol / number and service management page is compared: Assuming the service version number is 2.4.5, the release version number is 2.4.5-T2011192010, the previous text and service version number before the release is contrast That is 2.4.5.
[0127]Further, analysis of coverage and differences is to analyze every JAR package. The JAR package corresponding to different release versions is different, so every JacocoAgent uploaded data, you must confirm that the release version number is There is a record, no insertion, there is no action.
[0128]S405, determine if there is an old version in the current version, if there is no old version, no need to analyze, jump to step S403, if already existing, jump to step S406.
[0129]S406, if there is an old version in the current release, it is determined whether the difference analysis table has a differential analysis task corresponding to the current service. If there is already, no need to repeat the analysis, jump to step S403, if not, jump to step S407.
[0130]S407, if there is no differential analysis task corresponding to the current service in the differential analysis table, the difference analysis task is added to the differential analysis table, which is automatically, compared the current version and the old version, ending the entire process. .
[0131]In a particular embodiment, the difference in the current version and the previous version is default.
[0132]In a particular embodiment, the differential analysis module uses the Git Diff tool to compare two versions of Java files to obtain code difference status information between two version code.
[0133]In a particular embodiment, the code difference information between the two version of the code may be information such as changing the code row identifier (such as the changed code row) and the type of change. For example, in the current version code, the 7th, 8th, 9 is the new code line, the second, 3rd, 4 of the old version of the version is deleted, or the 7th line of the old version code is in the current version code. On the 14th line of replacement. The change type can include deletion, new, replacement, etc.
[0134]In a particular embodiment, in order to facilitate the calculation of the coverage, the coverage test speed can also be transformed into a label format, wherein the code difference tag can represent difference information between code lines, such as changing code. Row logo and change type, etc. For example, the code difference tag can include a change type identifier for representing a code change type, and a change code row identifier for identifying the change line row.
[0135]Test staff can see the difference analysis report directly at the differential analysis management page of the system.
[0136]In a particular embodiment, the report can be displayed in a tree structure, accurate to each line, convenient and easy to use.
[0137]Figure 5 In one embodiment of a JACOCO-based test analysis method according to the present invention, the main steps of the full coverage analysis are shown.
[0138]Wherein, the timing task module 6 performs a timing task, and if scanned to a full amount coverage task that conforms to the execution conditions, a command to generate a full amount coverage analysis report is performed.
[0139]The task of conforming the implementation conditions refers to the task status is online, and the time interval of the current task distance is successfully performed successfully, the time interval is greater than the second time period, for example, a full amount coverage analysis task of 30 minutes. Specifically, the following steps:
[0140]S501, perform timing task scans.
[0141]S502, it is judged whether or not the task status is a full coverage analysis task, if not, jump to step S503, if there is, jump to step S504.
[0142]S503, if there is no task that is not scanned to the task status, it means that the task currently not being executed is not to be executed.
[0143]S504, if scanned to task status is a task of online status, it is further determined whether or not to turn on the address of the service corresponding to the full-scale coverage analysis task, if it is not, jump to step S505, otherwise Jump to step S506.
[0144]S505, if the address and port of the service cannot be turned on, set the task to offline, do not make an analysis.
[0145]S506, if it is possible to turn on the address and port of the service, it is further determined whether the current task distance successfully executes a full amount coverage analysis task is greater than the second time period, if not, jump to step S507, if Skip to step S508.
[0146]S507, since the current task is not successfully performed in the previous time, the time period is less than the second time period, does not work.
[0147]S508, if the current task distance is successfully performed successfully, the time is greater than the second time period, further determine whether the source code of the service source code and the Maven package status are success, if successful, jump Go to step S509, otherwise the jump to step S510.
[0148]In one embodiment, for the full amount of coverage analysis module 3 using Git Clone Pull the source code of the corresponding test service from the code warehouse, the data is cloned into the new directory, and the source code for the corresponding test service is packaged is Maven package. These two packages are performed when the Git Clone and Maven package, which are executed. Other analytics will be executed after the full coverage analysis is performed. Also, the status of Git Clone and Maven will be updated in the database coverage table CW_COVERAGE_AALYZE in full analysis. When an incremental coverage analysis and difference analysis are performed, this state is checked in accordance with the item name Namespace + Servic + ReleaseVersionID to the coverage analysis.
[0149]The system will use the git command based on the corresponding code branch based on the passing parameters, and the submitted version number is downloaded, and the code download status is updated.
[0150]The system further packed the code to generate a corresponding test package while updating the Maven state.
[0151]S509, if the Git download source status and Maven package status are success, the git download source and Maven package operations are no longer re-executed, and go to step S512.
[0152]It should be noted that all analyzes are based on the source code. If the code of the source code has been downloaded, and Maven has been packaged, it will not need to repeat the download and package, will continue the analysis process.
[0153]S510, if git download source status and Maven package status are unsuccessful, perform Git Download Source Code and Maven Package Actions, update the Git and Maven status. Determining if the update Git and Maven status is successful, if the update git and maven status are unsuccessful, jump to step S511, otherwise jump to step S512.
[0154]S511, if the update status is unsuccessful, no full coverage analysis.
[0155]S512, if the update state is successful, perform a full amount coverage analysis, generate JACOCO analysis of the full coverage analysis report, store the report into the database (eg, mysql), and update the full amount coverage status of the service is successful, end the entire Process.
[0156]Wherein, the full coverage analysis report is to analyze the class files corresponding to all code generate coverage files. When analyzing the full amount coverage file generated, it is not necessary to analyze all, and only the part of the function code covered by the test function.
[0157]Figure 6 In one embodiment of JACOCO-based test analysis method according to the present invention, the main steps of incremental coverage analysis are shown.
[0158]In this method, the timing task module 6 performs a timing task, and if scanned to an incremental coverage task that conforms to the execution condition, a command to generate an incremental coverage analysis report is performed.
[0159]The task of conforming to perform conditions means that the task status is online, and the current task distance is successfully performed successfully increment overlay analysis task is greater than the second time period (for example, 30 minutes), and has been downloaded from Git and Executation coverage analysis tasks for Maven package. Specifically, including the following steps:
[0160]S601, perform timing tasks scanning.
[0161]S602, it is judged whether or not the task status is an incremental coverage analysis task of the online state. If not, the jump to step S603, if there is, the jump to step S604.
[0162]S603, if there is no scan to the task status as an incremental coverage analysis task of online state, indicating that the task that is currently not beinghaul is not to be executed, and do not do operation.
[0163]S604, if scanned to task status is an incremental coverage analysis task of online state, it is further determined whether or not the address and port of the service corresponding to the task can be turned on, if not, jump to step S605, otherwise jump to step S606 .
[0164]S605, set the increment coverage analysis task to offline, do not analyze.
[0165]S606, further determining whether the current task distance successfully performs incremental coverage analysis task is greater than the second time period, if not, jump to step S607, if y, jump to step S608.
[0166]S607, since the current task is not successfully performed in the previous successful incremental coverage analysis task, the second time period is not described.
[0167]S608, further determining whether the source code of the source code corresponding to the incremental coverage analysis task (ie git clone) and the Maven package status are success, if it is not successful, jump to step S609, otherwise jump to Step S610.
[0168]S609, if the Git download source status and Maven package status are unsuccessful, no incremental coverage analysis is performed.
[0169]S610, if the Git download source status and Maven package status are successful, further confirm that the source code of the two versions of the Java file is analyzed, that is, the Difference status of the Java file.
[0170]S611, it is judged whether or not the difference analysis state of the Java file is not start or fail, if so, jump to step S612.
[0171]S612 does not perform incremental coverage analysis tasks.
[0172]S613, it is determined whether the difference analysis status of the Java file is a successful analysis, and there is no difference in two versions or no old versions. If so, jump to step S614.
[0173]S614, update incremental coverage analysis status is no increment, ending the entire process.
[0174]S615, it is determined whether the difference analysis status of the Java file is a successful analysis, and there is a difference between the two versions. If so, jump to step S616.
[0175]S616, if the difference analysis status of the Java file is a successful analysis, there is a difference between the two versions, perform incremental coverage analysis, generates a Jacoco analysis report with a different package, removing excess content in the report, re-statistical coverage Total number, store the report path into the database (eg, mysql), and update the service's incremental coverage status is successful, ending the entire process.
[0176]In one embodiment, the principle of incremental analysis is: first writing code analysis which Java files between two versions have differences, record the differences in the package name and class name to MongoDB; then, execute incremental coverage analysis At the time, only the BUILD.XML file for Jacoco analysis is generated according to the difference in the package, then after the analysis is performed, only the coverage report of DUMP or above; then process HTML, traversing each package HTML, delete unreparable class files. After deleting excess information, repeat each HTML, re-press the coverage data to modify the existing classes. Eventually generates increments that only contain differences Coverage report.
[0177]The incremental coverage analysis report is based on the difference in development code changes, and the range of the generated class file is only included only the modified portion. In this way, when the coverage report is analyzed, the generated report file contains only the difference part, and then the code coverage result is generated only to generate this part according to this range.
[0178]Figure 7 ,8It is a full amount, incremental coverage analysis effect diagram according to an embodiment of the present invention.
[0179]Such asFigure 7 As shown, through the coverage analysis management page, you can get the project name, service name, release version number, git download source status, Maven package status, Java file difference status, increment analysis status, full analysis status, task status, update time , And operating status.
[0180]Such asFigure 8 As shown, the test coverage ratio indicated in progress bar (e.g., the ratio of instructions that are not actually tested and the required to be tested, the actual test, the proportion of branches that need to be tested, etc. ), With the percentage of test coverage, the number of codes that are not actually tested, the number of codes, specific methods, class, etc. corresponding to the code, the corresponding test coverage, and the corresponding actual test The number of codes, the number of pieces that are not actually tested, and the like.
[0181]The content included in the generated test report can be set as needed.
[0182]Figure 9 In one embodiment of a JACOCO-based test analysis method according to the present invention, the main steps of differential analysis are shown.
[0183]In this method, the timing task module 6 performs a timing task, and if scanned to a difference task that conforms to the execution condition, a command to generate a differential analysis report is performed.
[0184]The task of conforming to perform conditions refers to the task status online, the task analysis status is not start or fail, has been downloaded from the Git Clone to download the source code and perform the difference analysis task of the Maven package. Specifically, the following steps:
[0185]S901, perform timing tasks scanning.
[0186]S902, it is determined whether to scan to the task status is online state, and the analysis status is a differential analysis task that does not start or fail. If not, jump to step S903, if there is, jump to step S904.
[0187]S903, due to the task currently not being executed, do not do operation.
[0188]S904, it is determined whether or not the address and port of the service corresponding to the difference analysis task can be turned on. If it is not possible, the jump to step S905, otherwise the jump to step S906.
[0189]S905, if you cannot turn on the address and port of the service corresponding to the differential analysis task, set the difference analysis task to offline, do not make an analysis.
[0190]S906, further determining whether the current task distance successfully performs a difference analysis task is greater than the second time period, if not, jump to step S907, if y, jump to step S908.
[0191]S907, since the current task is not successfully executed at the last time the difference analysis task is less than the second time period, do not do operation.
[0192]S908, further determining that the two release versions of the service corresponding to the difference analysis task are successful and whether the Maven package status is success (see the package judgment in the example of the exemplification of the incremental coverage analysis), If you are not successful, you jump to step S909, otherwise you jump to step S910. The two release versions refer to the current version and the old version. In a particular embodiment, the default two release is the current version and the previous version.
[0193]S909, if the two released version of the git download source status and Maven packaged status are not successful, the difference analysis task is not performed.
[0194]S910, perform a full amount of difference analysis, generate Jacoco differential analysis report, store the report details in the database, update the difference analysis status of the service is successful, and change the difference analysis of the difference analysis of two releases in the database, end Process.
[0195]In a particular embodiment, the differential analysis module uses the Git Diff tool to compare two versions of Java files to obtain code difference status information between two version code. Specifically, the current version code is changed by the current version code with the old version code with the old version code, calculates the offset of the code.
[0196]In a particular embodiment, the code difference information between the two version of the code may be information such as changing the code row identifier (such as the row number of the changed code row) and the type of change, including the package, class, method of modified code. And travel information, etc., the line information includes the specific modified line of code and the number of modified total lines. For example, in the current version code, the 7th, 8th, 9 is the new code line, the second, 3rd, 4 in the old version code is to delete the code line, or the 7th line code in the old version code is in the current version of the code 14 Line replacement, etc. The change type can include deletion, new, replacement, etc.
[0197]In a particular embodiment, in order to facilitate the calculation of the coverage, the coverage test speed can also be transformed into a label format, wherein the code difference tag can represent difference information between code lines, such as changing code. Row logo and change type, etc. For example, the code difference tag can include a change type identifier for representing a code change type, and a change code row identifier for identifying the change line row.
[0198]Test staff can see the difference analysis report directly at the differential analysis management page of the system.
[0199]In a particular embodiment, the report can be displayed in a tree structure, accurate to each line, convenient and easy to use.
[0200]The difference analysis effect is likeFigure 10 ,11Indicated.
[0201]Through the technical solution of the present invention, the automatic analysis of a large number of services can be implemented by transformation and re-developing business logic, providing a full-scale / incremental coverage analysis of the testers. And differential analysis tools, solve problems that have previously test coverage cannot accurately and accurately regain the test range.
[0202]It should be noted that although the various steps are described in the above embodiments, those skilled in the art will appreciate that in order to achieve the effects of the present invention, different steps must not be performed in this order. It can be performed at the same time (parallel) or in other order, which are within the scope of the invention.
[0203]Those skilled in the art can understand that the present invention achieves all or partial flows in the method of the above-described one embodiment, or can be done by a computer program to direct instructions, and the computer program can be stored in a computer readable. In the storage medium, the step of each method embodiment can be realized when executed by the processor. Wherein, the computer program includes a computer program code that can be a source code form, an object code form, an executable file, or some intermediate form.
[0204]Further, the present invention also provides a computer readable storage medium. In a computer readable storage medium embodiment according to the present invention, the storage device can be configured to store a program that performs the above method embodiments, which can be loaded and operated by the processor to implement the steps of each of the above method embodiments. For convenience of explanation, only the part related to the embodiment of the present invention is shown, and the specific technical details are not disclosed, refer to the embodiment of the embodiment of the present invention. The storage device may be a storage device device formed by various electronic devices, optionally, stored in an embodiment of the present invention, stored a non-temporary computer readable storage medium. The computer readable medium may include any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, and electrical carrier signal capable of carrying the computer program code. , Telecommunications signals and software distribution media, etc. It should be noted that the contents of the computer readable medium can be appropriately increased and decreased according to the requirements of legislation and patent practice within the judicial jurisdiction, such as in some jurisdiction, according to legislation and patent practice, computer readable media Does not include electrical carrier signals and telecommunications signals.
[0205]Further, the present invention also provides a terminal device. In a terminal device embodiment according to the present invention, it includes a processor and a storage device, and the storage device can be configured to store a program of each method embodiment described above, and the processor can be configured to perform a program in a storage device. The program includes, but is not limited to, a program that performs the method of the above method embodiment. For convenience of explanation, only the part related to the embodiment of the present invention is shown, and the specific technical details are not disclosed, refer to the embodiment of the embodiment of the present invention. The terminal device may be a control or processing device including various electronic devices.
[0206]This embodiment is mainly described by the implementation of the present invention in a scenario applied to the terminal device (system platform). The hardware structure of the terminal device is likeFigure 12 Indicated. The terminal device can include an input device 1100, a first processor 1101, an output device 1102, a first memory 1103, and at least one communication bus 1104. Communication bus 1104 is used to realize communication connections between components. The first memory 1103 may include a high speed RAM memory, and may further include a non-volatile storage NVM, such as at least one disk memory, and various programs can be stored in the first memory 1103 for completing various processing functions and implementing the present embodiment. Method steps.
[0207]Optionally, the first processor 1101 may, for example, a central processor (CPU), a dedicated integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), programmable Logic Device (PLD), Field Programmable Door Array (FPGA), controller, microcontroller, microprocessor or other electronic component, the processor 1101 is implemented by a wired or wireless connection to the input device 1100 and an output device 1102 .
[0208]Alternatively, the input device 1100 can include a plurality of input devices, such as may include at least one of the user-oriented user interface, a device-oriented device interface, a programmable interface, a camera, and a sensor. Optionally, the device-oriented device interface can be a wired interface for data transmission between the device and the device, and may also be a hardware insertion interface for data transmission between the device and the device (eg, a USB interface, serial port, etc. ); Optional, the user interface, for example, may be, for example, a user-oriented control button for receiving voice input devices for voice input, and a user receiving user touch input touch sensing device (eg, a touch screen having a touch sensing function, touching Control panel, etc.); Optional, the programmable interface of the above software can be, for example, an entry for user editing or modifying a program, such as an input pin interface or an input interface of a chip; output device 1102 can include display, audio, etc. . In the present embodiment, the processor of the terminal device includes functions, specific functions, and technical effects for performing various modules of various devices, refer to the above embodiment, and will not be described later herein.
[0209]Figure 13A hardware structure of a terminal device provided for another embodiment of the present application.Figure 13is trueFigure 12 A specific embodiment in the implementation process. As shown, the terminal device of the present embodiment can include a second processor 1201 and a second memory 1202.
[0210]The second processor 1201 performs the computer program code stored by the second memory 1202 to implement the above embodiment.figure 1 The method is described. The second memory 1202 is configured to store various types of data to support the operation of the terminal device. Examples of this data include instructions for any application or method for operating on the terminal device, such as messages, pictures, videos, and the like. The second memory 1202 may include a random access memory (referred to as RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0211]Alternatively, the first processor 1201 is disposed in the processing component 1200. The terminal device may also include a communication component 1203, a power supply component 1204, a multimedia component 1205, a voice module 1206, an input / output interface 1207, and / or sensor assembly 1208. The components contained in the terminal device may be set according to the actual demand setting, and this embodiment does not limit this.
[0212]Processing component 1200 typically controls the overall operation of the terminal device. Processing component 1200 can include one or more second processor 1201 to perform instructions to complete the abovefigure 1 All or some steps of the method shown. Further, the processing assembly 1200 can include one or more modules that facilitate interaction between component 1200 and other components. For example, processing component 1200 can include a multimedia module to facilitate interaction between multimedia components 1205 and processing component 1200. Power component 1204 provides power for various components of the terminal device. Power component 1204 can include a power management system, one or more power supplies, and other components associated with generating, managing, and assigning power for terminal devices. Multimedia component 1205 includes a display of providing an output interface between the terminal device and the user. In some embodiments, the display can include a liquid crystal display (LCD) and a touch panel (TP). If the display includes a touch panel, the display can be implemented as a touch screen to receive an input signal from the user. The touch panel includes one or more touch sensors to sense the gestures on the touch, slide, and touch panels. The touch sensor may not only sense the boundary of the touch or slide operation, but also detect the duration and pressure associated with the touch or sliding operation. Voice assembly 1206 is configured to output and / or input speech signals. For example, voice assembly 1206 includes a microphone (MIC) that is configured to receive an external speech signal when the terminal device is in operation mode, as a speech recognition mode. The received speech signal can be further stored in the second memory 1202 or via the communication component 1203. In some embodiments, voice assembly 1206 also includes a speaker for outputting a speech signal.
[0213]The input / output interface 1207 provides an interface between the processing component 1200 and the peripheral interface module, and the peripheral interface module can be a hunch, buttons, and the like. These buttons can include, but are not limited to: volume buttons, start buttons, and lock buttons.
[0214]Sensor assembly 1208 includes one or more sensors for assessing a state assessment of various aspects for terminal devices. For example, sensor assembly 1208 can detect the opening / closing state of the terminal device, the relative positioning of the components, the presence or absence of the user contacts the terminal device. The sensor assembly 1208 can include a proximity sensor configured to detect the presence of the nearby object when there is no physical contact, including detecting the distance between the user and the terminal device. In some embodiments, the sensor assembly 1208 can also include a camera or the like.
[0215]Communication component 1203 is configured to facilitate communication between terminal devices and other devices. The terminal device can access a communication standard wireless network such as WiFi, 2G or 3G, or a combination thereof. In one embodiment, the terminal device can include a SIM card slot, which is used to insert the SIM card so that the terminal device can log in to the GPRS network and establish communication with the server via the Internet.
[0216]It can be found inFigure 13The communication module 1203, voice assembly 1206, and input / output interface 1207, and sensor assembly 1208 can be used asimage 3 The implementation of the input device in the embodiment.
[0217]Further, the present invention also provides a terminal device or a service platform, including the aforementioned Jacoco-based test analysis system.
[0218]Further, it should be understood that since the setting of each module is merely a functional unit of the system of the present invention, the physical device corresponding to these modules may be a processor itself, or part of the software in the processor, part of the hardware, or Part of software and hardware. Therefore, the number of each module in the figure is merely schematic.
[0219]It will be understood by those skilled in the art that each module in the system can be adapted or combined. This split or merge of a specific module does not cause technical solutions to deviate from the principles of the invention, and therefore, the technical solutions after split or combined will fall within the scope of the invention.
[0220]Here, the technical solution of the present invention has been described in connection with the drawings, however, those skilled in the art is that the scope of the invention is clearly not limited to these specific embodiments. Under the premise of not departing from the principles of the invention, those skilled in the art can make equivalents or alternatives of the related art feature, and the technical solutions after these changes or replacements will fall within the scope of the invention.

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products