CN112148619A - Test case suite optimization processing method and device, electronic equipment and storage medium - Google Patents

Test case suite optimization processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112148619A
CN112148619A CN202011080381.0A CN202011080381A CN112148619A CN 112148619 A CN112148619 A CN 112148619A CN 202011080381 A CN202011080381 A CN 202011080381A CN 112148619 A CN112148619 A CN 112148619A
Authority
CN
China
Prior art keywords
tested
test case
initial test
file
case set
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
CN202011080381.0A
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.)
Beijing Didi Infinity Technology and Development Co Ltd
Original Assignee
Beijing Didi Infinity Technology and Development 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 Beijing Didi Infinity Technology and Development Co Ltd filed Critical Beijing Didi Infinity Technology and Development Co Ltd
Priority to CN202011080381.0A priority Critical patent/CN112148619A/en
Publication of CN112148619A publication Critical patent/CN112148619A/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

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 provides an optimization processing method and device for a test case suite, electronic equipment and a storage medium, and relates to the technical field of computers. Wherein, the method comprises the following steps: acquiring a file to be tested, wherein the file to be tested comprises at least one sentence to be tested; mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences; determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested and the sentences to be tested which are covered by each initial test case; according to the method and the device for filtering the initial test case set, the initial test case set is filtered according to the coverage rate file, the target test case set is determined, and by applying the method and the device for filtering the initial test case set, redundant initial test cases in the initial test case set can be automatically filtered according to the coverage rate file, so that manual filtering is avoided, and therefore filtering efficiency can be effectively improved.

Description

