CN112559365A - Test case screening method and device, computer equipment and storage medium - Google Patents

Test case screening method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN112559365A
CN112559365A CN202011537961.8A CN202011537961A CN112559365A CN 112559365 A CN112559365 A CN 112559365A CN 202011537961 A CN202011537961 A CN 202011537961A CN 112559365 A CN112559365 A CN 112559365A
Authority
CN
China
Prior art keywords
test case
test
code coverage
test cases
coverage data
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
Application number
CN202011537961.8A
Other languages
Chinese (zh)
Inventor
曾旻
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Pinshun Information Technology Co ltd
Original Assignee
Shanghai Pinshun Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Pinshun Information Technology Co ltd filed Critical Shanghai Pinshun Information Technology Co ltd
Priority to CN202011537961.8A priority Critical patent/CN112559365A/en
Publication of CN112559365A publication Critical patent/CN112559365A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a test case screening method, a test case screening device, computer equipment and a storage medium, and belongs to the technical field of software testing. The method comprises the following steps: acquiring a plurality of test cases of a target service; executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case; acquiring similarity between code coverage data corresponding to each test case, and determining the code coverage data which are mutually similar according to each similarity; the method and the device have the advantages that the test cases corresponding to the code coverage data which are similar to each other are screened, and the test cases corresponding to the code coverage data which are similar to each other are screened, so that the screened test cases are high in pertinence, the number of the test cases of the software can be effectively reduced, the execution of a large number of redundant test cases is avoided, the test time is saved, and the test efficiency of a software system is improved.

Description

