Automatic testing method and system
By automatically generating and optimizing test cases and scripts through preset generation models, it solves the problems of low efficiency and high cost caused by manual writing in software testing, realizes automated test design and maintenance, and improves test coverage and stability.
Patent Information
- Application Number
- CN202410689176.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-10-08
AI Technical Summary
During the software testing process, as product functions and requirements continue to change, existing technology relies on manual writing of test cases and scripts, resulting in low testing efficiency and high cost, and the test design is not standardized enough to automatically parse product requirements documents and cannot be automated. Maintain and update test designs.
Use a preset generation model to automatically generate test cases and test scripts based on product requirement documents, parse the requirement documents through natural language processing, generate corresponding test points and scripts, and perform iterative optimization during the testing process to achieve the construction and maintenance of automated testing systems. .
It greatly saves labor and time costs, realizes the automation of test design and execution, reduces manual intervention, improves test coverage and script stability, and can automatically maintain and update test designs as requirements change.
Smart Images

Figure CN118747148A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the technical field of software testing, and in particular to an automated testing method and system. Background Art
[0002] In the field of software testing, the requirements (i.e., the functions that the product is expected to achieve) of software products (hereinafter referred to as products) are usually relatively simple in the early stages of design, so the test design based on the requirements is relatively simple and does not require a lot of manpower and time. However, as the product is continuously iterated and updated, the functions and requirements of the product will continue to increase and change, and the test cases and test scripts need to be constantly updated, which is a huge challenge for both the project progress and the testers themselves.
[0003] At present, product requirement documents are mainly written manually by users (such as product developers), and professionals manually write test cases and test scripts for debugging. The entire testing process is inefficient, time-consuming and labor-intensive, and the coverage of test design is easily affected by factors such as the personal ability of the writer, and is not standardized enough. Summary of the invention
[0004] An object of an embodiment of the present invention is to provide an improved automated testing method and system.
[0005] Therefore, an embodiment of the present invention provides an automated testing method, comprising: receiving a product requirement document, wherein the product requirement document includes requirement information under at least one test scenario; inputting the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate test cases and test scripts, and the at least one test case and the at least one test script correspond one-to-one; executing the at least one test script to obtain a corresponding test result.
[0006] Compared with the existing software product testing which still relies on manual implementation, this implementation scheme is based on a preset generation model and automatically generates test cases and test scripts according to the input product requirement documents. As a result, the entire test design process and the actual testing phase require almost no manual intervention, greatly saving manpower and time costs.
[0007] Optionally, the automated testing method further includes: for each test scenario, receiving the accuracy verification results of one or more qualified test cases in the test scenario, wherein the one or more qualified test cases are extracted from the test cases whose test results are consistent with the expected effect in at least one test case in the test scenario; and feeding back the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model. Thus, a verification link is set after the test is completed, and the preset generation model automatically performs iterative optimization and intensive training according to the verification results, which is conducive to making the test case coverage more comprehensive and the test script more stable.
[0008] Optionally, the accuracy verification result includes accurate and inaccurate, and the feedback of the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model includes: positively feeding back the qualified test cases with accurate accuracy verification results to the preset generation model, and negatively feeding back the qualified test cases with inaccurate accuracy verification results to the preset generation model; in response to the existence of qualified test cases with inaccurate accuracy verification results, inputting new training data in the test scenario to the preset generation model for enhanced training. Thus, the automatic iterative optimization of the preset generation model is achieved through positive and negative feedback, so that the test case coverage is more comprehensive and the test script is more stable. Specifically, for the test cases that pass the random inspection, the proportion of the corresponding part of the algorithm in the preset generation model is strengthened to optimize the preset generation model to a better model. Further, for the test cases that fail the random inspection, more new data in the test scenario to which the test case belongs is fed to the preset generation model to enhance the training of the preset generation model.
[0009] Optionally, the preset generation model parses the product requirement document based on natural language processing to determine the test points. For each test point, the preset generation model generates a test case and a corresponding test script based on at least one field in the product requirement document combined with a preset test method set. Thus, test cases and test scripts are automatically generated based on the preset generation model, saving manpower and time costs.
[0010] Optionally, receiving the product requirement document includes: displaying a preset template on a target page, wherein the preset template includes at least one field; and receiving input information for the at least one field to generate the product requirement document. Thus, by defining and providing a preset template, the standardization of the product requirement document is achieved, so that the preset generation model automatically parses the product requirement document, which is helpful for the construction of an automated testing system.
[0011] Optionally, the at least one field includes at least one of the following: primary classification, secondary classification, requirement number, requirement name, description, method name, sending parameter format, and response parameter format. Reasonable field design and classification division help the preset generation model to accurately identify the data filled in by the user under each field, so as to automatically and correctly generate test cases and test scripts that meet the requirements.
[0012] Optionally, executing the at least one test script and obtaining the corresponding test result includes: in the process of executing the at least one test script, skipping the test cases that failed the test until the at least one test script is traversed; for the test cases that failed the test, inputting the product requirement document into the preset generation model to regenerate the test cases and the corresponding test scripts; in response to the regenerated test cases being inconsistent with the test cases that failed the test, replacing the test cases that failed the test with the regenerated test cases, and executing the test scripts corresponding to the regenerated test cases to obtain the corresponding test results. Thus, the places where blockages are encountered during the debugging process are skipped first to avoid affecting the test efficiency, and further, the test cases that failed the test are automatically and preferentially tried to eliminate the blockages to optimize the test effect.
[0013] Optionally, the automated testing method further includes: regularly detecting whether the content of the product requirement document has changed; in response to detecting a change point, determining whether to update the test case based on the degree of impact of the content difference before and after the change associated with the change point on the test case; in response to determining to update the test case, at least inputting the changed content into the preset generation model to obtain an updated test case and a corresponding test script. In this way, the test design is automatically maintained and updated as the requirements change, reducing or even eliminating the need for manual intervention, greatly reducing labor costs.
[0014] Optionally, the expected effect in the test case is presented in the form of an image, and the method further includes: for each test script, displaying the test result of executing the test script in a preset test area and photographing it to obtain a first image; calculating the similarity between the first image and the second image in the test case corresponding to the test script; and determining the consistency between the test result and the expected effect based on the similarity. Thus, when the test result needs to check the physical state, the test can be completed fully automatically without manual intervention, thereby reducing labor costs.
[0015] Therefore, an embodiment of the present invention also provides an automated testing system, comprising: an interface module, used to receive a product requirement document, wherein the product requirement document includes requirement information under at least one test scenario; a test design module, communicating with the interface module, the test design module receives and inputs the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate test cases and test scripts, and the at least one test case and the at least one test script correspond one to one; a test execution module, communicating with the test design module, the test execution module executes the at least one test script to obtain a corresponding test result.
[0016] By adopting this implementation plan, an automated testing system is constructed to enable users to input product requirement documents through the interface module, and then automatically generate test cases and test scripts without human intervention. As a result, the entire test design process and the actual testing phase require almost no human intervention, greatly saving manpower and time costs.
[0017] Optionally, the automated testing system further includes: a human-computer interaction module, which communicates with the interface module, and the human-computer interaction module displays a preset template on the target page, wherein the preset template includes at least one field; and receives input information for the at least one field to generate the product requirement document and send it to the interface module. Thus, the user input information is received by the human-computer interaction module, and a standardized product requirement document that can be correctly parsed by the preset generation model is generated in combination with the preset template.
[0018] Optionally, the automated testing system further includes: a human-computer interaction module, for each test scenario, the human-computer interaction module receives the accuracy verification results of one or more qualified test cases in the test scenario, the human-computer interaction module communicates with the test design module to feed back the one or more qualified test cases and their accuracy verification results to the preset generation model, so as to optimize the preset generation model, and the one or more qualified test cases are extracted from the test cases whose test results are consistent with the expected effects in at least one test case in the test scenario. Thus, in the verification link after the test is completed, the user's spot check feedback on the test results is obtained through the human-computer interaction module, and then the preset generation model is automatically iteratively optimized and strengthened based on the verification results fed back by the user, which is conducive to making the test case coverage more comprehensive and the test script more stable.
[0019] Optionally, the automated testing system further includes: a camera module for capturing a first image of a preset test area, wherein the preset test area is provided with at least one component to display the test result of executing the test script; a storage module for storing a second image, wherein the second image is used to present the expected effect of the test case corresponding to the test script; and an image recognition module for calculating the similarity between the first image and the second image to determine the consistency between the test result and the expected effect. Thus, image recognition technology is applied to the verification of test results, and the full automation of the actual test phase is realized, which greatly reduces the labor cost and time cost.
[0020] Optionally, the at least one component includes an indicator light and / or a display screen on a control panel, and the control panel is provided on the household appliance. Thus, by taking a physical image of the at least one component, the physical state of the component is presented through the image to truly and accurately reflect the test result. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 is a flow chart of an automated testing method according to an embodiment of the present invention;
[0022] 2 is a schematic diagram of a product requirement document and a test case in a typical application scenario of an embodiment of the present invention;
[0023] Figure 3 yes Figure 1 A flowchart of a specific implementation of step S103;
[0024] Figure 4 is a flow chart of another automated testing method according to an embodiment of the present invention;
[0025] Figure 5 It is a schematic diagram of the principle of an automated testing system according to an embodiment of the present invention;
[0026] In the attached figure:
[0027] 100-automated test system; 101-interface module; 102-test design module; 103-test execution module; 104-human-computer interaction module; 105-preset test area; 106-storage module; 107-image recognition module; 500-computer system; 501-storage device; 502-processor; 503-memory; 504-peripheral input / output user device; 510-display device; 511-keyboard; 512-pointing device; 513-camera module; 600-household appliances; 610-control panel; 611-indicator light; 612-display screen. DETAILED DESCRIPTION
[0028] As mentioned in the background technology, when a software product is developed, it is necessary to test various functions of the product. However, the existing test design mainly relies on manpower, which not only affects the test efficiency, wastes time and manpower costs, but is also easily interfered by subjective factors and is not standardized enough.
[0029] Specifically, with the development of big data and automatic testing, many companies in the market have applied automatic testing to test execution. However, after analysis, the inventor of this application found that the so-called automatic testing at this stage is limited to the automatic execution of test scripts by computers, which requires manual test design, manual writing of test scripts, and debugging. This leads to the following problems in existing automatic testing:
[0030] 1. The format of the product requirement document is not standardized and unified, and it is impossible to automatically parse the product requirement document.
[0031] 2. The generation of test cases still relies heavily on manual labor, which consumes a lot of manpower and time costs. In addition, due to the different technical levels of testers, the coverage of the test design will vary.
[0032] 3. Writing automated test scripts requires testers to establish the relationship between code and test design, requires testers to have a high level of business and code writing skills, and code writing takes a long time.
[0033] 4. As requirements continue to change, test designs also need to be constantly updated, and automated scripts need to be constantly maintained. The maintenance workload is large and requires testers to have a certain level of technical skills.
[0034] 5. The results of manual testing need to be checked manually. Currently, most automatic test results that require checking the physical status also rely on manual inspection and cannot be automated.
[0035] To solve the above technical problems, an embodiment of the present invention provides an automated testing method, comprising: receiving a product requirement document, wherein the product requirement document includes requirement information under at least one test scenario; inputting the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate test cases and test scripts, and the at least one test case and the at least one test script correspond one to one; executing the at least one test script to obtain a corresponding test result.
[0036] Therefore, this implementation scheme automatically generates test cases and test scripts based on the input product requirement document based on the preset generation model. As a result, the entire test design process and the actual test phase require almost no human intervention, greatly saving manpower and time costs.
[0037] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0038] Figure 1 The present invention is a flowchart of an automated testing method according to an embodiment of the present invention.
[0039] The present embodiment is applied to the field of software testing technology, and specifically relates to automatically generating test cases and test scripts according to requirements, and then automatically executing tests on household appliances running software products and obtaining and analyzing test results.
[0040] This embodiment can be executed by a terminal, a server, etc. The terminal or the server can be deployed with an automated testing system, and the automated testing system executes the method described in this embodiment when it is run. The terminal can be, for example, a computer, a processor, etc. The server can be a local server or a cloud server.
[0041] The users of this implementation scheme can be testers. Different from the prior art, users who use the automated testing method provided by this implementation scheme can still correctly and efficiently implement software testing and complete the requirements testing of various functions of the software product even if they do not have professional programming skills.
[0042] Specifically, refer to Figure 1 The automated testing method described in this embodiment may include the following steps:
[0043] Step S101, receiving a product requirement document (PRD), wherein the product requirement document includes requirement information under at least one test scenario;
[0044] Step S102, inputting the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate a test case and a test script, and the at least one test case corresponds to the at least one test script in a one-to-one manner;
[0045] Step S103, execute the at least one test script to obtain a corresponding test result.
[0046] More specifically, the PRD may be a document with a standardized structure, that is, the content and format of the PRD received in S101 meet the requirements of the preset template. For example, the PRD may be filled in and improved by the user according to the preset template and then imported from the outside with one click. For another example, the PRD may be generated by the user filling in the preset template displayed on the interactive interface.
[0047] Furthermore, the preset generation model can be pre-deployed locally on the terminal or server executing this embodiment (such as Figure 5 Alternatively, the preset generation model can be deployed in an external storage device, and the terminal or server can access the external storage device to call the preset generation model to execute the present embodiment, which is conducive to saving the hardware cost of the terminal or server and reducing the computing pressure. The external storage device can be, for example, a cloud.
[0048] Furthermore, the preset generation model can be constructed by using, for example, a machine learning algorithm, a neural network algorithm, etc. In this example, the fully automated software testing logic is implemented by using the preset generation model deployed on the terminal or server.
[0049] In a specific implementation, step S101 may include the steps of: displaying a preset template on a target page, wherein the preset template includes at least one field; and receiving input information for the at least one field to generate a PRD.
[0050] Specifically, the target page may be a page presented by a display interface of a terminal or server. For example, the terminal or server provides a "PRD generation" control in the display interface, and the user clicks the control, and the display interface jumps to the target interface to present a preset template.
[0051] Furthermore, the preset template may include at least one field, wherein each field includes a field name and a filling area for the user to input. By pre-defining the format of the preset template and the dimensions to be covered, the user can fill in specific content.
[0052] In some embodiments, the preset template can be presented in a table format, and Table 1 exemplarily shows a specific implementation of the preset template. In Table 1, the first row is the field, and the columns starting from the second row except the column where the sequence number is located are the specific values corresponding to each field that need to be filled in by the user.
[0053] Table 1 Preset templates
[0054]
[0055] Next, the meaning of each field in Table 1 is explained in detail.
[0056] "First-level classification" means the highest level classification of the requirement, such as alarm.
[0057] "Secondary classification" means the subdivision of requirements under the first-level classification into second-level classifications, such as operation alarms.
[0058] "Requirement number" indicates the smallest category of the requirement and a globally unique number identifier (unique ID of the requirement), such as GJ-0010, which corresponds to active reporting, active request for query data, obtaining statistical results, and retrieving recent data analysis in multiple categories included in the operation alarm category.
[0059] "Requirement Name" indicates the name corresponding to the requirement number, such as active query operation alarm.
[0060] "Description" means the detailed description of the minimum requirement, including but not limited to the requirement background, usage scenarios and value, etc. For example, how long does it take to query the operation alarm status from the client.
[0061] "Method Name" indicates the method name of the requirement. The test script will create a script function based on this name, such as: get_running_alarm_info.
[0062] "Sending parameter format" indicates the parameter content that the method needs to send. You need to specify the parameter name, type, range, etc., such as: {name: string 32 (English letters and numbers), type: int8 (1 represents operation alarm, all possible types are listed), start_date: datetime (start time), end_date: datetime (end time)}, user login requirements, specify the user name length, type, etc., and generate test cases according to the specified format.
[0063] "Response parameter format" indicates the parameter content that the method theoretically receives. You need to specify the response code, content, etc., such as: {return_code: int8 (1 means normal, and all possible types are listed), content: string256 (response content, including English, numbers, punctuation marks, etc.), timestamp: datetime (timestamp)}, the prompt method for successful login needs to be specified, which is also part of the test case and corresponds to the expected result.
[0064] Furthermore, at least one of the fields listed in the preset template may be partially required fields and partially optional fields. For example, the method name field is an optional field, and the user's failure to fill in the field does not affect the automatic generation of the PRD and the subsequent generation of test scripts and test cases. In actual applications, the optional fields may be set for the purpose of facilitating users to review and understand the PRD.
[0065] When displaying a preset template, the target page can add an identifier after each field to indicate whether the field is required or optional.
[0066] Furthermore, a row in Table 1 can generate multiple test cases. A single test case contains the actual test data.
[0067] For example, the information filled in a row in Table 1 includes: the first-level classification is "Login Successful", the description is "You can successfully log in after entering the user name and verification code", the sending parameter format includes "user name, verification code length, Chinese and English", and the response parameter format includes "failure timestamp prompt, login success prompt". Based on this, when the preset generation model generates test cases, the defined parameter format types are exhaustively combined, and the content corresponding to the specific format can be equivalent to 1-2, and different test cases corresponding to successful login are generated.
[0068] Therefore, by defining and providing preset templates, the standardization of product requirement documents is achieved, so that the preset generation model can automatically parse the product requirement documents, which is helpful for the construction of an automated testing system. Furthermore, reasonable field design and classification division help the preset generation model to accurately identify the data filled in by users under each field, so as to automatically and correctly generate test cases and test scripts that meet the requirements.
[0069] In one specific implementation, the preset generation model can parse the standardized PRD based on natural language processing to automatically analyze and determine the test points. For each test point, the preset generation model generates a test case and a corresponding test script based on at least one field in the PRD combined with a preset test method set.
[0070] Specifically, a preset generation model is obtained through pre-training and continuous iterative training using the present implementation scheme. The preset generation model can accurately identify corresponding data and classify the required content.
[0071] Furthermore, a test point corresponds to a test case and a test script corresponding to the test case. For example, a scenario in which a test user successfully logs in can correspond to multiple test points, that is, multiple test cases (such as different combinations of user names).
[0072] For example, the preset generation model can globally cover the first-level classification and second-level classification in the PRD as traversal conditions. The test cases and test scripts generated by the preset generation model are also classified based on the first-level classification and second-level classification to facilitate subsequent optimization and maintenance of the test set; the first-level classification-second-level classification-requirement number is used as the classification condition of the test case; the description content, parameter format, and requirement number are used as comments for the test script for users to review after the subsequent results are exported; the parameter name is used as the method name of the test script; the classification of the class of the test script is constructed according to the first-level classification and second-level classification, and so on.
[0073] Furthermore, a preset test method set is pre-built, which may include commonly used test methods, such as decision tables, equivalence classes, etc. The preset test method set may be stored locally in the terminal or server, or in an external storage device.
[0074] Furthermore, the preset generation model can automatically output test cases according to the parameter format (including the sending parameter format and / or the response parameter format) and the commonly used test methods. For example, if the parameter format type is string32, test cases and test scripts containing normal values (normal length, normal type, etc.), boundary values (including inside the boundary, above the boundary, outside the boundary, etc.), and abnormal values (including abnormal type, abnormal length, null value, etc.) can be automatically generated.
[0075] Table 2 exemplarily shows a possible presentation format of the test cases output by the preset generation model. In Table 2, the first row is the dimensions included in the test case, and the columns starting from the second row except the column where the sequence number is located are the values corresponding to each dimension.
[0076] Table 2 Test cases
[0077]
[0078]
[0079] Next, the meaning of each dimension in Table 2 is explained in detail.
[0080] The "first level classification" corresponds to the first level classification in the PRD (as shown in Table 1), such as: alarm.
[0081] "Secondary classification" corresponds to the secondary classification in PRD (as shown in Table 1), such as: operation alarm.
[0082] "Use Case Title" refers to the title of the test case generated by the preset generation model after automatic processing based on PRD, such as: Operation Alarm-System Operation Abnormal Alarm Trigger Test. For example, parsing PRD based on natural language processing is intended to reflect test points, such as login success with capital letters + special symbols.
[0083] "Use case steps" refer to the test case steps that are decomposed according to the preset generation model after PRD processing, such as: Step 1: Simulate system operation abnormality; Step 2: Check whether the operation abnormality alarm information is received; Step 3: Check whether the system operation alarm light is on normally.
[0084] "Expected results" indicate the expected results of the corresponding use case steps, such as: 1. Receive abnormal alarm information; 2. The operation alarm light turns red.
[0085] "Script Name" corresponds to the name of the automation script of the test case, such as: get_running_alarm_info.
[0086] Furthermore, in Table 2, one row corresponds to one test case. Accordingly, the serial number in Table 2 is used to identify the test case.
[0087] Furthermore, in addition to using the preset generation model to generate test cases, the preset generation model is also used to automatically write the method name, sending parameter format, response parameter format, etc. in the PRD into a test script. The directory structure of the test script will also be automatically generated according to the classification structure of PRD, including test results result, common methods common, common parameters config, etc.
[0088] Generally speaking, test cases tend to be language descriptions, that is, they use text language to describe the specific content that needs to be executed in each step of the testing process; test scripts tend to be programming languages, that is, they convert test cases into content that computers can recognize.
[0089] Furthermore, each test case corresponds to a test script, with the script name and serial number corresponding one to one.
[0090] As a result, test cases and test scripts are automatically generated based on the preset generation model. Except for the initial input of PRD, no manual intervention is required throughout the process, saving manpower and time costs.
[0091] In a typical application scenario, taking the user login scenario as an example, the PRD received in step S101 can be as shown in Figure 2(a). By inputting the PRD into the preset generation model, the automatic generation result of the test case shown in Figure 2(b) can be obtained. It should be pointed out that Figures 2(a) and 2(b) only capture part of the content of the output results of the PRD and the preset generation model for exemplary display. For example, Figure 2(b) exemplarily shows the specific content of a test case in the system login scenario of sequence number 1 in Figure 2(a).
[0092] In a specific implementation, the automated testing system can provide an interface function for users to export the test cases (and / or test scripts) output by the preset generation model, so as to facilitate the review and archiving of the test design and provide support for the optimization of the preset generation model in the next step. For example, it can support the export in word, excel, pictures, mind maps, etc.
[0093] In one specific implementation, reference Figure 3 Step S103 may specifically include the following steps:
[0094] Step S1031, in the process of executing the at least one test script, skipping the test cases that fail the test until the at least one test script is traversed.
[0095] Specifically, after the test script is written and the file directory structure is generated, the automated testing system can automatically initiate the debugging process. It can test all the test scripts generated by the preset generation model based on the input PRD, or perform selective testing according to the user's selected classification (primary classification or secondary classification). During the debugging process, any blocked areas will be skipped and the faults (bugs) will be recorded in the log. After all scripts are debugged, a test report will be generated and output, which the user can view through the browser.
[0096] For example, when executing a test script, it is usually divided into several parts: preconditions (what conditions need to be met to execute the test case corresponding to this test script, such as the user login interface is the prerequisite for user login), execution process, and checking process. If any of these parts is abnormal, the execution of this test script is considered blocked.
[0097] In some embodiments, fault-tolerant measures may be considered, that is, a certain number of retries may be set. For any test script, if blocking occurs after repeated execution for n times, the test case corresponding to the test script is determined to have failed, where n is a positive integer.
[0098] In a specific implementation, continue to refer to Figure 3 , step S103 may further include the following steps:
[0099] Step S1032: For test cases that fail the test, the product requirement document is input into the preset generation model to regenerate the test cases and corresponding test scripts.
[0100] Step S1033, in response to the regenerated test case being inconsistent with the test case that failed the test, the regenerated test case replaces the test case that failed the test, and executes the test script corresponding to the regenerated test case to obtain the corresponding test result.
[0101] Step S1034: In response to the regenerated test case being consistent with the test case that failed the test, a prompt message is issued.
[0102] Specifically, after all debugging is completed, the automated test system will optimize the failed parts and automatically check the differences between the PRD and the test script. For example, the same PRD is input using the preset generation model to regenerate the test script and test case, and the differences in content between the regenerated test case and the original test case that failed the test are compared.
[0103] Furthermore, if the check finds any inconsistencies, the test script corresponding to the regenerated test case is executed and debugged again. If the check finds that it is consistent with the requirements, an alarm will be issued to prompt the tester to complete the test and check the test points that failed the test in time.
[0104] In some embodiments, the automated testing system supports sending prompt information in the form of email push and mobile phone text message push.
[0105] Therefore, the blocked areas encountered during the debugging process are skipped first to avoid affecting the test efficiency. Further, the test cases that fail the test are automatically tried to eliminate the blockage to optimize the test effect.
[0106] In a specific implementation, the automated testing method described in this embodiment may also include the steps of: regularly detecting whether the content of the PRD has changed; in response to detecting a change point, determining whether to update the test case based on the degree of impact of the content difference before and after the change associated with the change point on the test case; in response to determining to update the test case, at least inputting the changed content into the preset generation model to obtain an updated test case and a corresponding test script.
[0107] Specifically, the automated test system can periodically check whether the PRD has changed according to the configuration time in the configuration file. The configuration file can be set by the automated test system for the user to configure the period of periodic checking of the PRD. For example, the PRD content can be checked once a week to see if it has changed.
[0108] Furthermore, the PRD that has been input into the preset generation model can be stored locally in the terminal or server, and the user can subsequently update the specific content in the PRD as needed. For ease of expression, the PRD that originally inputs the preset generation model is recorded as PRD-A, and the PRD that has been updated subsequently is recorded as PRD-B. The automated testing system can first check whether the file version of the locally stored PRD and the time of the most recent update have changed compared to the last check. If there is a change, compare the text content of PRD-A and the text content of PRD-B to see if there is a change, such as the addition / deletion of the number of lines, the update of the content of the value corresponding to one or field in the original line, etc.
[0109] Furthermore, if the detection shows that the PRD has been updated, the automated testing system will automatically identify the change points and automatically determine whether the test cases and test scripts need to be updated. If the judgment result shows that changes are required, the test will be started after the automatic update, and the test results and update records will be automatically output and saved.
[0110] For example, assuming that the detection shows that the requirement number of a requirement in the PRD has changed, and the others have not changed, then the preset generation model will not generate a new round of test cases and test scripts again, but will only modify the numbers in the test cases and test scripts (for example, the requirement number) accordingly.
[0111] For another example, suppose it is detected that the content of a certain requirement in the PRD has changed, but the general idea and details remain unchanged, such as: the old version is described as: "Ordinary users can successfully log in by entering their username, password, and mobile phone number, clicking Send verification code, filling in the received verification code, and clicking the Login button." The new version is described as: "Ordinary users can successfully log in by entering their username, password, and mobile phone number, checking that each format is correct, clicking Send verification code, filling in the received verification code, and clicking the Login button." Since the change is that the description field adds the description "after checking that each format is correct", which has no essential impact on the overall testing process, the preset generation model will not generate a new round of test cases and test scripts after parsing.
[0112] For another example, if the content of a requirement changes significantly, the preset generation model will regenerate the test case and test script corresponding to the requirement after parsing. For example, the old version is described as: "Ordinary users can successfully log in by entering their username, password, and mobile phone number, clicking to send a verification code, filling in the received verification code, and clicking the login button." The new version is described as: "Ordinary users can successfully log in by entering their username and password and clicking the login button." In response to detecting this change point, the test case number corresponding to this requirement is YL-DL-YH-001, and the script name is YL-DL-YH-001. Both will be updated to remove the mobile phone number and verification code parts.
[0113] For another example, if a requirement is deleted, the preset generation model will delete the corresponding test cases and test scripts after parsing.
[0114] As a result, the test design can be automatically maintained and updated as requirements change, reducing or even eliminating human intervention, greatly reducing labor costs.
[0115] Figure 4 The flowchart of another automated testing method according to an embodiment of the present invention is as follows. The another automated testing method may include Figure 1 Steps S101 to S103 shown in FIG. 1 may further include steps S104 and S105. Figure 1 The different contents in are explained.
[0116] Step S104, for each test scenario, receiving accuracy verification results of one or more qualified test cases in the test scenario, wherein the one or more qualified test cases are extracted from test cases whose test results are consistent with expected effects in at least one test case in the test scenario;
[0117] Step S105, feeding back the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model.
[0118] Specifically, the accuracy check result may include accurate (also known as true) and inaccurate (also known as false). The test case with a correct accuracy check result is positively fed back to the preset generation model, and the test case with an incorrect accuracy check result is negatively fed back to the preset generation model.
[0119] Further, after step S103, all the test cases that have passed the test can be displayed on the display interface of the terminal or server. The user can extract a part of them for manual inspection and input the inspection results into the display interface. For example, a label column can be set for each test case row, and the user can check the accurate mark or inaccurate mark in the label column to indicate the accuracy verification result of the test case.
[0120] For example, in step S104, the user can write a test case based on the PRD, and compare it with the test case corresponding to the same requirement output by the preset generation model presented on the display interface, and then feedback the accuracy verification result in the label bar of the test case in that row.
[0121] In some embodiments, step S105 may include: positively feeding back to the preset generation model the qualified test cases whose accuracy verification results are accurate among the one or more qualified test cases, and negatively feeding back to the preset generation model the qualified test cases whose accuracy verification results are inaccurate; in response to the existence of qualified test cases whose accuracy verification results are inaccurate, inputting new training data under the test scenario into the preset generation model for reinforcement training.
[0122] Specifically, the "new" in the new training data refers to data that has not been fed to the preset generation model before. The new training data may include a new PRD and the corresponding test cases and test scripts in the test scenario, wherein the test cases and test scripts may be manually written. Therefore, as long as there are test cases that fail in the random inspection, more data is fed to the scenarios to which the failed test cases belong to retrain the preset generation model.
[0123] Furthermore, the preset generation model can be used to optimize the test of the scenario using machine learning methods. The initial preset generation model Ma is trained based on the original data set (the training data fed in the model training phase, including PRD, test cases written based on PRD, and corresponding test scripts). After each subsequent automatic test is completed, the tester can choose to conduct a spot check of the test content, such as a manual test spot check of a single test case j for test scenario i. If the test passes, the preset generation model Ma will strengthen the proportion of this part of the algorithm and optimize it to a better model. If the manual test in the test scenario fails, the preset generation model Ma will conduct intensive training on all test cases in the scenario i, that is, by feeding new training data in the scenario i, the performance of the preset generation model Ma in the scenario i will be strengthened.
[0124] Assume that the preset generation model outputs prediction results (300 test cases) for scenario i based on parameters A=0.9, B=0.75, and C=0.86. After manual inspection, 200 cases are qualified and 100 cases are unqualified. The accuracy verification results are input into the preset generation model. The preset generation model adjusts the parameters of scenario i to A=0.91, B=0.8, and C remains unchanged through positive and negative feedback. After adjustment, the prediction results are output (300 cases, 270 of which are qualified after manual inspection).
[0125] In other words, the improvement range (also called coverage) of the optimized preset generation model is Mai = Mai1 + Mai2 + ... + Main, where n is the number of test cases in scenario i initially fed to the preset generation model Ma, 1≤i≤n.
[0126] After optimization for multiple different scenarios, the overall improvement range of the preset generation model Mb is Mb = Ma1 + Ma2 + ... + Maj + ... + Mam. That is:
[0127]
[0128] Where m is the total number of scenes, 1≤j≤m.
[0129] Therefore, a verification step is set after the test is completed, and the preset generation model automatically performs iterative optimization and intensive training according to the verification results, which is conducive to making the test case coverage more comprehensive and the test script more stable. Specifically, the automatic iterative optimization of the preset generation model is achieved through positive and negative feedback, so that the test case coverage is more comprehensive and the test script is more stable. Furthermore, for test cases that pass the random inspection, the proportion of the corresponding part of the algorithm in the preset generation model is strengthened to optimize the preset generation model into a better model. Furthermore, for test cases that fail the random inspection, more new data in the test scenario to which the test case belongs is fed to the preset generation model to perform intensive training on the preset generation model.
[0130] In a specific implementation, the expected effect in the test case can be presented in the form of an image. Accordingly, the automated testing method described in this embodiment may also include: for each test script, displaying and photographing the test result of executing the test script in a preset test area to obtain a first image; calculating the similarity between the first image and the second image in the test case corresponding to the test script; and determining the consistency between the test result and the expected effect based on the similarity.
[0131] Specifically, the test results obtained by the automated testing system through the execution of the test script support image recognition comparison, that is, the expected results are saved in the automated testing system through photos. In the result verification phase of the test script, the image recognition model pre-deployed in the automated testing system is used to automatically take photos of the real-time test results in the test area and compare them with the expected results in the form of pre-stored photos.
[0132] In some embodiments, the expected results can be presented by software simulation and screenshots can be taken, and then image recognition can be performed with the image presenting the real-time test results in the test area to compare the differences between the two.
[0133] In a variation, the expected result may be a standard test result actually presented in the test area, and solidified and stored by photographing or the like. The automated testing system generates a test script by executing the automated testing method described in this embodiment and executes it once in the test area, photographs the real-time test results presented by the test script output by the execution model in the test area, and compares them with the pre-stored photos.
[0134] Taking the control panel of a refrigerator as an example, the control panel can be provided with indicator lights and an LCD screen. Assuming that the expected result is that multiple indicator lights in the test area need to display red and green in a certain order, and the LCD screen needs to display different letters and numbers, the test device is placed in a dark room to ensure that there is no interference from other light sources. The image recognition model uses a camera to divide the test area. The indicator light area is identified by the color of the lights in the actual result and expected result pictures. The LCD screen area uses an open text recognition model to perform text recognition comparison between the actual result and the expected result.
[0135] Therefore, when the test results require checking the physical status, the test can be completed fully automatically without human intervention, thus reducing labor costs.
[0136] In a specific implementation, after all tests of the automated testing system are completed, message push is supported. For example, the test personnel can be notified through emails, mobile phone text messages, etc., and the test results can be exported in different formats, such as word, excel, pictures, html, etc., and analyzed and displayed in multiple dimensions through charts.
[0137] From the above, this implementation scheme is adopted to automatically generate test cases and test scripts based on the preset generation model according to the input product requirement document. As a result, the entire test design process and the actual test phase require almost no human intervention, greatly saving manpower and time costs.
[0138] Figure 5 1 is a schematic diagram of the principle of an automated testing system 100 according to an embodiment of the present invention. The automated testing system 100 described in this embodiment can be used to perform the above Figures 1 to 4 The automated testing method described in the illustrated embodiment.
[0139] Specifically, the automated testing system 100 may be invoked and executed by a computer system 500 installed on a terminal or a server. Figure 5 The computer system 500 includes a processor 502 and a memory 503. The memory 503 stores a computer program that can be run on the processor 502. Further, the computer system 500 may also include a storage device 501. The storage device 501 may store the automated test system 100 and the preset generation model. The processor 502 calls the automated test system 100 to execute the above Figures 1 to 4 The steps of the method described in the illustrated embodiment.
[0140] Further, the computer system 500 may be coupled to peripheral input / output (I / O) user devices 504, such as a display device 510, a keyboard 511, a pointer device 512, and a camera module 513. The pointer device 512 may be, for example, a mouse. The camera module 513 may be, for example, a camera.
[0141] Further reference Figure 5The automated testing system 100 described in this embodiment may include: an interface module 101, used to receive a PRD, wherein the PRD includes requirement information under at least one test scenario; a test design module 102, communicating with the interface module 101, the test design module 102 receives and inputs the PRD into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input PRD to generate a test case and a test script, and the at least one test case corresponds to the at least one test script in a one-to-one manner; a test execution module 103, communicating with the test design module 102, the test execution module 103 executes the at least one test script to obtain a corresponding test result.
[0142] In a specific implementation, continue to refer to Figure 5 The automated testing system 100 may further include: a human-computer interaction module 104, which communicates with the interface module 101, and the human-computer interaction module 104 displays a preset template on the target page, wherein the preset template includes at least one field; receives input information for the at least one field to generate a PRD and sends it to the interface module 101.
[0143] Specifically, the human-computer interaction module 104 may include a display device 510 , a keyboard 511 , a pointer device 512 , and the like.
[0144] For example, the preset template is shown to the user by presenting the target page on the display device 510. Further, the PRD is generated by receiving the user's input information on the preset template through the keyboard 511, the pointer device 512, etc.
[0145] Thus, the user input information is received through the human-computer interaction module 104, and a standardized PRD that can be correctly parsed by the preset generation model is generated in combination with the preset template.
[0146] In one specific implementation, for each test scenario, the human-computer interaction module 104 receives the accuracy verification results of one or more qualified test cases under the test scenario, and communicates with the test design module 102 to feed back the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model.
[0147] Specifically, the one or more qualified test cases are extracted from the test cases whose test results are consistent with the expected effect (i.e., the test cases that passed the test) in at least one test case under the test scenario. For example, all the test cases that passed the test can be displayed through the display device 510, and the user can select the test cases for spot check and input the corresponding accuracy verification results through the peripheral input / output user device 504 such as the keyboard 511 and the pointer device 512.
[0148] Further, after the accuracy check result is positively and negatively fed back to the preset generation model and the optimization training of the model is completed, the updated preset generation model can be stored in the storage device 501 and replace the originally stored preset generation model. Accordingly, the next time the processor 502 calls the automated testing system 100 to execute the automated testing method described in this embodiment, the preset generation model called from the storage device 501 is the updated preset generation model.
[0149] Therefore, in the verification phase after the test is completed, the user's spot check feedback on the test results is obtained through the human-computer interaction module 104, and then the preset generation model is automatically iteratively optimized and strengthened based on the verification results fed back by the user, which is conducive to making the test case coverage more comprehensive and the test script more stable.
[0150] In a specific implementation, the camera module 513 can be used to capture a first image of a preset test area 105 , where at least one component is provided in the preset test area to display the test result of executing the test script.
[0151] Specifically, the test execution module 103 can communicate with at least one component to present the test result through the at least one component. Figure 5 The test cases automatically generated by the automated testing system 100 are for the software product installed in the household appliance 600. When the control panel 610 of the household appliance 600 runs the computer program of the software product, it can realize functions such as receiving user input instructions, displaying the operating parameters of the household appliance 600 to the user, and adjusting the operating parameters of the household appliance 600 according to the user input instructions.
[0152] Furthermore, in order to test whether the various functions of the home appliance 600 can be correctly implemented after the software is installed in the home appliance 600, the automated testing system 100 automatically generates test cases and corresponding test scripts according to the PRD associated with the software product, and determines the preset test area 105 as the area where the control panel 610 of the home appliance 600 is located. Furthermore, when the test execution module 103 executes the test script, it controls the various components of the home appliance 600 (for example, the processor of the control panel 610) to run according to the test script and presents the test results on the control panel 610.
[0153] Further, at least one component may include an indicator light 611 and / or a display screen 612 on the control panel 610. Figure 5 , a plurality of indicator lights 611 may be arranged side by side on the control panel 610. Thus, by taking a physical image of at least one component, the physical state of the component is presented through the image to truly and accurately reflect the test result.
[0154] Furthermore, the camera module 513 may be aligned with the control panel 610 to ensure that the shooting range at least covers the preset test area 105 .
[0155] In some embodiments, the camera module 513 may periodically capture images of the preset test area 105. For example, during the execution of the test script by the test execution module 103, the camera module 513 captures an image of the preset test area 105 every x seconds, where x may be a value from 2 to 10 seconds.
[0156] In some embodiments, in response to detecting a change in the display content of the preset test area 105, such as a change in the color of the indicator light 611, a change in the number of on / off indicator lights 611, a change in the content displayed on the display screen 612, etc., the camera module 513 captures an image of the preset test area 105. Thus, the power consumption of the camera module 513 can be reduced.
[0157] In a specific implementation, the automated testing system 100 may further include a storage module 106 for storing a second image, where the second image is used to present an expected effect of the test case corresponding to the test script.
[0158] Taking the test script shown in FIG2(b) as an example, the expected result includes multiple stages, and the automated testing system 100 can store the content that should be displayed on the control panel 610 at each stage in the form of an image as a corresponding second image. For example, the expected effect is "the verification code is sent successfully, the send button is grayed out and the countdown begins", and in the control panel 610 presented by the corresponding second image, the indicator light 611 corresponding to the send button is grayed out and the countdown is displayed on the display screen 612. For another example, the expected effect is "login is successful, the page jumps to the user's homepage, and menus such as password modification and system exit are displayed", and in the control panel 610 presented by the corresponding second image, the display screen 612 displays menus such as password modification and system exit.
[0159] Furthermore, the automated testing system 100 may further include an image recognition module 107 for calculating the similarity between the first image and the second image to determine the consistency between the test result and the expected effect.
[0160] Still taking the expected effect of "successfully sending the verification code, the send button is grayed out and enters the countdown" as an example, assuming that when the script execution module 103 executes the corresponding content of the test script, the test result presented on the control panel 610 is: the indicator light 611 corresponding to the send button is highlighted and the countdown is displayed on the display screen 612, and the presentation screen is captured by the camera module 513 and saved as the first image. Further, the test execution module 103 can also obtain the second image corresponding to this stage from the storage module 106.
[0161] In response to receiving the first image and the second image, the image recognition module 107 can call the image recognition model to detect the difference between the two images. In response to the detection, it is found that although the display content of the display screen 612 is consistent in the first image and the second image, the state of the indicator light 611 is inconsistent, and it can be determined that the test result is inconsistent with the expected effect. The image recognition module 107 feeds back the inconsistent detection result to the test execution module 103, and the test execution module 104 determines that the test case corresponding to the test script has not passed.
[0162] Therefore, image recognition technology is applied to the verification of test results, achieving full automation of the actual testing phase, greatly reducing labor and time costs.
[0163] In some embodiments, the storage device 501 and the memory 503 may be integrated into one.
[0164] In some embodiments, the storage device 501 and the memory 503 may be two independent modules. In this example, the computer program stored in the memory 503 is used to implement the basic functions of the computer system 500, such as functions other than automated testing.
[0165] Similarly, the storage module 106 and the storage device 501 may be integrated into one, or the two may be independent modules.
[0166] As described above, by adopting this implementation scheme, by constructing an automated testing system, after the user inputs the product requirement document through the interface module 101, test cases and test scripts can be automatically generated without human intervention. As a result, the entire test design process and the actual test phase require almost no human intervention, greatly saving manpower and time costs.
[0167] Although specific embodiments have been described above, these embodiments are not intended to limit the scope of the present disclosure, even when only a single embodiment is described with respect to specific features. The feature examples provided in this disclosure are intended to be illustrative rather than limiting, unless otherwise stated. In specific implementations, the technical features of one or more dependent claims may be combined with the technical features of the independent claims, and the technical features from the corresponding independent claims may be combined in any appropriate manner rather than just by the specific combinations listed in the claims.
[0168] Although the present invention is disclosed as above, the present invention is not limited thereto. Any person skilled in the art can make various changes and modifications without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.
Claims
1. An automated testing method, characterized in that: include: Receiving a product requirement document, wherein the product requirement document includes requirement information under at least one test scenario; Input the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate test cases and test scripts, and the at least one test case corresponds to the at least one test script in a one-to-one manner; Execute the at least one test script to obtain a corresponding test result.
2. The automated testing method according to claim 1, characterized in that: Also includes: For each test scenario, receiving accuracy verification results of one or more qualified test cases in the test scenario, wherein the one or more qualified test cases are extracted from at least one test case in the test scenario whose test results are consistent with expected effects; The one or more qualified test cases and their accuracy verification results are fed back to the preset generation model to optimize the preset generation model.
3. The automated testing method according to claim 2, characterized in that: The accuracy verification results include accurate and inaccurate, and the feeding back of the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model includes: feeding back positively to the preset generation model qualified test cases whose accuracy verification results are accurate among the one or more qualified test cases, and feeding back negatively to the preset generation model qualified test cases whose accuracy verification results are inaccurate; In response to the existence of a qualified test case whose accuracy verification result is inaccurate, new training data under the test scenario is input into the preset generation model to perform reinforcement training.
4. The automated testing method according to claim 1, characterized in that: The preset generation model parses the product requirement document based on natural language processing to determine the test points. For each test point, the preset generation model generates a test case and a corresponding test script based on at least one field in the product requirement document combined with a preset test method set.
5. The automated testing method according to claim 1, characterized in that: The received product requirement document includes: Displaying a preset template on a target page, wherein the preset template includes at least one field; Input information for the at least one field is received to generate the product requirement document.
6. The automated testing method according to claim 4 or 5, characterized in that: The at least one field includes at least one of the following: a primary classification, a secondary classification, a requirement number, a requirement name, a description, a method name, a sending parameter format, and a response parameter format.
7. The automated testing method according to claim 1, characterized in that: Executing the at least one test script to obtain a corresponding test result includes: In the process of executing the at least one test script, skipping test cases that fail the test until the at least one test script is traversed; For test cases that fail the test, the product requirement document is input into the preset generation model to regenerate the test cases and corresponding test scripts; In response to the regenerated test case being inconsistent with the test case that failed the test, the regenerated test case replaces the test case that failed the test, and the test script corresponding to the regenerated test case is executed to obtain the corresponding test result.
8. The automated testing method according to claim 1, characterized in that: Also includes: Regularly check whether the content of the product requirement document has changed; In response to detecting a change point, determining whether to update the test case according to the degree of influence of the content difference before and after the change associated with the change point on the test case; In response to determining to update the test case, at least the changed content is input into the preset generation model to obtain an updated test case and a corresponding test script.
9. The automated testing method according to claim 1, characterized in that: The expected effect in the test case is presented in the form of an image, and the method further comprises: For each test script, the test result of executing the test script is displayed in a preset test area and photographed to obtain a first image; Calculating the similarity between the first image and a second image in a test case corresponding to the test script; The consistency between the test result and the expected effect is determined according to the similarity.
10. An automated testing system, characterized in that: include: An interface module (101) is used to receive a product requirement document, wherein the product requirement document includes requirement information under at least one test scenario; A test design module (102) is in communication with the interface module (101), wherein the test design module (102) receives and inputs the product requirement document into a preset generation model to obtain at least one test case and at least one test script under the at least one test scenario, wherein the preset generation model is used to parse the input product requirement document to generate a test case and a test script, and the at least one test case and the at least one test script are in one-to-one correspondence; A test execution module (103) communicates with the test design module (102), and the test execution module executes the at least one test script to obtain a corresponding test result.
11. The automated testing system according to claim 10, characterized in that: Also includes: A human-computer interaction module (104) is in communication with the interface module (101), wherein the human-computer interaction module (104) displays a preset template on a target page, wherein the preset template includes at least one field; and receives input information for the at least one field to generate the product requirement document and send it to the interface module (101).
12. The automated testing system according to claim 10, characterized in that: Also includes: A human-computer interaction module (104), for each test scenario, the human-computer interaction module (104) receives the accuracy verification results of one or more qualified test cases in the test scenario, the human-computer interaction module (104) communicates with the test design module (102) to feed back the one or more qualified test cases and their accuracy verification results to the preset generation model to optimize the preset generation model, and the one or more qualified test cases are extracted from the test cases whose test results are consistent with expected effects in at least one test case in the test scenario.
13. The automated testing system according to claim 10, characterized in that: Also includes: A camera module (513) for capturing a first image of a preset test area (105), wherein the preset test area (105) is provided with at least one component for displaying a test result of executing the test script; a storage module (106) for storing a second image, wherein the second image is used to present an expected effect of a test case corresponding to the test script; An image recognition module (107) calculates the similarity between the first image and the second image to determine the consistency between the test result and the expected effect.
14. The automated testing system according to claim 13, characterized in that: The at least one component comprises an indicator light (611) and / or a display screen (612) on a control panel (610), and the control panel (610) is arranged on the household appliance (600).
Citation Information
Cited By
Test program generation method and device, computer equipment and readable storage medium
CN119512960A
Method and tool for automatically generating test case
CN119883923A
Test method and device for brake-by-wire equipment of vehicle, processor and vehicle
CN120742840A