Test case suite optimization processing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to an optimization processing method and apparatus for a test case set, an electronic device, and a storage medium.
Background
A test case refers to a description of a test task performed on a specific software product, and the content of the test case may include a test target, a test environment, input data, a test procedure, an expected result, a test script, and the like. For example, for a certain test service, test cases may be designed in a combined manner, but the test case set generated by this manner is relatively large, and many of the test case set are repeated invalid test cases, so that the test case set needs to be filtered.
Conventionally, when filtering test cases that are repeatedly invalid in a test case set, filtering is generally performed by manually combing filtering rules or by using a genetic algorithm of parameters.
However, the existing filtering method has the problem of low filtering efficiency because of depending on manual work.
Disclosure of Invention
The application aims to provide the method and the device for optimizing the test case set, the electronic equipment and the storage medium, aiming at the defects in the prior art, the initial test cases with the centralized redundancy can be automatically filtered, the manual filtering is avoided, and the filtering efficiency can be effectively improved.
In order to achieve the above purpose, the technical solutions adopted in the embodiments of the present application are as follows:
in a first aspect, an embodiment of the present application provides an optimization processing method for a test case suite, including:
acquiring a file to be tested, wherein the file to be tested comprises at least one statement to be tested; mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences; determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested covered by each initial test case and the sentences to be tested; and filtering the initial test case set according to the coverage rate file to determine a target test case set.
Optionally, the mapping the to-be-tested statements in the to-be-tested file according to a preset mapping manner to obtain the mapped to-be-tested statements includes:
mapping the file to be tested according to a first preset mapping mode to obtain the mapped file to be tested; and mapping the statements to be tested in the files to be tested according to a second preset mapping mode and the mapped files to be tested to obtain the mapped statements to be tested.
Optionally, the filtering the initial test case set according to the coverage file to determine a target test case set includes:
acquiring coverage rate parameters of any two initial test cases in the initial test case set according to the coverage rate file; and filtering the initial test case set according to the coverage rate parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as the target test case set.
Optionally, the filtering the initial test case set according to coverage parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as the target test case set includes:
and if the coverage rate parameters of any two initial test cases in the initial test case set reach preset conditions, filtering any one of the initial test cases until the coverage rate parameters of any two initial test cases in the initial test case set do not meet the preset conditions, and acquiring the target test case set.
Optionally, the determining that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition includes:
calculating a similarity parameter between coverage rate parameters of any two initial test cases in the initial test case set; and if the similarity parameter meets a preset threshold value, determining that the coverage rate parameters of any two initial test cases in the initial test case set meet a preset condition.
Optionally, the determining that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition includes:
calculating a difference set between coverage rate parameters of any two initial test cases in the initial test case set; and if the difference set is a null set, determining that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition.
Optionally, the determining a coverage rate file according to the initial test case set and the mapped file to be tested includes:
based on the mapped file to be tested, running each initial test case in the initial test case set to obtain a running result; and determining the coverage rate file according to the operation result.
Optionally, the method further comprises:
if it is determined that at least one statement to be tested in the file to be tested is uncovered according to the coverage rate file, adding a new test case, wherein the new test case is used for covering the statement to be tested which is not covered by the initial test case set; and updating the target test case set according to the new test case and the target test case set.
In a second aspect, an embodiment of the present application provides an apparatus for optimizing a test case suite, including: the device comprises an acquisition module, a mapping module, a determination module and a filtering module;
the acquisition module is used for acquiring a file to be tested, wherein the file to be tested comprises at least one sentence to be tested;
the mapping module is used for mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences;
the determining module is used for determining a coverage rate file according to an initial test case set and the mapped file to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the file to be tested and the sentence to be tested which are covered by each initial test case;
and the filtering module is used for filtering the initial test case set according to the coverage rate file and determining a target test case set.
Optionally, the mapping module is specifically configured to map the file to be tested according to a first preset mapping manner, and obtain the mapped file to be tested;
and mapping the statements to be tested in the files to be tested according to a second preset mapping mode and the mapped files to be tested to obtain the mapped statements to be tested.
Optionally, the filtering module is configured to obtain coverage parameters of any two initial test cases in the initial test case set according to the coverage file;
and filtering the initial test case set according to the coverage rate parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as the target test case set.
Optionally, the filtering module is specifically configured to, if it is determined that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition, filter any one of the initial test cases until the coverage rate parameters of any two initial test cases in the initial test case set do not meet the preset condition, and obtain the target test case set.
Optionally, the filtering module is specifically configured to calculate a similarity parameter between coverage parameters of any two initial test cases in the initial test case set;
and if the similarity parameter meets a preset threshold value, determining that the coverage rate parameters of any two initial test cases in the initial test case set meet a preset condition.
Optionally, the filtering module is specifically configured to calculate a difference set between coverage parameters of any two initial test cases in the initial test case set;
and if the difference set is a null set, determining that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition.
Optionally, the determining module is specifically configured to run each initial test case in the initial test case set based on the mapped file to be tested, and obtain a running result;
and determining the coverage rate file according to the operation result.
Optionally, the apparatus further comprises: the updating module is used for adding a new test case if at least one statement to be tested in the file to be tested is determined to be uncovered according to the coverage rate file, wherein the new test case is used for covering the statement to be tested which is not covered by the initial test case set;
and updating the target test case set according to the new test case and the target test case set.
In a third aspect, an embodiment of the present application provides an electronic device, including: the test case set optimization method comprises a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when the electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the optimization processing method of the test case set of the first aspect.
In a fourth aspect, an embodiment of the present application provides a storage medium, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the method for optimizing a test case suite according to the first aspect are executed.
The beneficial effect of this application is:
in the optimization processing method, device, electronic device and storage medium of the test case set provided by the embodiment of the application, the file to be tested is obtained, and the file to be tested comprises at least one statement to be tested; mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences; determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested and the sentences to be tested which are covered by each initial test case; according to the method and the device for filtering the initial test case set, the initial test case set is filtered according to the coverage rate file, the target test case set is determined, and by applying the method and the device for filtering the initial test case set, redundant initial test cases in the initial test case set can be automatically filtered according to the coverage rate file, so that manual filtering is avoided, and the filtering efficiency can be effectively improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic flowchart of an optimization processing method for a test case suite according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another method for optimizing a test case suite according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of another method for optimizing a test case suite according to an embodiment of the present application;
fig. 4 is a schematic flowchart of another method for optimizing a test case suite according to an embodiment of the present application;
fig. 5 is a schematic flowchart of another method for optimizing a test case suite according to an embodiment of the present application;
fig. 6 is a schematic flowchart of another method for optimizing a test case suite according to an embodiment of the present application;
fig. 7 is a functional module schematic diagram of an apparatus for optimizing a test case suite according to an embodiment of the present application;
fig. 8 is a functional module schematic diagram of another test case suite optimization processing apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the prior art, taking a service interface as an example, when a test case is designed for the service interface, the service interface may include a plurality of interface parameters, and a combination of different interface parameters has different business representations, and when there are many interface parameters, for example, N, and each parameter has 2 selectable items, then the number of test cases after combination expansion is up to N times of 2, it can be seen that the test case set is very large, and many of the test case set are repeatedly invalid test cases, so that the test case set needs to be filtered. In the conventional filtering, filtering is generally performed by manually combing some filtering rules or by a genetic algorithm of parameters, but the conventional filtering method depends on manual work, particularly on the understanding of a tester to a business system, so that the filtering efficiency is low.
In view of this, the present application provides an optimization processing method for a test case suite, which can implement automatic filtering on an initial test case suite and improve filtering efficiency.
Fig. 1 is a schematic flowchart of a method for optimizing a test case suite according to an embodiment of the present disclosure, where an execution subject of the method may be a computer, a server, a processor, a terminal device, and as shown in fig. 1, the method may include:
s101, obtaining a file to be tested, wherein the file to be tested comprises at least one statement to be tested.
The file to be tested may be a code file to be tested, and the code file to be tested may include a plurality of code statements to be tested, that is, a plurality of statements to be tested. Alternatively, each line of the code file to be tested may include one or more code statements to be tested, which are not limited herein, and may be different according to different code syntax or writing habits of code developers.
Of course, the application herein does not limit the type of code language in the document to be tested, and may include, but is not limited to, C, C + +, python, Java, php, and combinations of one or more thereof.
S102, mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode, and obtaining the mapped to-be-tested sentences.
The sentence to be tested in the file to be tested is mapped, so that the mapped sentence to be tested can correspond to the unique mapping mark. For example, the first row of statements to be tested in the file a to be tested may be mapped as a _1, and the second row of statements to be tested in the file a to be tested may be mapped as a _2, but not limited thereto.
S103, determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested covered by each initial test case and the sentences to be tested.
The initial test case set may include a plurality of initial test cases, and the initial test case set may be generated according to a test case generation tool (e.g., an ons TestCase tool), or may be generated based on an orthogonal method, which is not limited herein.
Based on the mapped file to be tested, a coverage rate file can be determined according to the initial test case set and the mapped file to be tested, and the coverage rate file can be used for embodying the tested proportion and degree of the file to be tested. The coverage rate file may include a plurality of coverage rate parameters, and the coverage rate parameters may be used to indicate the file to be tested and the statement to be tested that each initial test case covers, that is, may be used to indicate the file to be tested and the statement to be tested that each initial test case tests.
And S104, filtering the initial test case set according to the coverage rate file, and determining a target test case set.
After the coverage rate file is obtained, the initial test case set can be automatically filtered according to the coverage rate file, so that repeated invalid initial test cases in the initial test case set are filtered, and a target test case set is obtained, wherein the target test case set is an effective initial test case set.
In addition, the initial test case set is deleted, so that the test efficiency can be improved and other invalid tests can be avoided when relevant test verification is carried out subsequently based on the target test case set.
To sum up, the method for optimizing a test case suite provided in the embodiment of the present application may include: acquiring a file to be tested, wherein the file to be tested comprises at least one sentence to be tested; mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences; determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested and the sentences to be tested which are covered by each initial test case; according to the method and the device for filtering the initial test case set, the initial test case set is filtered according to the coverage rate file, and the target test case set is determined.
Fig. 2 is a schematic flowchart of another test case suite optimization processing method according to an embodiment of the present application. Optionally, as shown in fig. 2, the mapping the to-be-tested statement in the to-be-tested file according to the preset mapping manner to obtain the mapped to-be-tested statement includes:
s201, mapping the file to be tested according to a first preset mapping mode to obtain the mapped file to be tested.
S202, mapping the to-be-tested sentences in the to-be-tested file according to a second preset mapping mode and the mapped to-be-tested file to obtain the mapped to-be-tested sentences.
In some embodiments, the file to be tested and the statement to be tested may implement mapping in different mapping manners, which is not limited herein.
In some embodiments, the file to be tested may be globally indexed, and if the number of the files to be tested is multiple, each file to be tested may be globally mapped to a preset number, letter, or combination thereof. After the mapped file to be tested is obtained, the statements to be tested in the file to be tested may be mapped according to a second preset mapping manner, in some embodiments, the line mapping may be used as a minimum mapping unit, each line of statements to be tested in the file to be tested is sequentially mapped, and each line of statements to be tested is globally mapped to preset numbers, letters, or a combination thereof, but not limited thereto, and may be determined according to a preset mapping relationship. And acquiring the mapped to-be-tested sentences, so that the mapped to-be-tested sentences can correspond to the unique mapping marks.
Of course, other minimum mapping units may be selected according to an actual application scenario, for example, a segment mapping, a basic block mapping, and the like may also be selected, which is not limited herein.
For example, in an application scenario, the first file to be tested and the second file to be tested are included, optionally, the first file to be tested and the second file to be tested may be mapped as 1 and 2, for a first line of statements to be tested of the first file to be tested, the first line of statements to be tested may be mapped as 1_1, and for a second line of statements to be tested of the first file to be tested, the second line of statements to be tested of the first file to be tested may be mapped as 1_2, but not limited to this, and the mapping manner may be flexibly selected according to an actual application scenario. For example, the first row of statements to be tested of the second file to be tested may be mapped as 2_ a, and the second row of statements to be tested of the second file to be tested may be mapped as 2_ B, but not limited thereto.
Fig. 3 is a flowchart illustrating a further method for optimizing a test case suite according to an embodiment of the present application. Optionally, as shown in fig. 3, the filtering the initial test case suite according to the coverage file to determine the target test case suite includes:
s301, according to the coverage rate file, coverage rate parameters of any two initial test cases in the initial test case set are obtained.
S302, filtering the initial test case set according to the coverage rate parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as a target test case set.
The coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested and the statements to be tested which are covered by each initial test case, so that the coverage rate parameters of any two initial test cases in the initial test case set can be obtained when screening is carried out, the initial test case set is filtered according to the coverage rate parameters of any two initial test cases, repeated and invalid initial test cases in the initial test case set are filtered, the filtered initial test case set is obtained, and the filtered initial test case set can be used as a target test case set.
Optionally, the filtering the initial test case set according to the coverage parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as a target test case set includes:
and if the coverage rate parameters of any two initial test cases in the initial test case set reach the preset condition, filtering any one of the initial test cases until the coverage rate parameters of any two initial test cases in the initial test case set do not meet the preset condition, and acquiring the target test case set.
When filtering is performed, filtering may be performed by judging whether coverage parameters of any two initial test cases in the initial test case set reach a preset condition, where the preset condition may be a condition that any two initial test cases are repeated test cases, it can be understood that, if the preset condition is reached, any one of the initial test cases may be filtered, and the other one of the initial test cases is retained until the coverage parameters of any two initial test cases in the initial test case set do not meet the preset condition, that is, no repeated and invalid initial test case exists in the initial test case set, and the initial test case set after filtering is the target test case set.
Fig. 4 is a flowchart illustrating another method for optimizing a test case suite according to an embodiment of the present application. Optionally, as shown in fig. 4, the determining that the coverage rate parameters of any two initial test cases in the initial test case set reach the preset condition includes:
s401, calculating a similarity parameter between coverage rate parameters of any two initial test cases in the initial test case set.
S402, if the similarity parameter meets a preset threshold, determining that the coverage rate parameters of any two initial test cases in the initial test case set meet a preset condition.
The similarity parameter between the coverage rate parameters of any two initial test cases in the initial test case set can indicate the similarity degree of the two initial test cases, and any one of the two initial test cases can be filtered out by calculating the similarity parameter. The calculated similarity parameter may be compared with a preset threshold, and if the similarity parameter satisfies the threshold, it may be determined that the coverage parameters of any two initial test cases in the initial test case set reach a preset condition.
For example, the preset threshold may be X, the similarity parameter between the coverage rate parameters of two initial test cases in the initial test case set is X1, and optionally, if X1< X, the coverage rate parameters of the two initial test cases may be considered to reach the preset condition, but the actual determination manner is not limited thereto, and may be flexibly adjusted according to the actual application scenario.
In some embodiments, optionally, the coverage parameters for any two initial test cases in the set of initial test cases may be calculated based on a Jaccard similarity coefficient or a sum coefficient.
For the calculation of the Jaccard similarity coefficient, see the calculation formula
Figure BDA0002718344720000141
Calculating and obtaining, wherein a and B may respectively represent coverage parameters of any two initial test cases in the initial test case set, a ∞ B may represent an intersection of the coverage parameters of any two initial test cases, and a ≡ B may represent a union of the coverage parameters of any two initial test cases, it can be understood that if J (a, B) values of any two initial test cases are 1, the two initial test cases may be considered to be the same, and if not 1, the two initial test cases may be considered to be different. For the calculation of the sum coefficient, see the calculation formula
Figure BDA0002718344720000142
Calculating and obtaining, wherein A and B can respectively represent coverage rate parameters of any two initial test cases in the initial test case set, n (A # B) can represent the intersection of the coverage rate parameters of any two initial test cases,
Figure BDA0002718344720000143
the geometric mean value of the coverage rate parameters of any two initial test cases can be represented, if the K values of any two initial test cases are 1, the two initial test cases can be considered to be the same, and if the K values of any two initial test cases are not 1, the two initial test cases can be considered to be different. Of course, the calculation method of the similarity parameter is not limited thereto.
Fig. 5 is a flowchart illustrating a further method for optimizing a test case suite according to an embodiment of the present application. Optionally, as shown in fig. 5, the determining that the coverage rate parameters of any two initial test cases in the initial test case set reach the preset condition includes:
s501, calculating a difference set between coverage rate parameters of any two initial test cases in the initial test case set.
S502, if the difference set is a null set, determining that the coverage rate parameters of any two initial test cases in the initial test case set reach preset conditions.
The coverage parameter is used to indicate a file to be tested and a statement to be tested that each initial test case covers, and the coverage parameter corresponding to each initial test case may be represented in a set form, for example, the coverage parameter of a certain initial test case is: {1_1, 1_2, 3_1}, where 1_1 and 1_2 may indicate that the initial test case covers the 1 st row and the 2 nd row of the first file to be tested, and 3_1 may indicate that the initial test case also covers the 1 st row of the third file to be tested.
In some embodiments, it may be determined whether the coverage parameters of any two initial test cases in the initial test case set reach the preset condition by calculating a difference set between the coverage parameters of any two initial test cases in the initial test case set and judging whether the difference set is an empty set, where it is understood that, if the difference set is an empty set, it indicates that the two initial test cases are repeated test cases (same test cases) and the coverage parameters thereof reach the preset condition, then, at this time, any one of the initial test cases may be filtered according to the foregoing method until the coverage parameters of any two initial test cases in the initial test case set do not meet the preset condition, and a target test case set is obtained, which may specifically refer to the foregoing relevant parts, which is not described herein again.
Optionally, the determining the coverage rate file according to the initial test case set and the mapped file to be tested includes:
based on the mapped file to be tested, running each initial test case in the initial test case set to obtain a running result; and determining a coverage rate file according to the operation result.
The coverage rate file can be obtained by means of a third-party tool based on the mapped file to be tested, and it can be understood that the files to be tested in different programming languages can be obtained by different third-party tools. For example, the programming language of the file to be tested is Java language, Go language or Python language, and optionally, the coverage rate file may be obtained by Jacoco, GoCov or coverage.
In some embodiments, the third-party tool may include a plurality of functions, and based on the initial test case set and the mapped file to be tested, the plurality of functions may be run to obtain a run result, and the run result may indicate a statement to be tested that is executed and a statement to be tested that is not executed in the file to be tested, and then the coverage rate file may be determined according to the run result. Of course, the determination method of the coverage rate file is not limited to this.
Fig. 6 is a flowchart illustrating another method for optimizing a test case suite according to an embodiment of the present application. Optionally, as shown in fig. 6, the method further includes:
s601, if it is determined that at least one to-be-tested statement in the to-be-tested file is uncovered according to the coverage rate file, adding a new test case, wherein the new test case is used for covering the to-be-tested statement uncovered by the initial test case set.
And S602, updating the target test case set according to the new test case and the target test case set.
It can be understood that based on the foregoing embodiment, since the coverage file includes a plurality of coverage parameters, and the coverage parameters are used to indicate the file to be tested and the statements to be tested that each initial test case covers, the statements to be tested that are not covered in the file to be tested can be determined according to the coverage file. Based on the principle, in order to realize comprehensive testing and ensure that each test statement in the file to be tested can be covered, a new test case can be added based on the coverage rate file, and then the target test case set can be updated according to the new test case and the obtained target test case set, so that the updated target test case set can cover all the statements to be tested in the file to be tested, and the test comprehensiveness is ensured.
Of course, it should be noted that, based on the obtained coverage file, a coverage degree may also be determined, where the coverage degree may indicate a degree of coverage of a statement to be tested in the file to be tested, and optionally, if it is determined that the coverage degree does not meet a preset threshold, new test cases may be added, and the number of the added new test cases may be different according to an actual application scenario, for example, the number of the added new test cases may include 10, 20, or 50, and is not limited herein.
Based on the foregoing embodiment, the description is made by taking an interface addActivity as an example, where addActivity is an interface for creating activities, and may include 4 parameters, i.e., cityid, userids, starttime, and endtime, where the parameter cityid represents a city ID, the parameter userids represents a user ID, the parameter starttime represents a start time, and the parameter endtime represents an end time. Alternatively, the 4 parameters respectively generate orthogonal parameters as shown in table 1 below, and optionally, the orthogonal parameters may be generated based on an orthogonal experiment method.
TABLE 1
Figure BDA0002718344720000171
It can be seen that the generated initial test case set has 384 initial test cases (4 × 6 × 4 × 4 ═ 384), and based on the foregoing embodiment, the file to be tested referred to by the addActivity interface can be globally mapped, and the mapping is a number. For example, if the addActivity interface includes 3 files to be tested, and the file names of the files are addActivity. ccp, conf. ccp, and dao. ccp, respectively, the 3 files to be tested can be mapped to 0, 1, and 2, respectively.
Based on the description of the foregoing embodiment, after a certain initial test case runs, a coverage file may be generated, and which to-be-tested statements in the to-be-tested file are covered by the initial test case can be known through the coverage file. For example, if the a case covers rows 0, 1, and 2 in addactivity. ccp, and lines 5 and 6 in conf. ccp, the coverage parameter of the a case can be expressed as AL ═ {0_0, 0_1, 0_2, 1_5, 1_6 }; if the B case covers rows 2, 3, and 4 in addactivity. ccp, and covers rows 7 and 8 in dao. ccp, the coverage parameter of the B case can be represented as BL {0_2, 0_3, 0_4, 2_7, 2_8 }. Optionally, a difference set between the coverage rate parameter of the a case and the coverage rate parameter of the B case may be calculated, and if the difference set between the AL and the BL is an empty set, the coverage rate parameters of the a case and the B case may be considered to reach a preset condition, and any one of the test cases may be filtered out, for example, the test case a may be filtered out or the test case B may be filtered out.
Fig. 7 is a functional module schematic diagram of an optimization processing device for a test case suite according to an embodiment of the present application, where the optimization processing device may be the aforementioned computer, server, processor, terminal device, and the like, and the basic principle and the generated technical effect of the device are the same as those of the foregoing corresponding method embodiment, and for brief description, reference may be made to corresponding contents in the method embodiment for a part not mentioned in this embodiment. As shown in fig. 7, the optimization processing apparatus 100 may include: an acquisition module 110, a mapping module 120, a determination module 130, and a filtering module 140.
An obtaining module 110, configured to obtain a file to be tested, where the file to be tested includes at least one statement to be tested; the mapping module 120 is configured to map a to-be-tested sentence in a to-be-tested file according to a preset mapping manner, and obtain a mapped to-be-tested sentence; the determining module 130 is configured to determine a coverage rate file according to the set of initial test cases and the mapped file to be tested, where the coverage rate file includes a plurality of coverage rate parameters, and the coverage rate parameters are used to indicate the file to be tested and the sentence to be tested that each initial test case covers; and the filtering module 140 is configured to filter the initial test case set according to the coverage file, and determine a target test case set.
Optionally, the mapping module 120 is specifically configured to map the file to be tested according to a first preset mapping manner, and obtain a mapped file to be tested; and mapping the statements to be tested in the file to be tested according to the second preset mapping mode and the mapped file to be tested to obtain the mapped statements to be tested.
Optionally, the filtering module 140 is configured to obtain coverage parameters of any two initial test cases in the initial test case set according to the coverage file; and filtering the initial test case set according to the coverage rate parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as a target test case set.
Optionally, the filtering module 140 is specifically configured to, if it is determined that the coverage rate parameters of any two initial test cases in the initial test case set reach the preset condition, filter out any one of the initial test cases until the coverage rate parameters of any two initial test cases in the initial test case set do not meet the preset condition, and obtain the target test case set.
Optionally, the filtering module 140 is specifically configured to calculate a similarity parameter between coverage parameters of any two initial test cases in the initial test case set; and if the similarity parameter meets a preset threshold value, determining that the coverage rate parameters of any two initial test cases in the initial test case set meet a preset condition.
Optionally, the filtering module 140 is specifically configured to calculate a difference set between coverage parameters of any two initial test cases in the initial test case set; and if the difference set is a null set, determining that the coverage rate parameters of any two initial test cases in the initial test case set reach preset conditions.
Optionally, the determining module 130 is specifically configured to run each initial test case in the initial test case set based on the mapped file to be tested, and obtain a running result; and determining a coverage rate file according to the operation result.
Fig. 8 is a functional module schematic diagram of another test case suite optimization processing apparatus according to an embodiment of the present application. Optionally, as shown in fig. 8, the apparatus further includes: the updating module 150 is configured to add a new test case if it is determined that at least one to-be-tested statement in the to-be-tested file is uncovered according to the coverage rate file, where the new test case is used to cover the to-be-tested statement that is not covered by the initial test case set; and updating the target test case set according to the new test case and the target test case set.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may be a server, a computer, a terminal device, etc. implementing the concepts of the present application. As shown in fig. 9, a processor may be used on the electronic device 200 and to perform the functions in the present application.
The electronic device 200 may be a general-purpose computer or a special-purpose computer, both of which may be used to implement the method for optimizing the test case set of the present application. Although only a single computer is shown, for convenience, the functions described herein may be implemented in a distributed fashion across multiple similar platforms to balance processing loads.
For example, the electronic device 200 may include a network port 210 connected to a network, one or more processors 220 for executing program instructions, a communication bus 230, and a different form of storage medium 240, such as a disk, ROM, or RAM, or any combination thereof. Illustratively, the computer platform may also include program instructions stored in ROM, RAM, or other types of non-transitory storage media, or any combination thereof. The method of the present application may be implemented in accordance with these program instructions. The electronic device 200 also includes an Input/Output (I/O) interface 250 between the computer and other Input/Output devices (e.g., keyboard, display screen).
For ease of illustration, only one processor is depicted in the electronic device 200. However, it should be noted that the electronic device 200 in the present application may also comprise a plurality of processors, and thus the steps performed by one processor described in the present application may also be performed by a plurality of processors in combination or individually. For example, if the processor of the electronic device 200 executes steps a and B, it should be understood that steps a and B may also be executed by two different processors together or separately in one processor. For example, a first processor performs step a and a second processor performs step B, or the first processor and the second processor perform steps a and B together.
Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program performs the steps of the above method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Alternatively, the server may be a single server or a server group; the set of servers can be centralized or distributed (e.g., the servers can be a distributed system). In some embodiments, the server may be implemented on a cloud platform; by way of example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud (community cloud), a distributed cloud, an inter-cloud, a multi-cloud, and the like, or any combination thereof.
In some embodiments, the server may include a processor. The processor may process information and/or data related to the service request to perform one or more of the functions described herein. In some embodiments, a processor may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). Merely by way of example, a Processor may include a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), an Application Specific Instruction Set Processor (ASIP), a Graphics Processing Unit (GPU), a Physical Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Device (PLD), a controller, a microcontroller Unit, a Reduced Instruction Set computer (Reduced Instruction Set computer), a microprocessor, or the like, or any combination thereof.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present application. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (11)

