CN116627794A - Test case generation method and device - Google Patents

Test case generation method and device Download PDF

Info

Publication number
CN116627794A
CN116627794A CN202310258447.8A CN202310258447A CN116627794A CN 116627794 A CN116627794 A CN 116627794A CN 202310258447 A CN202310258447 A CN 202310258447A CN 116627794 A CN116627794 A CN 116627794A
Authority
CN
China
Prior art keywords
data
target
coverage rate
test case
code coverage
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
CN202310258447.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.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding 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 Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202310258447.8A priority Critical patent/CN116627794A/en
Publication of CN116627794A publication Critical patent/CN116627794A/en
Pending legal-status Critical Current

Links

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/3684Test management for test design, e.g. generating new test cases
    • 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 invention discloses a test case generation method and device, and relates to the technical field of computers. One embodiment of the method comprises the following steps: acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case; determining target data from the data source according to the data screening rule; determining current code coverage rate according to the target data and the historical test cases; and under the condition that the current code coverage rate is larger than the historical code coverage rate, generating a target test case according to the target data. According to the embodiment, the efficiency of generating the test case is improved, and the improvement efficiency of code coverage rate is further improved.

Description

Test case generation method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and apparatus for generating test cases.
Background
The improvement of the code coverage rate of the test case set is important to ensure the quality of the system to be tested.
At present, a tester writes new test cases manually according to the existing code coverage rate, and adds the new test cases into a test case set so as to improve the code coverage rate according to the new test cases.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the related art:
the tester needs to spend more time and effort to update the test case set, and if the updated test case set cannot improve the code coverage rate, the tester also needs to adjust the test case again in a manual mode, so that more testing manpower is input, and the efficiency of improving the code coverage rate is lower.
Disclosure of Invention
In view of the above, the embodiment of the invention provides a test case generation method and device, which can determine target data according to a data screening rule and determine current code coverage rate according to the target data and historical test cases; under the condition that the current code coverage rate is larger than the historical code coverage rate, the target test cases are automatically generated, the time for manually writing the test cases by a tester is greatly shortened, the number of the test cases is increased rapidly, the efficiency of generating the test cases is improved, and the improvement efficiency of the code coverage rate is further improved.
Further, according to the size relation between the current code coverage rate and the historical code coverage rate, updating the data screening rule, so that the purpose of generating more test cases with higher coverage rate can be achieved, and the effectiveness of generating the test cases is improved; according to the data screening rule, target data is acquired from a data source through an asynchronous message or a data interface, so that input and expected results of the test case can be acquired more conveniently, and the efficiency of generating the test case is improved.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a method for generating a test case, including:
acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case;
determining target data from the data source according to the data screening rule;
determining current code coverage rate according to the target data and the historical test cases;
and under the condition that the current code coverage rate is larger than the historical code coverage rate, generating a target test case according to the target data.
Optionally, the method further comprises:
determining a historical test link according to the historical test case, and analyzing the historical code coverage rate and the historical test link to obtain an uncovered code;
and determining the data screening rule according to the uncovered codes.
Optionally, updating the data filtering rule under the condition that the current code coverage rate is not greater than the historical code coverage rate, and re-determining the target data according to the updated data filtering rule.
Optionally, the determining, according to the data filtering rule, target data from the data source includes:
obtaining basic data from the data source through asynchronous messages, and determining the target data from the basic data according to the data screening rules;
and/or the number of the groups of groups,
and generating a query request according to the data screening rule, transmitting the query request to the data source through a data interface of the data source, and receiving the target data returned by the data source according to the query request.
Optionally, the determining the current code coverage according to the target data and the historical test case includes:
and sending the target data and the history test cases to the tested system through an operation interface of the tested system, and acquiring the current code coverage rate returned by a code coverage rate tool in the tested system.
Optionally, the target data includes target request data and a target return result, and generating the target test case according to the target data includes:
and taking the target request data as input of the target test case, and taking the target return result as an expected result of the target test case.
Optionally, after the generating the target test case, the method further includes:
testing the tested system according to the target test case;
and generating and displaying a visual page according to the test result and the expected result.
Optionally, the data filtering rules are updated to data filtering rules to filter the screened target data when the target data is redetermined.
According to a second aspect of an embodiment of the present invention, there is provided a test case generating apparatus including: the device comprises an acquisition module, a determination module and a generation module; wherein,,
the acquisition module is used for acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case;
the determining module is used for determining target data from the data source according to the data screening rule; determining current code coverage rate according to the target data and the historical test cases;
the generating module is used for generating a target test case according to the target data under the condition that the current code coverage rate is larger than the historical code coverage rate.
According to a third aspect of an embodiment of the present invention, there is provided an electronic apparatus including:
one or more processors;
storage means for storing one or more programs,
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement a method as provided in any one of the test case generation methods of the first aspect above.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method as set forth in any one of the test case generating methods provided in the first aspect above.
One embodiment of the above invention has the following advantages or benefits: target data can be determined according to the data screening rule, and the current code coverage rate is determined according to the target data and the historical test cases; under the condition that the current code coverage rate is larger than the historical code coverage rate, the target test cases are automatically generated, the time for manually writing the test cases by a tester is greatly shortened, the number of the test cases is increased rapidly, the efficiency of generating the test cases is improved, and the improvement efficiency of the code coverage rate is further improved.
Further, according to the size relation between the current code coverage rate and the historical code coverage rate, updating the data screening rule, so that the purpose of generating more test cases with higher coverage rate can be achieved, and the effectiveness of generating the test cases is improved; according to the data screening rule, target data is acquired from a data source through an asynchronous message or a data interface, so that input and expected results of the test case can be acquired more conveniently, and the efficiency of generating the test case is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a flow chart of a method for generating test cases according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a system architecture suitable for test case generation according to one embodiment of the present invention;
FIG. 3 is a flowchart of a test case generating method according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of a test case generating device according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features in the embodiments may be combined with each other without collision.
As shown in fig. 1, an embodiment of the present invention provides a test case generating method, which may include the following steps S101 to S104:
step S101: acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained through analysis according to a historical test case and a historical code coverage rate corresponding to the historical test case.
The data filtering rule may be a rule applied to a data source to filter data required by a tested system when testing a certain tested system. The data filtering rules may be configured in the form of regular expressions, for example, may be set to match a certain keyword or keywords; or may be configured to match traffic data within a time interval.
The data screening rules may be set in the following manner provided by one embodiment of the present invention: determining a historical test link according to the historical test case, and analyzing the historical code coverage rate and the historical test link to obtain an uncovered code; and determining the data screening rule according to the uncovered codes.
It can be understood that, typically, the system under test is tested by using historical test cases, and in the testing process, a code coverage rate tool can be used to obtain the historical code coverage rate after the execution of the historical test cases, and a historical test link corresponding to each test case. The historical test link is a code path covered by the test case after the test case is executed in the tested system. According to the historical coverage rate and the historical test link, codes which are not covered in the tested system can be obtained through a statistical report of the code coverage rate; and analyzing the uncovered codes to determine which business data can be uncovered by the uncovered codes, thereby determining the data screening rule. For example, in the tested system a, after the historical test case is executed, through the report of the coverage rate of the historical codes, a section of uncovered codes can be obtained by analysis, and can be covered when the account identifier X is judged to match the keyword U, and then a similar expression with the regular expression of x= U can be added in the data screening rule. Therefore, the data screening rule can be determined directionally according to the uncovered codes, the efficiency and the effectiveness of data screening are improved, and the possibility of improving the coverage rate of the codes can be further increased.
Step S102: and determining target data from the data source according to the data screening rule.
The data source can be a database for storing data of the service system, real-time data of the service system during operation or large data centers corresponding to a plurality of service systems. The target data may be business data that is applied to the system under test for execution. In one embodiment of the invention, the target data may be determined from the data sources in the following manner: and obtaining basic data from the data source through asynchronous messages, and determining the target data from the basic data according to the data screening rule.
For example, when the service system runs in real time, an asynchronous message may be sent at a location where real-time data return occurs according to a service request, where the asynchronous message includes the request data and a return result of the service system corresponding to the request data. After the asynchronous message is obtained, the asynchronous message is consumed, service data in the asynchronous message is used as basic data, target data meeting data screening rules is determined from the basic data, and then the target data is stored in a persistent database, such as mysql or Hbase.
In one embodiment of the invention, the target data may also be determined from the data sources in the following manner: and generating a query request according to the data screening rule, transmitting the query request to the data source through a data interface of the data source, and receiving the target data returned by the data source according to the query request.
For example, for backtracking information related to a service to be queried, a data screening rule may send a query request to a related service log data source, query log records through a data interface corresponding to the data source, screen out log data meeting the data screening rule, determine the log data as target data, and store the target data durably.
It will be appreciated that the target data may also be determined in a combination of asynchronous messages and data interfaces. FIG. 2 is a schematic diagram of a system architecture for generating test cases according to an embodiment of the present invention. As shown in fig. 2, data is acquired through a data interface or an asynchronous message, then target data is determined by a screening service according to a data screening rule, and then the target data is stored in a database, such as mysql or Hbase, through a persistence service.
Step S103: and determining the current code coverage rate according to the target data and the historical test case.
In one embodiment of the invention, the current code coverage may be determined in the following manner: and sending the target data and the history test cases to the tested system through an operation interface of the tested system, and acquiring the current code coverage rate returned by a code coverage rate tool in the tested system.
That is, the operation interface of the tested system is called, and the target data and the input data in the history test case are transmitted to the tested system through the operation interface to operate. A code coverage rate tool, such as a java coverage rate tool jacoco, is configured in the tested system, and after the data are run in the tested system, the current code coverage rate can be obtained through the code coverage rate tool.
As in fig. 2, the playback service transmits the target data from the database to the tested system for operation; the tested system is accessed into a code coverage rate tool to count the code coverage rate during running; after the current code coverage rate is obtained, the code coverage rate is stored in a database; insertion of pile code or Mock operation is typically performed in the system under test to mimic the return value of the external interface invoked during operation of the system under test, thereby simplifying the testing process.
Step S104: and under the condition that the current code coverage rate is larger than the historical code coverage rate, generating a target test case according to the target data.
It will be appreciated that the target data may cover code segments not covered by the historical test cases, and then the current code coverage is greater than the historical code coverage; therefore, a new target test case can be generated according to the target data so as to improve the code coverage rate. The target data includes target request data and a target return result, for example, the target request data may be an account identifier ID, and the target return result may be service status information about the account identifier ID returned by the service system a. In one embodiment of the invention, the target test cases may be generated from the target data in the following manner: and taking the target request data as input of the target test case, and taking the target return result as an expected result of the target test case. Therefore, the target test case can be conveniently generated by the target data, the process of writing the test case is simplified, the process of automatically adding the test case is realized, and the efficiency of generating the target test case is further improved.
In fig. 2, the playback service performs data playback on the tested system, that is, the current code coverage rate is counted after the target data is sent from the database to the tested system for operation, and when the current code coverage rate is determined to be greater than the historical code coverage rate, the target test cases generated according to the target data can be synchronized to the test case platform for storage, so that the test case set of the tested system is updated, and the purpose of improving the code coverage rate is achieved. After the target test case is synchronized to the test case platform, the target test case can be marked according to the current code coverage returned by the code coverage tool so as to determine the corresponding relation between the target test case and the coverage code, thereby better maintaining the test case set.
In one embodiment of the present invention, after the target test case is generated, the target test case may be used for testing a tested system, and the test result may be obtained by the following manner: testing the tested system according to the target test case; and generating and displaying a visual page according to the test result and the expected result.
For example, in fig. 2, after a target test case tests a tested system, an automatic comparison service may compare a test result with an expected result of the target test case to obtain a comparison report, the comparison report may be stored in a database, and then the result of the comparison report is sent as an asynchronous message to a visual display system to generate a visual page, so as to obtain a detailed test report of the tested system, so that a tester can analyze the test report, evaluate the direction of optimizing the test case, and perform subsequent optimization on a test case set and a data screening rule of the tested system, thereby achieving the purpose of continuous integration.
It can be understood that after the target data is transmitted to the tested system for operation, the situation that the current code coverage rate is not improved and is possibly smaller than or equal to the historical code coverage rate may occur, and the following methods provided by the embodiments of the present invention may be adopted for subsequent optimization: updating the data screening rule, and re-determining the target data according to the updated data screening rule. Therefore, more accurate target data can be provided for the subsequent automatic generation of target test cases, and the possibility of improving the code coverage rate is increased.
For example, the current code coverage rate is equal to the historical code coverage rate, that is, the code covered by the target data when the tested system is running is already covered by the historical test case, so that the target data has no effect on improving the code coverage rate, then in the next data screening request, the data screening rule can be adjusted, for example, the rule of the data screening rule, which matches the service data in a certain time period, is adjusted, the duration of the time period is increased to improve the number of the screened service data, so that the target data which is more likely to improve the code coverage rate is screened out, and the efficiency of improving the code coverage rate is improved.
In one embodiment of the present invention, when updating the data filtering rule, the following manner may be further adopted: updating the data filtering rule into a data filtering rule to filter the screened target data when the target data is redetermined. For example, for target data that has proven to be unable to improve code coverage, these target data may be considered invalid data, which may be deleted from the database in fig. 2 in order to save storage space of the database; in addition, in the process of updating the data screening rule, the data screening rule can be updated into the data filtering rule, namely, when the screening service performs data screening next time, the target data of the corresponding condition is filtered, so that the current batch of target data (namely, invalid data) is not acquired any more, the accuracy of the data screening of the screening service is improved, and the data screening efficiency is further improved.
FIG. 3 is a flowchart of a test case generating method according to another embodiment of the present invention, which includes the following steps:
step S301: a data screening request is obtained.
Wherein the data screening request includes a data source and a data screening rule.
Step S302: and screening out target data according to the data screening rule.
Step S303: and sending the target data to the tested system to operate.
Step S304: and acquiring the current code coverage rate.
And acquiring the current code coverage rate from a code coverage rate tool accessed by the tested system.
Step S305: judging whether the current code coverage rate is larger than the historical coverage rate or not; if yes, step S306 is performed, and if no, step S309 is performed.
Step S306: and generating a target test case according to the target data.
Step S307: synchronizing the target test case to the test case platform.
Step S308: and testing the tested system by using the test case set in the test case platform to generate a visual page display test report.
And (3) carrying out test link analysis according to the current code coverage rate and the current test case set to determine uncovered codes, and executing step S309 when the data screening is carried out next time, and updating the data screening rule so as to screen out other target data to further improve the code coverage rate.
Step S309: updating the data screening rules.
The current code coverage rate is not greater than the historical code coverage rate, the target data is ignored, the historical code coverage rate and the test case set in the test case platform are subjected to link analysis, and the data screening rule is adjusted according to the analysis result, so that the target data which can possibly improve the code coverage rate is screened out again; and a data filtering rule can be added into the data filtering rule, so that target data which does not improve the code coverage rate at this time is filtered, and the screened invalid data is reduced, thereby improving the efficiency and accuracy of data filtering.
After updating the data screening rule, the next data screening request can be generated, so that the purpose of continuous integration is achieved, the efficiency of generating test cases is improved, and the possibility of improving the code coverage rate is further improved.
According to the test case generation method provided by the embodiment of the invention, the target data can be determined according to the data screening rule, and the current code coverage rate can be determined according to the target data and the historical test case; under the condition that the current code coverage rate is larger than the historical code coverage rate, the target test cases are automatically generated, the time for manually writing the test cases by a tester is greatly shortened, the number of the test cases is increased rapidly, the efficiency of generating the test cases is improved, and the improvement efficiency of the code coverage rate is further improved.
Further, according to the size relation between the current code coverage rate and the historical code coverage rate, updating the data screening rule, so that the purpose of generating more test cases with higher coverage rate can be achieved, and the effectiveness of generating the test cases is improved; according to the data screening rule, target data is acquired from a data source through an asynchronous message or a data interface, so that input and expected results of the test case can be acquired more conveniently, and the efficiency of generating the test case is improved.
As shown in fig. 4, an embodiment of the present invention provides a test case generating apparatus 400, including: an acquisition module 401, a determination module 402, and a generation module 403; wherein,,
the acquiring module 401 is configured to acquire a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case;
the determining module 402 is configured to determine target data from the data source according to the data filtering rule; determining current code coverage rate according to the target data and the historical test cases;
the generating module 403 is configured to generate a target test case according to the target data when the current code coverage rate is greater than the historical code coverage rate.
In one embodiment of the present invention, the determining module 402 is configured to determine a historical test link according to a historical test case, and obtain an uncovered code according to the historical code coverage rate and the historical test link analysis; and determining the data screening rule according to the uncovered codes.
In one embodiment of the present invention, the determining module 402 is configured to update the data filtering rule and re-determine the target data according to the updated data filtering rule, where the current code coverage is not greater than the historical code coverage.
In one embodiment of the present invention, the determining module 402 is configured to obtain base data from the data source through an asynchronous message, and determine the target data from the base data according to the data filtering rule.
In one embodiment of the present invention, the determining module 402 is configured to generate a query request according to the data filtering rule, transmit the query request to the data source through a data interface of the data source, and receive the target data returned by the data source according to the query request.
In one embodiment of the present invention, the determining module 402 is configured to send the target data and the history test case to the tested system through an operation interface of the tested system, and obtain a current code coverage rate returned by a code coverage rate tool in the tested system.
In one embodiment of the present invention, the determining module 402 is configured to update the data filtering rule to a data filtering rule to filter the filtered target data when the target data is redetermined.
In one embodiment of the present invention, the generating module 403 is configured to include target request data and a target return result, take the target request data as input of the target test case, and take the target return result as an expected result of the target test case.
In one embodiment of the present invention, the generating module 403 is configured to test the tested system according to the target test case after the generating the target test case; and generating and displaying a visual page according to the test result and the expected result.
According to the test case generating device provided by the embodiment of the invention, the target data can be determined according to the data screening rule, and the current code coverage rate can be determined according to the target data and the historical test case; under the condition that the current code coverage rate is larger than the historical code coverage rate, the target test cases are automatically generated, the time for manually writing the test cases by a tester is greatly shortened, the number of the test cases is increased rapidly, the efficiency of generating the test cases is improved, and the improvement efficiency of the code coverage rate is further improved.
Further, according to the size relation between the current code coverage rate and the historical code coverage rate, updating the data screening rule, so that the purpose of generating more test cases with higher coverage rate can be achieved, and the effectiveness of generating the test cases is improved; according to the data screening rule, target data is acquired from a data source through an asynchronous message or a data interface, so that input and expected results of the test case can be acquired more conveniently, and the efficiency of generating the test case is improved.
FIG. 5 illustrates an exemplary system architecture 500 for a test case generation method or a test case generation apparatus to which embodiments of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting information browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server providing support for data screening requests made by users using the terminal devices 501, 502, 503. The background management server can process the received data screening request to determine target data, generate a target test case according to the target data, and feed back a processing result to the terminal equipment.
It should be noted that, the test case generating method provided in the embodiment of the present invention is generally executed by the server 505, and accordingly, the test case generating device is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes an acquisition module, a determination module, and a generation module. The names of these modules do not in any way limit the module itself, and the acquisition module may also be described as a "module that acquires a data screening request", for example.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include: acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case; determining target data from the data source according to the data screening rule; determining current code coverage rate according to the target data and the historical test cases; and under the condition that the current code coverage rate is larger than the historical code coverage rate, generating a target test case according to the target data.
According to the technical scheme provided by the embodiment of the invention, the target data can be determined according to the data screening rule, and the current code coverage rate can be determined according to the target data and the historical test cases; under the condition that the current code coverage rate is larger than the historical code coverage rate, the target test cases are automatically generated, the time for manually writing the test cases by a tester is greatly shortened, the number of the test cases is increased rapidly, the efficiency of generating the test cases is improved, and the improvement efficiency of the code coverage rate is further improved.
Further, according to the size relation between the current code coverage rate and the historical code coverage rate, updating the data screening rule, so that the purpose of generating more test cases with higher coverage rate can be achieved, and the effectiveness of generating the test cases is improved; according to the data screening rule, target data is acquired from a data source through an asynchronous message or a data interface, so that input and expected results of the test case can be acquired more conveniently, and the efficiency of generating the test case is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (11)

