CN112052160A - Code case obtaining method and device, electronic equipment and medium - Google Patents
Code case obtaining method and device, electronic equipment and medium Download PDFInfo
- Publication number
- CN112052160A CN112052160A CN202010785347.7A CN202010785347A CN112052160A CN 112052160 A CN112052160 A CN 112052160A CN 202010785347 A CN202010785347 A CN 202010785347A CN 112052160 A CN112052160 A CN 112052160A
- Authority
- CN
- China
- Prior art keywords
- code
- use case
- sample
- case
- test
- 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
- 238000000034 method Methods 0.000 title claims abstract description 49
- 238000012360 testing method Methods 0.000 claims abstract description 94
- 230000008859 change Effects 0.000 claims abstract description 53
- 230000004069 differentiation Effects 0.000 claims abstract description 30
- 238000012549 training Methods 0.000 claims abstract description 26
- 238000012216 screening Methods 0.000 claims abstract description 18
- 230000001960 triggered effect Effects 0.000 claims description 14
- 238000012544 monitoring process Methods 0.000 claims description 12
- 239000011159 matrix material Substances 0.000 claims description 11
- 230000015654 memory Effects 0.000 claims description 9
- 238000004590 computer program Methods 0.000 claims description 7
- 238000010276 construction Methods 0.000 claims description 4
- 238000004138 cluster model Methods 0.000 claims description 2
- 239000013598 vector Substances 0.000 abstract description 9
- 230000003287 optical effect Effects 0.000 description 5
- 238000010586 diagram Methods 0.000 description 3
- 230000005291 magnetic effect Effects 0.000 description 3
- 238000005034 decoration Methods 0.000 description 2
- 238000011156 evaluation Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000011990 functional testing Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
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
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/21—Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
- G06F18/214—Generating training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/22—Matching criteria, e.g. proximity measures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/23—Clustering techniques
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/194—Calculation of difference between files
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Artificial Intelligence (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Computation (AREA)
- Evolutionary Biology (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a code use case acquisition method, a code use case acquisition device, an electronic device and a medium, wherein the code use case acquisition method comprises the following steps: establishing a matching relation between the sample use case and the sample code; carrying out unsupervised learning training on the matching relation between the sample case and the sample code to construct a clustering model of the case and the code; acquiring a code change differentiation file; screening out test cases according to the code change differentiation files; and taking the test cases as the input of the clustering models of the use cases and the codes, so that the clustering models of the use cases and the codes classify the test cases and output a use case set with the highest coverage rate. According to the method and the device, the relation between the use cases and the codes can be used as the characteristic vectors, the use cases are distributed to different use case sets by using a clustering algorithm, only part of use cases are recommended when the test use cases are recommended, and all use cases are not required to be executed, so that the coverage rate of differential codes is ensured to be more than 80%, the use case density is also reduced, and the test efficiency is improved.
Description
Technical Field
The application relates to the technical field of computers, in particular to a method and a device for acquiring a use case of a code, an electronic device and a medium.
Background
The traditional functional test only focuses on the black box test at the requirement level, and when the test range is regressed, the regression range is only evaluated under the guidance of developers. The evaluation is too subjective, the evaluation is difficult to avoid, and a large number of missing measurement problems occur. And many times because the phenomenon appears that the code is merged wrongly or the development is carried with the online, etc., the test is finished only by the requirement, and the incomplete test is easy to appear.
In order to solve the problems existing in the black box test, attention is paid to the white box test based on codes, and the white box test and the black box test are different in that the white box test pays attention to the codes covered by the use cases when the use cases are executed, the relation between the codes and the use cases is established, and the corresponding use cases are recommended according to the condition of changing the codes during each round of test.
However, in the code, many basic methods are called by many use cases, once the basic methods are changed, a large number of use cases are recommended to be executed, so that the number of use cases to be executed is greatly increased, and the efficiency of testers is seriously influenced.
Disclosure of Invention
The application provides a method, a device, an electronic device and a medium for acquiring a use case of a code, and aims to solve at least one of the technical defects. The technical scheme adopted by the application is as follows:
a first aspect of the present application provides a method for acquiring a use case of a code, where the method includes:
establishing a matching relation between the sample use case and the sample code;
carrying out unsupervised learning training on the matching relation between the sample use case and the sample code to construct a clustering model of the use case and the code;
acquiring a code change differentiation file;
screening out test cases according to the code change differentiation file;
and taking the test case as the input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate.
According to the method, the relation between the use cases and the codes can be used as the feature vectors, the use cases are distributed to different use case sets by using a clustering algorithm, only part of use cases are recommended when the test use cases are recommended, and all use cases are not required to be executed, so that the coverage rate of differential codes is ensured to be more than 80%, the use case density is also reduced, and the test efficiency is improved.
In the first aspect of the present application, as an optional implementation manner, the establishing a matching relationship between a sample use case and a sample code includes:
inserting a monitoring packet into a project, monitoring code change in the project according to the monitoring packet and determining the sample code when the sample use case is triggered and executed by a target user;
acquiring the execution state of the sample use case;
and when the execution of the sample use case is judged to be finished according to the execution state of the sample use case, establishing the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs, and taking the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs as the matching relation between the sample use case and the sample code.
In this optional embodiment, a matching relationship between the sample use case and the sample code may be established by the ID of the sample use case, the ID of the project, the line number of the sample code, and the ID of the class to which the sample code belongs.
In the first aspect of the present application, as an optional implementation manner, before inserting a listening packet in a project to listen to a code change in the project according to the listening packet and determine the sample code when the sample use case is triggered to be executed by a user, the method further includes:
acquiring IP addresses of a plurality of preset users, and taking the IP address of each preset user as a unique identifier of each preset user;
and when the sample use case is triggered and executed by a plurality of preset users, determining the target user according to the unique identifier of each preset user.
In this optional embodiment, when the sample use case is triggered and executed by a plurality of preset users, since the IP address can be used as a unique identifier for identifying the user, the target user can be determined from the preset user through the IP address, and thus, a case and code relationship establishment error in a multi-user execution use case is avoided.
In the first aspect of the present application, as an optional implementation manner, the performing unsupervised learning training on the matching relationship between the sample use case and the sample code to construct a cluster model of use cases and code includes:
converting the relation between the sample use case ID and the engineering ID, the line number of the sample code and the ID of the class to which the sample code belongs into a relation matrix;
training a plurality of preset clustering models by using the relation matrix as training data, and determining an optimal clustering model from the plurality of preset clustering models according to the training results of the plurality of preset clustering models;
and taking the optimal clustering model as the clustering model of the use case and the code.
In this optional embodiment, the optimal clustering model can be determined by training a plurality of preset clustering models through the relationship matrix.
In the first aspect of the present application, as an optional implementation manner, the screening out test cases according to the code change differentiation file includes:
acquiring the line number information of the changed codes in the code change differentiation file;
and screening out the use cases related to the change from a plurality of sample use cases according to the line number information of the code with the change and the matching relation between the sample use cases and the sample codes, and using the use cases as the test use cases.
In this optional embodiment, by acquiring the line number information of the changed code in the code change differentiation file, a use case related to the change can be screened from a plurality of sample use cases according to the line number information of the changed code and the matching relationship between the sample use cases and the sample codes, and the use case can be used as the test use case.
In the first aspect of the present application, as an optional implementation manner, before the obtaining the code change differentiation file, the method further includes:
when a code branch is created, the original version of the JAVA file is reserved;
and when the JAVA file of the new version is submitted, comparing the JAVA file of the original version with the JAVA file of the new version, and generating the code change differential file.
In this optional embodiment, the code change differentiation file may be generated by comparing the JAVA file of the original version with the JAVA file of the new version.
In the first aspect of the present application, as an optional implementation manner, the using the test case as an input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate includes:
taking the test case as the input of the clustering model of the use case and the code, so that the clustering model of the use case and the code outputs the coverage rate of the test case;
determining a case set with the highest coverage rate according to the coverage rate of the test case;
and after the case set with the highest coverage rate is determined according to the coverage rate of the test cases, the method further comprises the following steps:
executing each use case in the use case set with the highest coverage rate on the test codes, and counting the use case density of the test codes and the coverage rate of each use case in the use case set with the highest coverage rate so as to enable testers to evaluate.
In this optional embodiment, the case set with the highest coverage rate can be determined by the coverage rate of the test case.
A second aspect of the present application provides a use case acquiring apparatus for a code, where the use case acquiring apparatus includes:
the establishing module is used for establishing a matching relation between the sample use case and the sample code;
the construction module is used for carrying out unsupervised learning training on the matching relation between the sample use case and the sample codes so as to construct a clustering model of the use case and the codes;
the first acquisition module is used for acquiring a code change differentiation file;
the screening module is used for screening out test cases according to the code change differentiation files;
and the output module is used for taking the test case as the input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate.
According to the case obtaining device of the codes, the case and code relation can be used as the characteristic vector through the case obtaining method of the execution codes, the cases are distributed to different case sets through the clustering algorithm, only part of the cases are recommended when the test cases are recommended, all the cases are not required to be executed, and therefore the coverage rate of the differentiated codes is guaranteed to be more than 80%, the case density is reduced, and the test efficiency is improved.
A third aspect of the present application provides an electronic device, comprising:
a processor; and
a memory configured to store machine-readable instructions, which when executed by the processor, cause the processor to perform a use case acquisition method of the code provided in the first aspect of the present application.
According to the electronic equipment for codes, the relation between the use cases and the codes can be used as the characteristic vector through the use case obtaining method for executing the codes, the use cases are distributed to different use case sets through the clustering algorithm, only part of the use cases are recommended when the test use cases are recommended, and all the use cases are not required to be executed, so that the coverage rate of differential codes is guaranteed to be more than 80%, the use case density is reduced, and the test efficiency is improved.
A fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the use case obtaining method provided by the first aspect of the present application.
According to the computer-readable storage medium of the codes, the relation between the use cases and the codes can be used as the feature vectors through the use case obtaining method of the execution codes, the use cases are distributed to different use case sets through the clustering algorithm, when the test use cases are recommended, only part of the use cases are recommended, all the use cases are not required to be executed, and therefore the coverage rate of the differentiated codes is guaranteed to be more than 80%, the density of the use cases is reduced, and the test efficiency is improved.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a schematic flowchart of a use case obtaining method of a code according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a use case obtaining apparatus for a code according to a second embodiment of the present application;
fig. 3 is a schematic structural diagram of an electronic device according to a third embodiment of the present application.
Detailed Description
Reference will now be made in detail to the present application, examples of which are illustrated in the accompanying drawings, wherein like reference numerals refer to the same or similar parts or parts having the same or similar functions throughout.
It will be understood by those within the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
Referring to fig. 1, fig. 1 is a schematic flowchart of a method for acquiring a code use case according to an embodiment of the present application. As shown in fig. 1, a use case obtaining method of a code according to an embodiment of the present application includes the steps of:
101. establishing a matching relation between the sample use case and the sample code;
102. carrying out unsupervised learning training on the matching relation between the sample case and the sample code to construct a clustering model of the case and the code;
103. acquiring a code change differentiation file;
104. screening out test cases according to the code change differentiation files;
105. and taking the test cases as the input of the clustering models of the use cases and the codes, so that the clustering models of the use cases and the codes classify the test cases and output a use case set with the highest coverage rate.
According to the method, the relation between the use cases and the codes can be used as the feature vectors, the use cases are distributed to different use case sets by using a clustering algorithm, only part of use cases are recommended when the test use cases are recommended, and all use cases are not required to be executed, so that the coverage rate of differential codes is ensured to be more than 80%, the use case density is also reduced, and the test efficiency is improved.
In this embodiment of the present application, as an optional implementation manner, establishing a matching relationship between a sample use case and a sample code includes:
inserting a monitoring packet into the project so as to monitor code change in the project according to the monitoring packet and determine a sample code when the sample use case is triggered and executed by a target user;
acquiring an execution state of a sample case;
and when the execution of the sample use case is judged to be finished according to the execution state of the sample use case, establishing the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs, and taking the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs as the matching relation between the sample use case and the sample code.
In this optional embodiment, the matching relationship between the sample use case and the sample code may be established by the ID of the sample use case, the ID of the project, the line number of the sample code, and the ID of the class to which the sample code belongs.
In this embodiment, as an optional implementation manner, before inserting a monitoring packet into a project to monitor a code change in the project according to the monitoring packet and determine a sample code when a sample use case is triggered by a user, the method further includes:
acquiring IP addresses of a plurality of preset users, and taking the IP address of each preset user as a unique identifier of each preset user;
when the sample use case is triggered and executed by a plurality of preset users, the target user is determined according to the unique identification of each preset user.
In the optional embodiment, when the sample use case is triggered and executed by multiple preset users, the IP address can be used as a unique identifier for identifying the user, so that the target user can be determined from the preset user through the IP address, and further, the error in establishing the relation between the use case and the code in the multi-user execution use case is avoided.
In the embodiment of the present application, as an optional implementation manner, the unsupervised learning training is performed on the matching relationship between the sample use case and the sample code to construct a clustering model of the use case and the code, including:
converting the relation between the sample case ID and the engineering ID, the line number of the sample code and the ID of the class to which the sample code belongs into a relation matrix;
training a plurality of preset clustering models by using the relation matrix as training data, and determining an optimal clustering model from the plurality of preset clustering models according to the training results of the plurality of preset clustering models;
and taking the optimal clustering model as a clustering model of the use case and the code.
In this optional embodiment, the optimal clustering model can be determined by training a plurality of preset clustering models through the relationship matrix.
In this embodiment, as an optional implementation manner, screening out a test case according to a code change differentiation file includes:
acquiring line number information of changed codes in a code change differentiation file;
and screening out the use cases related to the change from a plurality of sample use cases according to the line number information of the code with the change and the matching relation between the sample use cases and the sample codes, and using the use cases as test cases.
In the optional embodiment, by acquiring the line number information of the changed code in the code change differentiation file, a case related to the change can be screened from a plurality of sample cases according to the line number information of the changed code and the matching relationship between the sample cases and the sample code, and the case can be used as a test case.
In this embodiment of the present application, as an optional implementation manner, before obtaining the code change differentiation file, the method further includes:
when a code branch is created, the original version of the JAVA file is reserved;
and when the JAVA file of the new version is submitted, comparing the JAVA file of the original version with the JAVA file of the new version, and generating a code change differential file.
In the optional embodiment, the code change differentiation file can be generated by comparing the JAVA file of the original version with the JAVA file of the new version.
In this embodiment of the present application, as an optional implementation manner, using a test case as an input of a clustering model of use cases and codes, so that the clustering model of use cases and codes classifies the test case and outputs a use case set with a highest coverage rate, includes:
the test case is used as the input of a clustering model of the use case and the code, so that the clustering model of the use case and the code outputs the coverage rate of the test case;
determining a case set with the highest coverage rate according to the coverage rate of the test cases;
and after determining the case set with the highest coverage rate according to the coverage rate of the test cases, the method further comprises the following steps:
and executing each case in the case set with the highest coverage rate on the test code, and counting the case density of the test code and the coverage rate of each case in the case set with the highest coverage rate so as to enable the tester to evaluate.
In the optional embodiment, the case set with the highest coverage rate can be determined by testing the coverage rate of the cases.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a device for acquiring a code use case according to an embodiment of the present application. As shown in fig. 2, the use case acquiring apparatus of the code includes:
an establishing module 201, configured to establish a matching relationship between a sample use case and a sample code;
the construction module 202 is configured to perform unsupervised learning training on a matching relationship between a sample case and a sample code to construct a case-code clustering model;
the first obtaining module 203 is configured to obtain a code change differentiation file;
the screening module 204 is used for screening test cases according to the code change differentiation files;
the output module 205 is configured to use the test case as an input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate.
According to the code use case obtaining device, the use case and code relation can be used as the feature vector through the code use case obtaining method, the use cases are distributed to different use case sets through the clustering algorithm, when the test use cases are recommended, only part of the use cases are recommended, all the use cases are not required to be executed, therefore, the coverage rate of the differentiated codes is guaranteed to be more than 80%, the use case density is reduced, and the test efficiency is improved.
In this embodiment of the present application, as an optional implementation manner, a specific manner for the establishing module 201 to execute and establish the matching relationship between the sample use case and the sample code is as follows:
inserting a monitoring packet into the project so as to monitor code change in the project according to the monitoring packet and determine a sample code when the sample use case is triggered and executed by a target user;
acquiring an execution state of a sample case;
and when the execution of the sample use case is judged to be finished according to the execution state of the sample use case, establishing the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs, and taking the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs as the matching relation between the sample use case and the sample code.
In this optional embodiment, the matching relationship between the sample use case and the sample code may be established by the ID of the sample use case, the ID of the project, the line number of the sample code, and the ID of the class to which the sample code belongs.
In this embodiment of the present application, as an optional implementation manner, the device for acquiring a use case of a code in this embodiment of the present application further includes a second acquiring module and a determining module, where:
the second acquisition module is used for acquiring the IP addresses of a plurality of preset users and taking the IP address of each preset user as the unique identifier of each preset user;
and the determining module is used for determining the target user according to the unique identifier of each preset user when the sample use case is triggered and executed by a plurality of preset users.
In the optional embodiment, when the sample use case is triggered and executed by multiple preset users, the IP address can be used as a unique identifier for identifying the user, so that the target user can be determined from the preset user through the IP address, and further, the error in establishing the relation between the use case and the code in the multi-user execution use case is avoided.
In the embodiment of the present application, as an optional implementation manner, the construction module 202 performs unsupervised learning training on the matching relationship between the sample use case and the sample code, and a specific manner of constructing a clustering model of the use case and the code is as follows:
converting the relation between the sample case ID and the engineering ID, the line number of the sample code and the ID of the class to which the sample code belongs into a relation matrix;
training a plurality of preset clustering models by using the relation matrix as training data, and determining an optimal clustering model from the plurality of preset clustering models according to the training results of the plurality of preset clustering models;
and taking the optimal clustering model as a clustering model of the use case and the code.
In this optional embodiment, the optimal clustering model can be determined by training a plurality of preset clustering models through the relationship matrix.
In this embodiment, as an optional implementation manner, a specific manner for the screening module 204 to screen out the test cases according to the code change differentiation file is as follows:
acquiring line number information of changed codes in a code change differentiation file;
and screening out the use cases related to the change from a plurality of sample use cases according to the line number information of the code with the change and the matching relation between the sample use cases and the sample codes, and using the use cases as test cases.
In the optional embodiment, by acquiring the line number information of the changed code in the code change differentiation file, a case related to the change can be screened from a plurality of sample cases according to the line number information of the changed code and the matching relationship between the sample cases and the sample code, and the case can be used as a test case.
In this embodiment of the present application, as an optional implementation manner, the use case obtaining apparatus of the code in this embodiment of the present application further includes a storage module and a comparison module, where:
the storage module is used for reserving the JAVA file of the original version when the code branch is created;
and the comparison module is used for comparing the JAVA file of the original version with the JAVA file of the new version when the JAVA file of the new version is submitted, and generating a code change differential file.
In the optional embodiment, the code change differentiation file can be generated by comparing the JAVA file of the original version with the JAVA file of the new version.
In this embodiment of the present application, as an optional implementation manner, the output module 205 executes that the test case is used as an input of a clustering model of the use cases and the codes, so that a specific manner of classifying the test cases by the clustering model of the use cases and the codes and outputting a use case set with the highest coverage rate is as follows:
the test case is used as the input of a clustering model of the use case and the code, so that the clustering model of the use case and the code outputs the coverage rate of the test case;
and determining the case set with the highest coverage rate according to the coverage rate of the test cases.
Correspondingly, the device for acquiring the use case of the code in the embodiment of the application further includes a statistical module, wherein:
and the statistical module is used for executing each use case in the use case set with the highest coverage rate on the test codes, and performing statistics on the use case density of the test codes and the coverage rate of each use case in the use case set with the highest coverage rate so as to enable the testers to evaluate.
In the optional embodiment, the case set with the highest coverage rate can be determined by testing the coverage rate of the cases.
An embodiment of the present application provides an electronic device, which includes:
a processor 301; and
the memory 302 is configured to store machine-readable instructions, and when the instructions are executed by the processor 301, the processor 301 is caused to execute a use case obtaining method of the code provided in the first embodiment of the present application.
Those skilled in the art will appreciate that the electronic devices provided by the embodiments of the present application may be specially designed and manufactured for the required purposes, or may comprise known devices in general-purpose computers. For example, the electronic device may be a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and the like, and the embodiment of the present application does not limit the specific type of the electronic device. These devices have stored therein computer programs that are selectively activated or reconfigured. Such a computer program may be stored in a device (e.g., computer) readable medium or in any type of medium suitable for storing electronic instructions and respectively coupled to a bus.
The Memory 302 in the electronic device of the present application may be a ROM (Read-Only Memory) or other type of static storage device that can store static information and instructions, a RAM (Random Access Memory) or other type of dynamic storage device that can store information and instructions, an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact disk Read-Only Memory) or other optical disk storage, optical disk storage (including Compact disk, laser disk, optical disk, digital versatile disk, blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
The Processor 301 in the electronic device of the present Application may be a CPU (Central Processing Unit), a general-purpose Processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array), or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 301 may also be a combination of computing functions, e.g., comprising one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
According to the code electronic equipment, the relation between the use cases and the codes can be used as the characteristic vector through the use case obtaining method for executing the codes, the use cases are distributed to different use case sets through the clustering algorithm, only part of the use cases are recommended when the test use cases are recommended, and all the use cases are not required to be executed, so that the coverage rate of differential codes is guaranteed to be more than 80%, the use case density is reduced, and the test efficiency is improved.
The embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements a use case obtaining method provided in the embodiment of the present application.
The computer-readable medium provided herein includes, but is not limited to, any type of disk including floppy disks, hard disks, optical disks, CD-ROMs, and magneto-optical disks, ROMs, RAMs, EPROMs (Erasable Programmable Read-Only memories), EEPROMs, flash Memory, magnetic or optical cards. That is, a readable medium includes any medium that stores or transmits information in a form readable by a device (e.g., a computer).
According to the code computer-readable storage medium, the use case and code relation can be used as the feature vector through the use case obtaining method for executing the code, the use cases are distributed to different use case sets through the clustering algorithm, when the test use cases are recommended, only part of the use cases are recommended, and all the use cases are not required to be executed, so that the coverage rate of differential codes is guaranteed to be more than 80%, the use case density is reduced, and the test efficiency is improved.
Those of skill in the art will appreciate that the various operations, methods, steps in the processes, acts, or solutions discussed in this application can be interchanged, modified, combined, or eliminated. Further, other steps, measures, or schemes in various operations, methods, or flows that have been discussed in this application can be alternated, altered, rearranged, broken down, combined, or deleted. Further, steps, measures, schemes in the prior art having various operations, methods, procedures provided in the present application may also be alternated, modified, rearranged, decomposed, combined, or deleted.
The terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present application, "a plurality" means two or more unless otherwise specified.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a partial embodiment of the present application, and it should be noted that, for those skilled in the art, several modifications and decorations can be made without departing from the principle of the present application, and these modifications and decorations should also be regarded as the protection scope of the present application.
Claims (10)
1. A method for acquiring a use case of a code is characterized by comprising the following steps:
establishing a matching relation between the sample use case and the sample code;
carrying out unsupervised learning training on the matching relation between the sample use case and the sample code to construct a clustering model of the use case and the code;
acquiring a code change differentiation file;
screening out test cases according to the code change differentiation file;
and taking the test case as the input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate.
2. The use case acquisition method according to claim 1, wherein the establishing of the matching relationship between the sample use case and the sample code comprises:
inserting a monitoring packet into a project, monitoring code change in the project according to the monitoring packet and determining the sample code when the sample use case is triggered and executed by a target user;
acquiring the execution state of the sample use case;
and when the execution of the sample use case is judged to be finished according to the execution state of the sample use case, establishing the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs, and taking the relation between the ID of the sample use case and the ID of the project, the line number of the sample code and the ID of the class to which the sample code belongs as the matching relation between the sample use case and the sample code.
3. The use case acquisition method according to claim 2, wherein before inserting a listening packet in a project to listen to a code change in the project according to the listening packet and determining the sample code when the sample use case is triggered to be executed by a user, the method further comprises:
acquiring IP addresses of a plurality of preset users, and taking the IP address of each preset user as a unique identifier of each preset user;
and when the sample use case is triggered and executed by a plurality of preset users, determining the target user according to the unique identifier of each preset user.
4. The use case acquisition method according to claim 2, wherein the unsupervised learning training of the matching relationship between the sample use case and the sample code to construct a cluster model of use cases and codes comprises:
converting the relation between the sample use case ID and the engineering ID, the line number of the sample code and the ID of the class to which the sample code belongs into a relation matrix;
training a plurality of preset clustering models by using the relation matrix as training data, and determining an optimal clustering model from the plurality of preset clustering models according to the training results of the plurality of preset clustering models;
and taking the optimal clustering model as the clustering model of the use case and the code.
5. The use case obtaining method according to claim 1, wherein the screening out the test use cases according to the code change differentiation file includes:
acquiring the line number information of the changed codes in the code change differentiation file;
and screening out the use cases related to the change from a plurality of sample use cases according to the line number information of the code with the change and the matching relation between the sample use cases and the sample codes, and using the use cases as the test use cases.
6. The use case acquisition method of claim 5, wherein prior to the acquiring the code change differencing file, the method further comprises:
when a code branch is created, the original version of the JAVA file is reserved;
and when the JAVA file of the new version is submitted, comparing the JAVA file of the original version with the JAVA file of the new version, and generating the code change differential file.
7. The use case obtaining method according to claim 1, wherein the using the test use case as an input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test use case and outputs a use case set with the highest coverage rate, includes:
taking the test case as the input of the clustering model of the use case and the code, so that the clustering model of the use case and the code outputs the coverage rate of the test case;
determining a case set with the highest coverage rate according to the coverage rate of the test case;
and after the case set with the highest coverage rate is determined according to the coverage rate of the test cases, the method further comprises the following steps:
executing each use case in the use case set with the highest coverage rate on the test codes, and counting the use case density of the test codes and the coverage rate of each use case in the use case set with the highest coverage rate so as to enable testers to evaluate.
8. A use case acquiring apparatus of a code, the use case acquiring apparatus comprising:
the establishing module is used for establishing a matching relation between the sample use case and the sample code;
the construction module is used for carrying out unsupervised learning training on the matching relation between the sample use case and the sample codes so as to construct a clustering model of the use case and the codes;
the first acquisition module is used for acquiring a code change differentiation file;
the screening module is used for screening out test cases according to the code change differentiation files;
and the output module is used for taking the test case as the input of the clustering model of the use cases and the codes, so that the clustering model of the use cases and the codes classifies the test case and outputs a use case set with the highest coverage rate.
9. An electronic device, comprising:
a processor; and
a memory configured to store machine-readable instructions that, when executed by the processor, cause the processor to perform a use case acquisition method of the code of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the use case acquisition method of the code of any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010785347.7A CN112052160A (en) | 2020-08-06 | 2020-08-06 | Code case obtaining method and device, electronic equipment and medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010785347.7A CN112052160A (en) | 2020-08-06 | 2020-08-06 | Code case obtaining method and device, electronic equipment and medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN112052160A true CN112052160A (en) | 2020-12-08 |
Family
ID=73602232
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010785347.7A Pending CN112052160A (en) | 2020-08-06 | 2020-08-06 | Code case obtaining method and device, electronic equipment and medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112052160A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113282893A (en) * | 2021-04-27 | 2021-08-20 | 南方电网数字电网研究院有限公司 | Source code reinforcing method and device, computer equipment and storage medium |
CN113688036A (en) * | 2021-08-13 | 2021-11-23 | 北京灵汐科技有限公司 | Data processing method, device, equipment and storage medium |
CN117556263A (en) * | 2024-01-10 | 2024-02-13 | 阿里云计算有限公司 | Sample construction method, code generation method, electronic device, and storage medium |
CN117971684A (en) * | 2024-02-07 | 2024-05-03 | 浙江大学 | Whole machine regression test case recommendation method capable of changing semantic perception |
WO2024103370A1 (en) * | 2022-11-18 | 2024-05-23 | Telefonaktiebolaget Lm Ericsson (Publ) | Code change based test case (tc) selection |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100058295A1 (en) * | 2008-09-02 | 2010-03-04 | International Business Machines Corporation | Dynamic Test Coverage |
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 |
-
2020
- 2020-08-06 CN CN202010785347.7A patent/CN112052160A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100058295A1 (en) * | 2008-09-02 | 2010-03-04 | International Business Machines Corporation | Dynamic Test Coverage |
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 |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113282893A (en) * | 2021-04-27 | 2021-08-20 | 南方电网数字电网研究院有限公司 | Source code reinforcing method and device, computer equipment and storage medium |
CN113688036A (en) * | 2021-08-13 | 2021-11-23 | 北京灵汐科技有限公司 | Data processing method, device, equipment and storage medium |
WO2024103370A1 (en) * | 2022-11-18 | 2024-05-23 | Telefonaktiebolaget Lm Ericsson (Publ) | Code change based test case (tc) selection |
CN117556263A (en) * | 2024-01-10 | 2024-02-13 | 阿里云计算有限公司 | Sample construction method, code generation method, electronic device, and storage medium |
CN117556263B (en) * | 2024-01-10 | 2024-04-23 | 阿里云计算有限公司 | Sample construction method, code generation method, electronic device, and storage medium |
CN117971684A (en) * | 2024-02-07 | 2024-05-03 | 浙江大学 | Whole machine regression test case recommendation method capable of changing semantic perception |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112052160A (en) | Code case obtaining method and device, electronic equipment and medium | |
CN108090567B (en) | Fault diagnosis method and device for power communication system | |
CN110413506A (en) | Test case recommended method, device, equipment and storage medium | |
US20170140273A1 (en) | System and method for automatic selection of deep learning architecture | |
CN110633222A (en) | Method and device for determining regression test case | |
CN111831564A (en) | Regression testing method and device and computing equipment | |
CN109669436B (en) | Test case generation method and device based on functional requirements of electric automobile | |
CN111400695B (en) | Equipment fingerprint generation method, device, equipment and medium | |
CN108415668B (en) | Chip excitation method, device, system, computer equipment and storage medium | |
CN113052577A (en) | Method and system for estimating category of virtual address of block chain digital currency | |
CN110580214B (en) | Evaluation method and device for application program test, storage medium and terminal equipment | |
CN114185766A (en) | Code detection method and device, electronic equipment and storage medium | |
CN116228045B (en) | Product reliability weak link assessment method and device based on performance degradation | |
CN114880637B (en) | Account risk verification method and device, computer equipment and storage medium | |
CN106936561B (en) | Side channel attack protection capability assessment method and system | |
CN107402883B (en) | A kind of data test treating method and apparatus | |
Akkouche et al. | Analog/RF test ordering in the early stages of production testing | |
CN116108449A (en) | Software fuzzy test method, device, equipment and storage medium | |
CN115248783A (en) | Software testing method, system, readable storage medium and computer equipment | |
CN114943083A (en) | Intelligent terminal vulnerability code sample mining method and device and electronic equipment | |
CN110177006B (en) | Node testing method and device based on interface prediction model | |
CN113656354A (en) | Log classification method, system, computer device and readable storage medium | |
CN112631905A (en) | Execution process data management method and device, computer equipment and storage medium | |
CN112506765A (en) | Software testing method, device, equipment and storage medium | |
CN117320057A (en) | Context logic judgment method and system for high-capacity communication signaling test |
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 |