1. A method for optimizing a test case suite is characterized by comprising the following steps:
acquiring a file to be tested, wherein the file to be tested comprises at least one statement to be tested;
mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences;
determining a coverage rate file according to the initial test case set and the mapped files to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the files to be tested covered by each initial test case and the sentences to be tested;
and filtering the initial test case set according to the coverage rate file to determine a target test case set.
2. The method according to claim 1, wherein the mapping the to-be-tested sentence in the to-be-tested file according to a preset mapping manner to obtain the mapped to-be-tested sentence comprises:
mapping the file to be tested according to a first preset mapping mode to obtain the mapped file to be tested;
and mapping the statements to be tested in the files to be tested according to a second preset mapping mode and the mapped files to be tested to obtain the mapped statements to be tested.
3. The method of claim 1, wherein the filtering the initial set of test cases according to the coverage file to determine a target set of test cases comprises:
acquiring coverage rate parameters of any two initial test cases in the initial test case set according to the coverage rate file;
and filtering the initial test case set according to the coverage rate parameters of any two initial test cases in the initial test case set, and acquiring the filtered initial test case set as the target test case set.
4. The method according to claim 3, wherein the filtering the initial test case set according to coverage parameters of any two of the initial test cases in the initial test case set to obtain the filtered initial test case set as the target test case set comprises:
and if the coverage rate parameters of any two initial test cases in the initial test case set reach preset conditions, filtering any one of the initial test cases until the coverage rate parameters of any two initial test cases in the initial test case set do not meet the preset conditions, and acquiring the target test case set.
5. The method according to claim 4, wherein the determining that the coverage parameters of any two of the initial test cases in the set of initial test cases meet a preset condition comprises:
calculating a similarity parameter between coverage rate parameters of any two initial test cases in the initial test case set;
and if the similarity parameter meets a preset threshold value, determining that the coverage rate parameters of any two initial test cases in the initial test case set meet a preset condition.
6. The method according to claim 4, wherein the determining that the coverage parameters of any two of the initial test cases in the set of initial test cases meet a preset condition comprises:
calculating a difference set between coverage rate parameters of any two initial test cases in the initial test case set;
and if the difference set is a null set, determining that the coverage rate parameters of any two initial test cases in the initial test case set reach a preset condition.
7. The method of claim 1, wherein determining a coverage file from the set of initial test cases and the mapped file to be tested comprises:
based on the mapped file to be tested, running each initial test case in the initial test case set to obtain a running result;
and determining the coverage rate file according to the operation result.
8. The method according to any one of claims 1-7, further comprising:
if it is determined that at least one statement to be tested in the file to be tested is uncovered according to the coverage rate file, adding a new test case, wherein the new test case is used for covering the statement to be tested which is not covered by the initial test case set;
and updating the target test case set according to the new test case and the target test case set.
9. An apparatus for optimizing a test case suite, comprising: the device comprises an acquisition module, a mapping module, a determination module and a filtering module;
the acquisition module is used for acquiring a file to be tested, wherein the file to be tested comprises at least one sentence to be tested;
the mapping module is used for mapping the to-be-tested sentences in the to-be-tested file according to a preset mapping mode to obtain the mapped to-be-tested sentences;
the determining module is used for determining a coverage rate file according to an initial test case set and the mapped file to be tested, wherein the coverage rate file comprises a plurality of coverage rate parameters, and the coverage rate parameters are used for indicating the file to be tested and the sentence to be tested which are covered by each initial test case;
and the filtering module is used for filtering the initial test case set according to the coverage rate file and determining a target test case set.
10. An electronic device, comprising: the test case set optimization method comprises a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, when an electronic device runs, the processor and the storage medium communicate through the bus, and the processor executes the machine-readable instructions to execute the steps of the test case set optimization processing method according to any one of claims 1-8.
11. A storage medium having stored thereon a computer program for executing the steps of the method for optimized processing of a test case set according to any of claims 1-8 when the computer program is executed by a processor.
CN202011080381.0A 2020-10-10 2020-10-10 Test case suite optimization processing method and device, electronic equipment and storage medium Pending CN112148619A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011080381.0A CN112148619A (en) 2020-10-10 2020-10-10 Test case suite optimization processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011080381.0A CN112148619A (en) 2020-10-10 2020-10-10 Test case suite optimization processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112148619A true CN112148619A (en) 2020-12-29