1. A test case generation method, comprising:
acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case;
determining target data from the data source according to the data screening rule;
determining current code coverage rate according to the target data and the historical test cases;
and under the condition that the current code coverage rate is larger than the historical code coverage rate, generating a target test case according to the target data.
2. The method as recited in claim 1, further comprising:
determining a historical test link according to the historical test case, and analyzing the historical code coverage rate and the historical test link to obtain an uncovered code;
and determining the data screening rule according to the uncovered codes.
3. The method of claim 1, wherein the step of determining the position of the substrate comprises,
and updating the data screening rule under the condition that the current code coverage rate is not greater than the historical code coverage rate, and re-determining the target data according to the updated data screening rule.
4. The method of claim 1, wherein said determining target data from said data sources according to said data screening rules comprises:
obtaining basic data from the data source through asynchronous messages, and determining the target data from the basic data according to the data screening rules;
and/or the number of the groups of groups,
and generating a query request according to the data screening rule, transmitting the query request to the data source through a data interface of the data source, and receiving the target data returned by the data source according to the query request.
5. The method of claim 1, wherein said determining a current code coverage based on said target data and said historical test cases comprises:
and sending the target data and the history test cases to the tested system through an operation interface of the tested system, and acquiring the current code coverage rate returned by a code coverage rate tool in the tested system.
6. The method of claim 1, wherein the target data includes target request data and target return results, and wherein generating the target test case from the target data comprises:
and taking the target request data as input of the target test case, and taking the target return result as an expected result of the target test case.
7. The method of claim 6, further comprising, after the generating the target test case:
testing the tested system according to the target test case;
and generating and displaying a visual page according to the test result and the expected result.
8. A method according to claim 3, further comprising:
updating the data filtering rule into a data filtering rule to filter the screened target data when the target data is redetermined.
9. A test case generating apparatus, comprising: the device comprises an acquisition module, a determination module and a generation module; wherein,,
the acquisition module is used for acquiring a data screening request; the data screening request indicates a data source and a data screening rule, and the data screening rule is obtained by analyzing according to a historical test case and a historical code coverage rate corresponding to the historical test case;
the determining module is used for determining target data from the data source according to the data screening rule; determining current code coverage rate according to the target data and the historical test cases;
the generating module is used for generating a target test case according to the target data under the condition that the current code coverage rate is larger than the historical code coverage rate.
10. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
when executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-8.
11. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-8.
CN202310258447.8A 2023-03-16 2023-03-16 Test case generation method and device Pending CN116627794A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310258447.8A CN116627794A (en) 2023-03-16 2023-03-16 Test case generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310258447.8A CN116627794A (en) 2023-03-16 2023-03-16 Test case generation method and device