Test case screening method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of software testing technologies, and in particular, to a method and an apparatus for screening test cases, a computer device, and a storage medium.
Background
With the development of software testing technology, in order to measure a specific target in the testing process, a test case is written for the specific target to perform automated testing.
In the prior art, because a software system may be subjected to multiple revisions or upgrades, all test cases are used for testing the software system for multiple times after each revision or upgrade, the test cases are not screened in the method, and the pertinence of the test cases is not strong, so that repeated redundant work may be performed in the testing process, and the testing efficiency is not high.
Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for screening test cases, a computer device, and a storage medium, so as to solve the problems in the prior art that the number of test cases is large, which results in repeated and redundant test operations, and the test efficiency is low.
In a first aspect, a test case screening method is provided, where the method includes:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to the test cases, and determining the code coverage data which are similar to each other according to the similarity;
and screening the test cases corresponding to the code coverage data which are similar to each other.
Further, the obtaining of the plurality of test cases of the target service includes:
acquiring interface parameter information of the target service, wherein the interface parameter information comprises respective parameter actual values of all interface parameters obtained by analyzing actual flow data of the target service;
performing machine learning on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter dereferencing rules of the interface parameters;
and assigning values to the interface parameters according to the parameter value-taking rules of the interface parameters to generate a plurality of test cases of the target service.
Further, before assigning values to the interface parameters according to the parameter value-taking rules of the interface parameters and generating a plurality of test cases of the target service, the method further includes:
judging whether the interface parameters have preset parameter value-taking rules or not aiming at each interface parameter, if so, pushing the preset parameter value-taking rules of the interface parameters and the parameter value-taking rules obtained through machine learning to a user side for the user to select;
and receiving selection information of the user terminal aiming at the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.
Further, the assigning each interface parameter according to the parameter value rule of each interface parameter to generate a plurality of test cases of the target service includes:
and assigning values to the interface parameters by combining an equivalence class division method or/and a boundary value method according to the parameter value-taking rules of the interface parameters to generate a plurality of test cases of the target service.
Further, the obtaining of the similarity between the code coverage data corresponding to each test case and determining the code coverage data similar to each other according to each similarity includes:
binding each test case and the program code segment covered by each test case according to the code coverage data corresponding to each test case;
for each target test case in all the test cases, calculating the same degree between the program code segments bound by the target test case and the program code segments bound by other test cases in all the test cases, and acquiring the similarity between the code coverage data corresponding to the target test case and the code coverage data corresponding to other test cases according to the calculation result;
and judging whether the similarity meets a preset similarity condition, and if so, determining that the code coverage data corresponding to the target test case is similar to the code coverage data corresponding to the other test cases.
Further, the screening the test cases corresponding to the code coverage data similar to each other includes:
classifying the test cases respectively corresponding to the code coverage data which are mutually similar into the same test case set;
determining code coverage rate corresponding to each test case in each test case set;
and screening each test case subset according to the code coverage rate corresponding to each test case in each test case set.
Further, the screening each test case subset according to the code coverage rate corresponding to each test case in each test case set includes:
sequencing each test case in the test case set from high to low according to the code coverage rate aiming at each test case subset to obtain a sequencing result; and
and screening the test cases with the top N bits in the sequencing result to serve as the optimal test case, wherein N is more than or equal to 1.
In a second aspect, a test case screening apparatus is provided, where the apparatus includes:
the case acquisition module is used for acquiring a plurality of test cases of the target service;
the case execution module is used for executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
the similarity determination module is used for acquiring the similarity between the code coverage data corresponding to each test case and determining the code coverage data which are mutually similar according to each similarity;
and the case screening module is used for screening the test cases corresponding to the code coverage data which are similar to each other.
Further, the use case obtaining module includes:
a parameter obtaining unit, configured to obtain interface parameter information of the target service, where the interface parameter information includes respective actual parameter values of all interface parameters obtained by analyzing actual traffic data of the target service;
the machine learning unit is used for performing machine learning on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter value rules of the interface parameters;
and the case generating unit is used for assigning values to the interface parameters according to the parameter value rules of the interface parameters to generate a plurality of test cases of the target service.
Further, the apparatus further comprises a parameter rule processing module, wherein the parameter rule processing module is configured to:
judging whether the interface parameters have preset parameter value-taking rules or not aiming at each interface parameter, if so, pushing the preset parameter value-taking rules of the interface parameters and the parameter value-taking rules obtained through machine learning to a user side for the user to select;
and receiving selection information of the user terminal aiming at the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.
Further, the use case generating unit is specifically configured to:
and assigning values to the interface parameters by combining an equivalence class division method or/and a boundary value method according to the parameter value-taking rules of the interface parameters to generate a plurality of test cases of the target service.
Further, the similarity determination module is specifically configured to:
binding each test case and the program code segment covered by each test case according to the code coverage data corresponding to each test case;
for each target test case in all the test cases, calculating the same degree between the program code segments bound by the target test case and the program code segments bound by other test cases in all the test cases, and acquiring the similarity between the code coverage data corresponding to the target test case and the code coverage data corresponding to other test cases according to the calculation result;
and judging whether the similarity meets a preset similarity condition, and if so, determining that the code coverage data corresponding to the target test case is similar to the code coverage data corresponding to the other test cases.
Further, the use case screening module includes:
the case classification unit is used for classifying the test cases corresponding to the code coverage data which are mutually similar into the same test case set;
a coverage rate determining unit, configured to determine a code coverage rate corresponding to each test case in each test case set;
and the use case screening unit is used for screening each test case subset according to the code coverage rate corresponding to each test case in each test case set.
Further, the use case screening unit is specifically configured to:
sequencing each test case in the test case set from high to low according to the code coverage rate aiming at each test case subset to obtain a sequencing result; and
and screening the test cases with the top N bits in the sequencing result to serve as the optimal test case, wherein N is more than or equal to 1.
In a third aspect, a computer device is provided, which includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the computer program, the following operation steps are implemented:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to the test cases, and determining the code coverage data which are similar to each other according to the similarity;
and screening the test cases corresponding to the code coverage data which are similar to each other.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the operational steps of:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to the test cases, and determining the code coverage data which are similar to each other according to the similarity;
and screening the test cases corresponding to the code coverage data which are similar to each other.
The test case screening method, the test case screening device, the computer equipment and the storage medium provided by the invention are used for acquiring a plurality of test cases of target service; executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case; acquiring similarity between code coverage data corresponding to each test case, and determining the code coverage data which are mutually similar according to each similarity; the test cases corresponding to the code coverage data which are similar to each other are screened, and the test cases corresponding to the code coverage data which are similar to each other are screened, so that the screened test cases are not only strong in pertinence, but also the number of the test cases of the software can be effectively reduced, the execution of a large number of redundant test cases is avoided, the test time is saved, and the test efficiency of the software system is improved.
Drawings
FIG. 1 is a schematic flow chart illustrating a test case screening method according to an embodiment;
FIG. 2 is a schematic flow chart of step 101 of the method shown in FIG. 1;
FIG. 3 is a schematic flow chart of step 103 of the method shown in FIG. 1;
FIG. 4 is a schematic flow chart of step 104 of the method of FIG. 1;
FIG. 5 is a block diagram of a test case screening apparatus according to an embodiment;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It is to be understood that, unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, what is meant is "including, but not limited to".
Furthermore, in the description of the present invention, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In addition, in the description of the present invention, "a plurality" means two or more unless otherwise specified.
As described in the foregoing background technology, in the prior art, because a software system may undergo multiple modifications or upgrades, after each modification or upgrade, all test cases are used to perform multiple tests on the software system, the test cases are not screened in this way, and the test cases are not targeted strongly, which may cause repeated redundant work in the test process, and thus the test efficiency is not high. Therefore, the method for screening the test cases is provided, and each code coverage data and the test cases corresponding to the similar code coverage data are screened, so that the screened test cases are high in pertinence, execution of a large number of redundant test cases can be avoided, test time is saved, and test efficiency of a software system is improved.
In one embodiment, a test case screening method is provided, where the method may be applied to a computer device, and the computer device may be implemented by an independent server or a server cluster formed by multiple servers, as shown in fig. 1, and the method may include the following steps:
101, obtaining a plurality of test cases of a target service.
The target service may be any type of service, the target service generally has one or more interfaces, and the use case data refers to test data used for performing interface testing in the test case, and may include interface request data and expected interface response data.
Specifically, the process of obtaining the test case is not limited by the present invention.
And 102, executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case.
The service program code corresponding to the target service is stored in the preset service code, the service program code comprises a plurality of program code segments, and different program code segments have different program functions.
Specifically, a plurality of test cases are executed in a test environment through a test case execution engine, a coverage report of service codes of a target service is obtained, code coverage data is extracted from the coverage report, and the code coverage data comprises: the test coverage to code information, the non-test coverage to code information and the code coverage rate, wherein the code information can be code characteristics specifically, and the code characteristics include but are not limited to: the code coverage rate can be obtained by calculation according to the code information covered by the test and the code information not covered by the test, for example, the proportion of the line number of the code covered by a certain test case to the total line number of the program code of the target service is calculated, so as to obtain the code coverage rate of the test case. Here, the test environment refers to an environment simulated to be close to a real production environment, and may be a static test environment, for example.
And 103, acquiring similarity between the code coverage data corresponding to each test case, and determining the code coverage data which are similar to each other according to each similarity.
Specifically, the similarity between the code coverage data corresponding to each test case can be obtained by analyzing the test coverage to code information, the untested coverage to code information and the code coverage rate included in the code coverage data, whether at least two code coverage data with the similarity meeting the preset similar condition exist is judged according to the similarity between the code coverage data corresponding to each test case and the preset similar condition, and if so, the at least two code coverage data are determined to be mutually similar code coverage data.
The preset similarity condition may be set according to actual needs, for example, when the similarity between two code coverage data exceeds a preset similarity value, it is determined that the two code coverage data are similar to each other.
And 104, screening the test cases corresponding to the code coverage data which are similar to each other.
Specifically, test cases meeting preset conditions are screened out from test case screening corresponding to code coverage data similar to each other and serve as optimal test cases.
According to the case screening method provided by the embodiment of the invention, the similarity between the code coverage data corresponding to each test case is obtained, the code coverage data which are mutually similar are determined according to each similarity, and the test cases corresponding to the code coverage data which are mutually similar are screened, so that the screened test cases are not only strong in pertinence, but also the number of the test cases of the software can be effectively reduced, the execution of a large number of redundant test cases is avoided, the test time is saved, and the test efficiency of a software system is improved.
In an embodiment, as shown in fig. 2, the implementation process of obtaining multiple test cases of the target service in step 101 may include the steps of:
1011, obtaining interface parameter information of the target service, wherein the interface parameter information includes respective parameter actual values of all interface parameters obtained by analyzing actual flow data of the target service.
The actual flow data of the target service comprises actual flow data of each interface of the target service, and the actual flow data comprises a request message and a response message.
Specifically, the actual flow data of the target service in the production environment may be prerecorded and stored in the database, when the server receives a test case generation instruction, the selected target service is determined according to the test case generation instruction, the actual flow data of the target service is pulled from the database, after desensitization processing is performed on the actual flow data, the actual flow data is analyzed according to the interface parameter access structure corresponding to each interface of the target service, and information such as an interface name, an interface parameter field name, and a field attribute corresponding to an interface parameter is obtained, and in addition, other information of the interface parameter, such as an interface uniform resource locator, an interface method type, an interface parameter access type, and an interface parameter access type, can be obtained through analysis.
The field types of the interface parameters comprise parameter input fields and parameter output fields, and each parameter field is provided with a corresponding parameter field name and field attribute information and a field type corresponding to the parameter field name. The database of the server stores preset parameter value-taking rules corresponding to each parameter field in advance, wherein the parameter value-taking rules comprise parameter value-taking ranges and/or regular expressions, and the parameter value-taking ranges comprise safety values, upper boundary values, lower boundary values, null values, parameter values of non-local field types and the like.
And 1012, performing machine learning on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter value rules of the interface parameters.
The feature information of the target service includes a service name, a domain name, a service function point of the target service, and the like.
Specifically, machine learning is performed on the parameter field names of the interface parameters, the actual values of the parameters corresponding to the parameter field names, the service names and domain names of the target services, the service function points of the target services, and the like, and the parameter value-taking rules of the interface parameters are analyzed, that is, the rules of the parameter value-taking rules are found out.
The machine learning may employ, for example, a clustering algorithm, a neural network, bayes, regression analysis, or other algorithms to analyze the parameter dereferencing rules for each interface parameter, and generate rule results (e.g., clustering or classification results) of the parameter dereferencing rules.
It should be understood that the embodiments of the present invention do not limit the specific machine learning process.
And 1013, assigning the interface parameters according to the parameter value-taking rules of the interface parameters to generate a plurality of test cases of the target service.
The implementation process of step 103 may include:
and assigning values to the interface parameters according to the parameter value-taking rules of the interface parameters and by combining an equivalence class division method or/and a boundary value method to generate a plurality of test cases of the target service.
The equivalence class division method divides the test data into effective equivalence class data and ineffective equivalence class data, the effective equivalence class data are reasonable and meaningful data sets which accord with a limiting rule, and the ineffective equivalence class data are unreasonable and meaningless data sets; boundary value analysis methods test the boundary of an input or output by selecting the upper, inner and outer points of a given data field.
In addition, other test case design methods, such as a scenario method, an orthogonal table, and the like, may also be considered. The embodiment does not limit the specific test case generation process.
In this embodiment, the interface parameter information of the target service includes respective parameter actual values of the plurality of interface parameters obtained by analyzing actual flow data of the target service, so that machine learning is performed on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter value rules of the interface parameters, and value assignment is performed on the interface parameters according to the parameter value rules of the interface parameters to generate a plurality of test cases of the target service, so that the test cases can be closer to actual flow in a production environment, and accuracy of the test cases can be effectively improved. In addition, the method can also be used for quickly and efficiently generating the test case of the target service, so that the generation efficiency of the test case is improved, and the workload of the testers for compiling the automatic test case is reduced.
In one embodiment, before the step 1013 is performed, the method further comprises:
judging whether the interface parameters have preset parameter value rules or not aiming at each interface parameter, if so, pushing the preset parameter value rules of the interface parameters and the parameter value rules obtained through machine learning to a user end for the user to select; and
and receiving selection information of the user terminal aiming at the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.
The database of the server stores preset parameter value rules corresponding to the parameter fields of the interface parameters in advance. The visual configuration interface can be provided for the user side to receive a parameter value-taking rule for configuring the interface parameter through the visual configuration interface by the user, and the interface parameter field and the corresponding configured parameter value-taking rule key value pair form are stored in the database.
In this embodiment, the preset parameter value rule of the interface parameter and the parameter value rule obtained through machine learning are pushed to the user side for selection by the user, the selection information of the user side for the parameter value rule of the interface parameter is received, and the parameter value rule indicated by the selection information is determined as the parameter value rule of the interface parameter, so that the parameter value rule of the interface parameter is more accurate, and the accuracy of generating a subsequent test case is improved.
In one embodiment, the preset parameter value rule of the interface parameter and the parameter value rule obtained through machine learning are pushed to the user side for selection by the user, and the process may include:
similarity calculation is carried out on a preset parameter value rule of the interface parameter and the parameter value rule obtained through machine learning, a target interface parameter with a similarity result exceeding a preset similarity threshold value is determined, and the preset parameter value rule of the target interface parameter and the parameter value rule obtained through machine learning are pushed to a user side.
The preset similarity threshold value can be preset according to actual needs. The similarity calculation method may refer to the prior art, and for example, a euclidean distance, a hamming distance, a cosine distance, etc. are used.
In this embodiment, the parameter value rule preset by the target interface parameter with the similarity result exceeding the preset similarity threshold and the parameter value rule obtained through machine learning are pushed to the user side, and the parameter value rule indicated by the received selection information is determined as the parameter value rule of the interface parameter, so that the workload of the user in performing selection operation on the parameter value rule can be reduced, and the generation efficiency of subsequent test cases is further improved.
In an embodiment, as shown in fig. 3, the obtaining, in the step 103, a similarity between code coverage data corresponding to each test case, and determining, according to each similarity, code coverage data that are similar to each other, may include the steps of:
1031, binding each test case and the program code segment covered by each test case according to the code coverage data corresponding to each test case.
Specifically, the program code segments covered by the test cases can be determined according to the test coverage code information in the code coverage data corresponding to the test cases, and the binding relationship between the test cases and the program code segments covered by the test cases is established. And establishing a binding relation of 'test case-code segment' for indicating which code lines each test case covers, namely each test case is bound with the code segment covered by the test case.
It is understood that a test case may bind one or more sections of program code, a section of program code containing at least one line of code.
1032, for each target test case in all the test cases, calculating the same degree between the program code segments bound by the target test case and the program code segments bound by other test cases in all the test cases, and according to the calculation result, acquiring the similarity between the code coverage data corresponding to the target test case and the code coverage data corresponding to other test cases.
The target test case may be a test case randomly selected from all test cases, and the other test cases are test cases other than the target test case in all test cases.
For convenience of description, the program code segment bound to the target test case is taken as a first program code line, and the program code segments bound to other test cases are taken as a second program code segment.
Specifically, the implementation process of step 1032 may include:
and aiming at the target test case, traversing each other test case except the target test case in all the test cases, performing feature matching on respective code characteristics of the first program code segment bound by the target test case and the second program code segment bound by the traversed other test cases when each other test case is traversed, calculating the same degree between the first program code segment bound by the target test case and the second program code segment bound by the other test cases, and determining the same degree as the similarity between the code coverage data corresponding to the test case and the code coverage data corresponding to the other test cases. The embodiment does not limit the specific similarity obtaining process.
It can be understood that, when the degree of identity between the respective program code segments bound by two test cases is higher, the code coverage data corresponding to the two test cases is more similar. The number of the program code segments bound by the two test cases may be one or more.
1033, judging whether the similarity meets a preset similarity condition, and if so, determining that the code coverage data corresponding to the target test case is similar to the code coverage data corresponding to other test cases.
The preset similar condition may be set as: when the similarity between any two code coverage data exceeds a preset threshold, the two code coverage data are similar code coverage data, and it is understood that the preset threshold may be set according to actual situations, for example, set to 80%.
In an embodiment, as shown in fig. 4, the screening 104 of the test cases corresponding to the code coverage data similar to each other may include:
1041, classifying the test cases corresponding to the code coverage data similar to each other into the same test case set.
The test cases corresponding to the code coverage data which are similar to each other are classified into the same test subset, and a plurality of test case subsets are obtained.
Exemplarily, if the code coverage data corresponding to the test case a and the test case b are similar to each other, the test case a and the test case b are categorized into the same test case set.
It is understood that the code coverage rates corresponding to the test cases in the same test case set are similar to each other, but not similar to the code coverage rates corresponding to the test cases in other test case sets.
1042, determining the code coverage rate corresponding to each test case in each test case set.
1043, screening each subset of test cases according to the code coverage rate corresponding to each test case in each test case set.
Specifically, screening each test case subset according to the code coverage rate corresponding to each test case in each test case set, where the process may include:
and sequencing each test case in the test case set according to the sequence of the code coverage rate from high to low aiming at each test case subset to obtain a sequencing result, and screening the test cases with the top N bits in the sequencing result as the optimal test case, wherein N is more than or equal to 1.
In the embodiment, the test cases corresponding to the code coverage data which are similar to each other are classified into the same test subset to obtain a plurality of test case subsets, and each test case subset is screened according to the code coverage rate corresponding to each test case in each test case subset, so that the screened test cases are strong in pertinence, the number of the test cases of the software can be effectively reduced, the execution of a large number of redundant test cases is avoided, and the screened test cases are more comprehensive, therefore, even a program code segment covered by a few test cases can be tested, and the test effectiveness and the test comprehensiveness can be improved.
In an embodiment, there is provided a test case screening apparatus, as shown in fig. 5, the apparatus may include:
a use case obtaining module 51, configured to obtain multiple test use cases of the target service;
the case execution module 52 is configured to execute a plurality of test cases through the test case execution engine to obtain code coverage data corresponding to each test case;
the similarity determining module 53 is configured to obtain similarities between the code coverage data corresponding to each test case, and determine, according to the similarities, the code coverage data that are mutually similar;
the use case screening module 54 is configured to screen test cases corresponding to code coverage data that are similar to each other.
In one embodiment, the use case obtaining module 51 includes:
the device comprises a parameter acquisition unit, a parameter processing unit and a parameter processing unit, wherein the parameter acquisition unit is used for acquiring interface parameter information of a target service, and the interface parameter information comprises respective parameter actual values of all interface parameters obtained by analyzing actual flow data of the target service;
the machine learning unit is used for performing machine learning on all interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter value rules of the interface parameters;
and the case generating unit is used for assigning values to the interface parameters according to the parameter value rules of the interface parameters to generate a plurality of test cases of the target service.
In one embodiment, the apparatus further comprises a parameter rule processing module to:
judging whether the interface parameters have preset parameter value rules or not aiming at each interface parameter, if so, pushing the preset parameter value rules of the interface parameters and the parameter value rules obtained through machine learning to a user end for the user to select;
and receiving selection information of the user terminal aiming at the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.
In one embodiment, the use case generating unit is specifically configured to:
and assigning values to the interface parameters according to the parameter value-taking rules of the interface parameters and by combining an equivalence class division method or/and a boundary value method to generate a plurality of test cases of the target service.
In one embodiment, the similarity determination module 53 is specifically configured to:
binding each test case and the program code segment covered by each test case according to the code coverage data corresponding to each test case;
calculating the same degree between the program code segments bound by the target test case and the program code segments bound by other test cases in all the test cases aiming at each target test case in all the test cases, and acquiring the similarity between the code coverage data corresponding to the target test case and the code coverage data corresponding to other test cases according to the calculation result;
and judging whether the similarity meets a preset similarity condition, if so, determining that the code coverage data corresponding to the target test case is similar to the code coverage data corresponding to other test cases.
In one embodiment, use case screening module 54 includes:
the case classification unit is used for classifying the test cases corresponding to the code coverage data which are mutually similar into the same test case set;
the coverage rate determining unit is used for determining the code coverage rate corresponding to each test case in each test case set;
and the case screening unit is used for screening each test case subset according to the code coverage rate corresponding to each test case in each test case set.
In one embodiment, the use case filtering unit is specifically configured to:
sequencing each test case in the test case set from high to low according to the code coverage rate aiming at each test case subset to obtain a sequencing result; and
and screening the test cases with the top N bits in the sequencing result to serve as the optimal test case, wherein N is more than or equal to 1.
For specific limitations of the test case screening apparatus, reference may be made to the above limitations of the test case screening method, which is not described herein again. All or part of each module in the test case screening device can be realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The server comprises a processor, a memory and a network interface which are connected through a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The nonvolatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used to communicate with other devices via a network connection. The computer program is executed by a processor to implement a test case screening method.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to each test case, and determining the code coverage data which are mutually similar according to each similarity;
and screening test cases corresponding to the code coverage data which are similar to each other.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to each test case, and determining the code coverage data which are mutually similar according to each similarity;
and screening test cases corresponding to the code coverage data which are similar to each other.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A test case screening method is characterized by comprising the following steps:
acquiring a plurality of test cases of a target service;
executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
acquiring similarity between code coverage data corresponding to the test cases, and determining the code coverage data which are similar to each other according to the similarity;
and screening the test cases corresponding to the code coverage data which are similar to each other.
2. The method of claim 1, wherein obtaining the plurality of test cases for the target service comprises:
acquiring interface parameter information of the target service, wherein the interface parameter information comprises respective parameter actual values of all interface parameters obtained by analyzing actual flow data of the target service;
performing machine learning on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter dereferencing rules of the interface parameters;
and assigning values to the interface parameters according to the parameter value-taking rules of the interface parameters to generate a plurality of test cases of the target service.
3. The method according to claim 2, wherein before assigning values to the interface parameters according to the parameter value rules of the interface parameters and generating the plurality of test cases of the target service, the method further comprises:
judging whether the interface parameters have preset parameter value-taking rules or not aiming at each interface parameter, if so, pushing the preset parameter value-taking rules of the interface parameters and the parameter value-taking rules obtained through machine learning to a user side for the user to select;
and receiving selection information of the user terminal aiming at the parameter value rule of the interface parameter, and determining the parameter value rule indicated by the selection information as the parameter value rule of the interface parameter.
4. The method according to any one of claims 1 to 3, wherein the obtaining of the similarity between the code coverage data corresponding to each of the test cases and determining the code coverage data similar to each other according to each of the similarities comprises:
binding each test case and the program code segment covered by each test case according to the code coverage data corresponding to each test case;
for each target test case in all the test cases, calculating the same degree between the program code segments bound by the target test case and the program code segments bound by other test cases in all the test cases, and acquiring the similarity between the code coverage data corresponding to the target test case and the code coverage data corresponding to other test cases according to the calculation result;
and judging whether the similarity meets a preset similarity condition, and if so, determining that the code coverage data corresponding to the target test case is similar to the code coverage data corresponding to the other test cases.
5. The method according to any one of claims 1 to 3, wherein the screening of the test cases corresponding to the code coverage data similar to each other includes:
classifying the test cases respectively corresponding to the code coverage data which are mutually similar into the same test case set;
determining code coverage rate corresponding to each test case in each test case set;
and screening each test case subset according to the code coverage rate corresponding to each test case in each test case set.
6. The method of claim 5, wherein the screening each subset of test cases according to the code coverage rate corresponding to each test case in each test case set comprises:
sequencing each test case in the test case set from high to low according to the code coverage rate aiming at each test case subset to obtain a sequencing result; and
and screening the test cases with the top N bits in the sequencing result to serve as the optimal test case, wherein N is more than or equal to 1.
7. A test case screening apparatus, the apparatus comprising:
the case acquisition module is used for acquiring a plurality of test cases of the target service;
the case execution module is used for executing a plurality of test cases through a test case execution engine to obtain code coverage data corresponding to each test case;
the similarity determination module is used for acquiring the similarity between the code coverage data corresponding to each test case and determining the code coverage data which are mutually similar according to each similarity;
and the case screening module is used for screening the test cases corresponding to the code coverage data which are similar to each other.
8. The apparatus of claim 7, wherein the use case obtaining module comprises:
a parameter obtaining unit, configured to obtain interface parameter information of the target service, where the interface parameter information includes respective actual parameter values of all interface parameters obtained by analyzing actual traffic data of the target service;
the machine learning unit is used for performing machine learning on all the interface parameters according to the parameter actual values of the interface parameters and the characteristic information of the target service to obtain parameter value rules of the interface parameters;
and the case generating unit is used for assigning values to the interface parameters according to the parameter value rules of the interface parameters to generate a plurality of test cases of the target service.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the method of any of claims 1 to 6 are implemented when the computer program is executed by the processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN202011537961.8A 2020-12-23 2020-12-23 Test case screening method and device, computer equipment and storage medium Pending CN112559365A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011537961.8A CN112559365A (en) 2020-12-23 2020-12-23 Test case screening method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011537961.8A CN112559365A (en) 2020-12-23 2020-12-23 Test case screening method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112559365A true CN112559365A (en) 2021-03-26