Family

ID=73952969

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011080381.0A Pending CN112148619A (en) 2020-10-10 2020-10-10 Test case suite optimization processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112148619A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113377289A (en) * 2021-06-01 2021-09-10 北京齐尔布莱特科技有限公司 Cache management method, system, computing device and readable storage medium
CN113448869A (en) * 2021-07-16 2021-09-28 建信金融科技有限责任公司 Method and device for generating test case, electronic equipment and computer readable medium
CN113468053A (en) * 2021-07-02 2021-10-01 建信金融科技有限责任公司 Application system testing method and device
CN113722234A (en) * 2021-09-14 2021-11-30 京东科技控股股份有限公司 Test case screening method and device, electronic equipment and storage medium
CN113900942A (en) * 2021-10-09 2022-01-07 电子科技大学 Method for generating simplified test case set of flight control machine-mounted model
CN114610614A (en) * 2022-03-08 2022-06-10 北京京航计算通讯研究所 Safety test method and system for programmable logic device packaging module

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10146668B1 (en) * 2013-12-20 2018-12-04 EMC IP Holding Company LLC Modeling code coverage in software life cycle
CN109446060A (en) * 2018-09-13 2019-03-08 百富计算机技术(深圳)有限公司 A kind of generation method, terminal device and the storage medium of server-side test use cases
CN110471850A (en) * 2019-08-09 2019-11-19 锐捷网络股份有限公司 Code coverage test method and device
CN110502447A (en) * 2019-08-30 2019-11-26 西安邮电大学 A kind of regression test case priority ordering method based on figure
CN110765000A (en) * 2019-09-06 2020-02-07 深圳开源互联网安全技术有限公司 Program testing method and device
CN111078563A (en) * 2019-12-18 2020-04-28 上海品顺信息科技有限公司 Coverage rate data processing method, terminal device and computer readable storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10146668B1 (en) * 2013-12-20 2018-12-04 EMC IP Holding Company LLC Modeling code coverage in software life cycle
CN109446060A (en) * 2018-09-13 2019-03-08 百富计算机技术(深圳)有限公司 A kind of generation method, terminal device and the storage medium of server-side test use cases
CN110471850A (en) * 2019-08-09 2019-11-19 锐捷网络股份有限公司 Code coverage test method and device
CN110502447A (en) * 2019-08-30 2019-11-26 西安邮电大学 A kind of regression test case priority ordering method based on figure
CN110765000A (en) * 2019-09-06 2020-02-07 深圳开源互联网安全技术有限公司 Program testing method and device
CN111078563A (en) * 2019-12-18 2020-04-28 上海品顺信息科技有限公司 Coverage rate data processing method, terminal device and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
宫伟祥;崔诗娴;陈春晓;: "无线电调谐单元软件语句覆盖目标的实现", 计算机系统应用, vol. 25, no. 05, 15 May 2016 (2016-05-15), pages 181 - 186 *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113377289A (en) * 2021-06-01 2021-09-10 北京齐尔布莱特科技有限公司 Cache management method, system, computing device and readable storage medium
CN113377289B (en) * 2021-06-01 2024-08-13 北京齐尔布莱特科技有限公司 Cache management method, system, computing device and readable storage medium
CN113468053A (en) * 2021-07-02 2021-10-01 建信金融科技有限责任公司 Application system testing method and device
CN113468053B (en) * 2021-07-02 2022-11-15 中国建设银行股份有限公司 Application system testing method and device
CN113448869A (en) * 2021-07-16 2021-09-28 建信金融科技有限责任公司 Method and device for generating test case, electronic equipment and computer readable medium
CN113722234A (en) * 2021-09-14 2021-11-30 京东科技控股股份有限公司 Test case screening method and device, electronic equipment and storage medium
CN113722234B (en) * 2021-09-14 2024-09-20 京东科技控股股份有限公司 Screening method and device for test cases, electronic equipment and storage medium
CN113900942A (en) * 2021-10-09 2022-01-07 电子科技大学 Method for generating simplified test case set of flight control machine-mounted model
CN113900942B (en) * 2021-10-09 2023-04-07 电子科技大学 Method for generating simplified test case set of flight control machine-mounted model
CN114610614A (en) * 2022-03-08 2022-06-10 北京京航计算通讯研究所 Safety test method and system for programmable logic device packaging module

Similar Documents

Publication Publication Date Title
CN112148619A (en) Test case suite optimization processing method and device, electronic equipment and storage medium
CN111797022A (en) Test case generation method and device for order splitting service, electronic equipment and medium
CN109858828B (en) Power distribution network fixed value automatic setting method and device and distribution network system
CN113760769B (en) Test case processing method and device, electronic equipment and storage medium
CN110955409B (en) Method and device for creating resources on cloud platform
CN112100359B (en) Test case searching method, device, equipment and storage medium
CN114064208A (en) Method and device for detecting application service state, electronic equipment and storage medium
CN111782527A (en) Interface testing method and device, computer equipment and storage medium
CN115576828A (en) Test case generation method, device, equipment and storage medium
WO2022198835A1 (en) Method and apparatus for testing electronic map, and electronic device and storage medium
CN112561690A (en) Method, system, equipment and storage medium for testing credit card staging service interface
CN111127223A (en) Insurance product testing method and device and storage medium
CN115981996A (en) Test data generation method, device, equipment and storage medium
CN116719843A (en) Query method, storage medium and device for database system
CN107273293B (en) Big data system performance test method and device and electronic equipment
CN116301978A (en) System upgrading method, device, equipment and storage medium
CN115757097A (en) Test case generation method and device, electronic equipment and storage medium
JP5121891B2 (en) Rule inspection device, rule inspection method and rule inspection program
CN114461390A (en) Evaluation method combining multi-dimensional analysis and critical path method and related device
CN114942905A (en) Migration data verification method, device, equipment and storage medium
CN114693116A (en) Method and device for detecting code review validity and electronic equipment
CN114527993A (en) Application deployment method, device, equipment and medium
CN113448872B (en) Test execution method, device, equipment and storage medium
CN112363933A (en) Automatic verification method and device for word paragraph table, computer equipment and storage medium
CN111444392A (en) Method, device and equipment for accessing cave library

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