Publications (1)

Publication Number Publication Date
CN116627794A true CN116627794A (en) 2023-08-22

Family

ID=87620030

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310258447.8A Pending CN116627794A (en) 2023-03-16 2023-03-16 Test case generation method and device

Country Status (1)

Country Link
CN (1) CN116627794A (en)

Similar Documents

Publication Publication Date Title
US20230281012A1 (en) Systems and methods for automating and monitoring software development operations
CN111679990B (en) Test data generation method and device, readable medium and electronic equipment
CN110737726B (en) Method and device for determining test data of interface to be tested
CN110858172A (en) Automatic test code generation method and device
CN111221727B (en) Test method, test device, electronic equipment and computer readable medium
CN111435380B (en) Page cross-domain interaction method, system, device and storage device
CN110866031B (en) Database access path optimization method and device, computing equipment and medium
CN113760722A (en) Test system and test method
CN114281663A (en) Test processing method, test processing device, electronic equipment and storage medium
CN115996179A (en) Service node testing method and device, readable medium and electronic equipment
CN111813685B (en) Automatic test method and device
CN114465919B (en) Network service testing method, system, electronic equipment and storage medium
CN115964302A (en) Data testing method and device
CN111488268A (en) Dispatching method and dispatching device for automatic test
CN113468053B (en) Application system testing method and device
CN116627794A (en) Test case generation method and device
CN115454956A (en) Log generation method and device, electronic equipment and storage medium
CN110806967A (en) Unit testing method and device
CN113011858A (en) Audit project configuration and execution method and device
CN113282455A (en) Monitoring processing method and device
CN113238919A (en) Statistical method, device and system for user access number
CN111178014A (en) Method and device for processing business process
CN112579428A (en) Interface testing method and device, electronic equipment and storage medium
CN112749204A (en) Method and device for reading data
CN115309612B (en) Method and device for monitoring data

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