Family

ID=75030928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011537961.8A Pending CN112559365A (en) 2020-12-23 2020-12-23 Test case screening method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112559365A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190439A (en) * 2021-04-22 2021-07-30 北京百度网讯科技有限公司 Test case execution method and device and electronic equipment
CN113342664A (en) * 2021-06-16 2021-09-03 北京奇艺世纪科技有限公司 Dial testing method and device, storage medium and computer equipment
CN113535563A (en) * 2021-07-19 2021-10-22 上海复深蓝软件股份有限公司 Test case duplication removing method and device, computer equipment and storage medium
CN113672506A (en) * 2021-08-06 2021-11-19 中国科学院软件研究所 Dynamic proportion test case sequencing selection method and system based on machine learning
CN113722234A (en) * 2021-09-14 2021-11-30 京东科技控股股份有限公司 Test case screening method and device, electronic equipment and storage medium
CN114003305A (en) * 2021-10-22 2022-02-01 济南浪潮数据技术有限公司 Device similarity calculation method, computer device, and storage medium
CN114385492A (en) * 2021-12-30 2022-04-22 大连理工大学 Advanced comprehensive tool optimization option defect detection method based on differential test
CN115437965A (en) * 2022-10-27 2022-12-06 南京讯优智超软件科技有限公司 Data processing method suitable for test management platform
CN115543856A (en) * 2022-12-02 2022-12-30 中国汽车技术研究中心有限公司 Method, device and equipment for screening fuzzy test cases of Bluetooth protocol and storage medium
CN118260209A (en) * 2024-05-24 2024-06-28 摩尔线程智能科技(北京)有限责任公司 Code testing method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107515826A (en) * 2017-08-28 2017-12-26 广州阿里巴巴文学信息技术有限公司 Test case accurate recommendation method, device, system, equipment and storage medium
CN108491321A (en) * 2018-03-06 2018-09-04 平安科技(深圳)有限公司 test case range determining method, device and storage medium
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN111858292A (en) * 2019-09-12 2020-10-30 北京嘀嘀无限科技发展有限公司 Screening method, screening system, computer device and storage medium of test case
CN111858288A (en) * 2019-04-25 2020-10-30 深圳兆日科技股份有限公司 Test case optimization method, device and equipment and computer readable storage medium
CN111949549A (en) * 2020-08-31 2020-11-17 携程计算机技术(上海)有限公司 Test request screening method, system, electronic device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107515826A (en) * 2017-08-28 2017-12-26 广州阿里巴巴文学信息技术有限公司 Test case accurate recommendation method, device, system, equipment and storage medium
CN108491321A (en) * 2018-03-06 2018-09-04 平安科技(深圳)有限公司 test case range determining method, device and storage medium
CN111858288A (en) * 2019-04-25 2020-10-30 深圳兆日科技股份有限公司 Test case optimization method, device and equipment and computer readable storage medium
CN110750442A (en) * 2019-09-06 2020-02-04 平安医疗健康管理股份有限公司 Test case generation method, device, equipment and storage medium
CN111858292A (en) * 2019-09-12 2020-10-30 北京嘀嘀无限科技发展有限公司 Screening method, screening system, computer device and storage medium of test case
CN111949549A (en) * 2020-08-31 2020-11-17 携程计算机技术(上海)有限公司 Test request screening method, system, electronic device and storage medium

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113190439A (en) * 2021-04-22 2021-07-30 北京百度网讯科技有限公司 Test case execution method and device and electronic equipment
CN113190439B (en) * 2021-04-22 2024-03-22 北京百度网讯科技有限公司 Execution method and device of test case and electronic equipment
CN113342664B (en) * 2021-06-16 2023-09-01 北京奇艺世纪科技有限公司 Dial testing method, device, storage medium and computer equipment
CN113342664A (en) * 2021-06-16 2021-09-03 北京奇艺世纪科技有限公司 Dial testing method and device, storage medium and computer equipment
CN113535563A (en) * 2021-07-19 2021-10-22 上海复深蓝软件股份有限公司 Test case duplication removing method and device, computer equipment and storage medium
CN113672506A (en) * 2021-08-06 2021-11-19 中国科学院软件研究所 Dynamic proportion test case sequencing selection method and system based on machine learning
CN113722234A (en) * 2021-09-14 2021-11-30 京东科技控股股份有限公司 Test case screening method and device, electronic equipment and storage medium
CN114003305A (en) * 2021-10-22 2022-02-01 济南浪潮数据技术有限公司 Device similarity calculation method, computer device, and storage medium
CN114003305B (en) * 2021-10-22 2024-03-15 济南浪潮数据技术有限公司 Device similarity calculation method, computer device, and storage medium
CN114385492A (en) * 2021-12-30 2022-04-22 大连理工大学 Advanced comprehensive tool optimization option defect detection method based on differential test
CN115437965A (en) * 2022-10-27 2022-12-06 南京讯优智超软件科技有限公司 Data processing method suitable for test management platform
CN115543856B (en) * 2022-12-02 2023-03-24 中国汽车技术研究中心有限公司 Screening method, device, equipment and storage medium for Bluetooth protocol fuzzy test cases
CN115543856A (en) * 2022-12-02 2022-12-30 中国汽车技术研究中心有限公司 Method, device and equipment for screening fuzzy test cases of Bluetooth protocol and storage medium
CN118260209A (en) * 2024-05-24 2024-06-28 摩尔线程智能科技(北京)有限责任公司 Code testing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112559365A (en) Test case screening method and device, computer equipment and storage medium
CN112559364B (en) Test case generation method and device, computer equipment and storage medium
CN110413506B (en) Test case recommendation method, device, equipment and storage medium
CN108427613B (en) Abnormal interface positioning method and device, computer equipment and storage medium
CN108491321B (en) Method and device for determining test case range and storage medium
CN110730107A (en) Test data generation method and device, computer equipment and storage medium
CN109766261B (en) Coverage test method, coverage test device, computer equipment and storage medium
US11809406B2 (en) Event records in a log file
CN111459796B (en) Automated testing method, apparatus, computer device and storage medium
CN112733146B (en) Penetration testing method, device and equipment based on machine learning and storage medium
CN112363937B (en) Differential coverage rate testing method, differential coverage rate testing device, computer equipment and storage medium
JP7404839B2 (en) Identification of software program defect location
CN111290950B (en) Test point obtaining method and device in program test, storage medium and equipment
CN113282513B (en) Interface test case generation method and device, computer equipment and storage medium
CN110362479B (en) System upgrade test method and system
CN113656404A (en) Data verification method and device, computer equipment and storage medium
CN111026647A (en) Code coverage rate obtaining method and device, computer equipment and storage medium
CN114064497A (en) Application program testing method and device, computer equipment and storage medium
CN111984527A (en) Software performance testing method, device, equipment and medium
CN112363936A (en) Method and device for testing differential coverage rate, computer equipment and storage medium
CN111752819A (en) Abnormity monitoring method, device, system, equipment and storage medium
CN117493188A (en) Interface testing method and device, electronic equipment and storage medium
CN112346981A (en) Joint debugging test coverage rate detection method and system
CN112596723A (en) Database script generation method, device, equipment and medium
CN115543816A (en) Software regression test result verification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination