Test association method and apparatus, electronic device, and storage medium

By establishing a link between automated test scripts and functional test cases, and using hash sets to store and update test results, the problem of time-consuming and labor-intensive synchronization of automated test results with functional test cases is solved, achieving automated test result synchronization and improved accuracy.

CN116257426BActive Publication Date: 2026-05-05CHINA UNITED NETWORK COMM GRP CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2021-12-10
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing technologies, synchronizing automated test results with functional test case execution results is time-consuming, labor-intensive, and inefficient.

Method used

By naming automated test scripts and functional test cases with the same name, the test results of automated test scripts are associated with those of functional test cases. Hash sets are used to store and update the hash data of automated test scripts, thereby enabling automatic updates of the execution results of functional test cases.

Benefits of technology

It enables automatic updating of functional test case execution results, improving testing efficiency and accuracy, reducing manual intervention, and saving time and manpower.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116257426B_ABST
    Figure CN116257426B_ABST
Patent Text Reader

Abstract

This application provides a test association method, apparatus, electronic device, and storage medium. By executing automated test script files, the test results of the automated test scripts are obtained. Based on the test results, a hash set is updated. The hash set includes hash data corresponding to multiple automated test scripts. The key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script. For each functional test case in the functional test case file, the hash set is queried to obtain a first hash data whose key matches the name of the functional test case. Based on the value of the first hash data, the test identifier of that functional test case in the functional test case file is updated. This application establishes an association between automated test scripts and functional test cases using the same name, realizing automatic updating of functional test case execution results, saving time and effort, and improving testing efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of testing technology, and in particular to a testing association method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the development of software engineering technology, software structures and logic are becoming increasingly complex, and software scales are becoming increasingly large. In order to verify the quality of software and reduce the possibility of software defects, software testing is necessary.

[0003] Software testing can be categorized into manual testing and automated testing based on testing methods. In the testing process, after receiving requirements, testers first write functional test cases to organize their thinking and review the test cases. Then, all automatable test cases are compiled into a single automated script. Subsequent testing executes the automated script directly for already automated test cases, and manually executes the tests for non-automated test cases, until all functional test cases have been executed, at which point the testing is considered complete. After the automated test cases have been executed, testers must manually update the corresponding functional test cases to show either success or failure based on the automated test results.

[0004] However, the above-mentioned method of manually synchronizing test results is time-consuming, labor-intensive, and inefficient. Summary of the Invention

[0005] This application provides a test association method, apparatus, electronic device, and storage medium to solve the problem of time-consuming, labor-intensive, and inefficient synchronization of automated test results and functional test case execution results.

[0006] Firstly, this application provides a test association method, comprising: obtaining a functional test case file and an automated test script file; wherein the functional test case file includes multiple functional test cases, and the automated test script file includes multiple automated test scripts; executing tests according to the automated test script file to obtain test results of the multiple automated test scripts; updating a hash set based on the test results of the multiple automated test scripts, the hash set including hash data corresponding to the multiple automated test scripts; wherein the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script; for each functional test case in the functional test case file, querying the hash set to obtain first hash data whose key matches the name of the functional test case, and updating the test identifier of the functional test case in the functional test case file according to the value of the first hash data, different test identifiers representing different test results.

[0007] This application establishes a correlation between the test results of automated test scripts and the execution results of functional test cases by naming them with the same name. This enables automatic updates of the execution results of functional test cases, saving time and effort, improving testing efficiency, and also improving accuracy.

[0008] Furthermore, based on the test results of multiple automated test scripts, the hash set is updated, including: for each automated test script, the following processing is performed: if the current hash set does not contain hash data whose key is the name of the automated test script, then the hash data corresponding to the automated test script is added to the hash set; if the current hash set contains hash data corresponding to the automated test script, then the value of the hash data corresponding to the automated test script is updated according to the current value of the hash data and the test result of the automated test script.

[0009] The above explains how hash data is stored and updated in a hash set.

[0010] Furthermore, the test result includes one of the following: pass, fail, or partial pass; based on the current value of the hash data and the test result of the automated test script, the value of the hash data corresponding to the automated test script is updated, including: if the current value of the hash data and the test result of the automated test script are consistent, or if the current value of the hash data represents a partial pass, then the value of the hash data is not modified; if the current value of the hash data does not represent a partial pass, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; wherein, the modified value represents a partial pass.

[0011] The above further elaborates on how hash data is updated in a hash set.

[0012] Furthermore, based on the automated test script file, tests are executed to obtain test results from multiple automated test scripts, including: determining the types of multiple automated test scripts in the automated test script file; and executing the corresponding run commands based on the types of multiple automated test scripts to obtain the test results of the automated test scripts.

[0013] The above methods demonstrate that this application supports the execution and result parsing of various types of automated test scripts.

[0014] Furthermore, for each functional test case in the functional test case file, the hash set is queried, including: if the functional test case file is in mind map format, the name of each leaf node in the functional test case file is obtained, and the hash set is queried based on the name of each leaf node.

[0015] The above method describes how to update the execution results of functional test cases when the functional test case file is in mind map format.

[0016] Furthermore, for each functional test case in the functional test case file, the hash set is queried, including: if the file type of the functional test case file is a list, then the contents of each row under the test case name column in the functional test case file are obtained, and the hash set is queried based on the contents of each row.

[0017] The above method describes how to update the execution results of functional test cases when the functional test case file is a list.

[0018] The apparatus, equipment, and computer storage medium provided in this application are described below, and their contents and effects can be found in the Methods section.

[0019] Secondly, this application provides a test association device, including: an acquisition module for acquiring functional test case files and automated test script files; wherein the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts; and a processing module for executing tests according to the automated test script files to obtain the test results of the multiple automated test scripts.

[0020] The processing module is also used to update the hash set based on the test results of multiple automated test scripts. The hash set includes hash data corresponding to multiple automated test scripts. The key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script. It is also used to query the hash set for each functional test case in the functional test case file, obtain the first hash data whose key matches the name of the functional test case, and update the test identifier of the functional test case in the functional test case file according to the value of the first hash data. Different test identifiers represent different test results.

[0021] Furthermore, the processing module updates the hash set based on the test results of multiple automated test scripts. Specifically, for each automated test script, the following processing is performed: if the current hash set does not contain hash data whose key is the name of the automated test script, then the hash data corresponding to the automated test script is added to the hash set; if the current hash set contains hash data corresponding to the automated test script, then the value of the hash data corresponding to the automated test script is updated according to the current value of the hash data and the test result of the automated test script.

[0022] Furthermore, the test result includes one of the following: pass, fail, or partial pass; based on the current value of the hash data and the test result of the automated test script, the value of the hash data corresponding to the automated test script is updated, including: if the current value of the hash data and the test result of the automated test script are consistent, or if the current value of the hash data represents a partial pass, then the value of the hash data is not modified; if the current value of the hash data does not represent a partial pass, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; wherein, the modified value represents a partial pass.

[0023] Furthermore, the processing module executes tests based on the automated test script file to obtain test results from multiple automated test scripts. Specifically, this includes: determining the types of multiple automated test scripts in the automated test script file; and executing the corresponding run commands based on the types of multiple automated test scripts to obtain the test results of the automated test scripts.

[0024] Furthermore, the processing module queries the hash set for each functional test case in the functional test case file. Specifically, if the functional test case file is in mind map format, the module obtains the name of each leaf node in the functional test case file and queries the hash set based on the name of each leaf node.

[0025] Furthermore, the processing module queries the hash set for each functional test case in the functional test case file. Specifically, if the file type of the functional test case file is a list, it retrieves the content of each row under the test case name column in the functional test case file and queries the hash set based on the content of each row.

[0026] Thirdly, this application provides an electronic device, including: a memory, a processor; a memory for storing processor-executable instructions; wherein the processor is configured to: perform the method as described in the first aspect according to the executable instructions.

[0027] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method as described in the first aspect.

[0028] The test association method, apparatus, electronic device, and storage medium provided in this application obtain the test results of automated test scripts by executing automated test script files. Based on the test results, a hash set is updated. The hash set includes hash data corresponding to multiple automated test scripts. The key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script. For each functional test case in the functional test case file, the hash set is queried to obtain first hash data whose key matches the name of the functional test case. Based on the value of the first hash data, the test identifier of that functional test case in the functional test case file is updated. This application uses the same name to establish a association between the test results of automated test scripts and the execution results of functional test cases, realizing automatic updating of the execution results of functional test cases, saving time and effort, and improving testing efficiency. Attached Figure Description

[0029] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0030] Figure 1 This application provides one possible application scenario.

[0031] Figure 2 A flowchart of a test association method provided in Embodiment 1 of this application;

[0032] Figure 3 This is a schematic diagram of a functional test case file provided in Embodiment 1 of this application;

[0033] Figure 4 This is a schematic diagram of an automated test script file provided in Embodiment 1 of this application;

[0034] Figure 5 A schematic diagram of an input interface for an automated test script file and a functional test case file provided in Embodiment 1 of this application;

[0035] Figure 6 This is a schematic diagram of an automated test result provided in Embodiment 1 of this application;

[0036] Figure 7 A schematic diagram of the functional test case file after automatically updating the execution result provided in Embodiment 1 of this application;

[0037] Figure 8 This is a schematic diagram of the test association device provided in Embodiment 2 of this application;

[0038] Figure 9 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application.

[0039] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0040] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application.

[0041] First, let me explain the terms used in this application:

[0042] A test case is a set of test inputs, execution conditions, and expected results designed for a specific purpose, used to verify whether a particular software requirement is met. The main methods for designing test cases are black-box testing and white-box testing.

[0043] Functional testing, also known as black-box testing, focuses on the external structure of the program without considering the internal logical structure. It mainly tests the software interface and software functions.

[0044] Automated testing: A process that transforms human-driven testing actions into machine-executed processes. Typically, after test cases are designed and reviewed, testers execute the tests step-by-step according to the procedures described in the test cases, comparing the actual results with the expected results. To save manpower, time, or hardware resources and improve testing efficiency, the concept of automated testing was introduced.

[0045] JMeter is a Java-based stress testing tool developed by the Apache Software Foundation, used for stress testing software.

[0046] HashMap: An implementation of the Map interface based on a hash table. This implementation provides all optional map operations and allows null values ​​and null keys.

[0047] A hash table, also called a hash map, is a data structure that allows direct access to records based on key-value pairs. The key is the name of the record, and the value is the location within it. In other words, it accesses records by mapping key values ​​to locations within the table, thus speeding up the search process. This mapping function is called a hash function, and the array storing the records is called a hash table.

[0048] Leaf node: Also known as a leaf node or leaf node, it is a concept in discrete mathematics. A node in a tree that has no children (i.e., a degree of 0) is called a leaf node, or simply a "leaf". A leaf node is a node with a degree of 0, also called a terminal node.

[0049] With the development of software engineering technology, software structures and logic are becoming increasingly complex, and software scales are becoming increasingly large. To verify software quality and reduce the possibility of defects, software testing is necessary. Software testing can be divided into manual testing and automated testing based on testing methods. Test cases are a scientific organization and summary of software testing activities; they are a method of quantifying testing and aim to transform software testing behaviors into manageable patterns.

[0050] In the testing process, after receiving the requirements, testers first write functional test cases to organize their thinking and review the test cases. Then, all test cases that can be automated are compiled into a single automated script. In subsequent testing, automated test cases are executed directly using the automated script, while non-automated test cases are executed manually until all functional test cases have been executed, at which point the testing is considered complete.

[0051] During this process, testers manually identify which test cases were not automated and require manual testing. Simultaneously, after the automated tests are completed, testers can manually update the execution results of the corresponding functional test cases to either success or failure based on the automated test results.

[0052] However, the above-mentioned manual synchronization of test results results in a time-consuming, labor-intensive, and inefficient process of synchronizing automated test results with functional test case execution results.

[0053] This application provides a testing association method, apparatus, electronic device, and storage medium, aiming to solve the above-mentioned technical problems in the prior art.

[0054] This application can be applied to a software functional testing scenario, such as... Figure 1 As shown, to perform functional testing on a certain software, based on the testing requirements, technicians will write functional test cases. Some of these functional test cases can be executed automatically. Automated test scripts will be written for the automated test cases. The functional test case files and their corresponding automated test script files will be input into a test-related device. This device will execute the automated test scripts and obtain the automated test results. The device will then update the functional test cases based on the automated test results; that is, it will update the execution results of the corresponding functional test cases based on the automated test results.

[0055] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0056] Example 1

[0057] Figure 2 The flowchart of the test association method provided in Embodiment 1 of this application includes the following steps:

[0058] S101. Obtain functional test case files and automated test script files; wherein, the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts;

[0059] For example, Figure 3 This diagram illustrates a functional test case file provided in Embodiment 1 of this application. The functional test case file is in the form of a mind map (XMind), which corresponds to seven leaf nodes—nodes that do not extend further at the end. Each of the seven leaf nodes corresponds to one of the seven functional test cases. In other words, a single functional test case file can include multiple functional test cases.

[0060] Figure 3 The seven meridians are:

[0061] Flowchart 1: Registration - Register using an unregistered mobile number - Registration successful - The interface for registering using an unregistered mobile number returns a registration success message;

[0062] Path 2: Registration - Database entry is normal - The corresponding mobile phone number in the database is the correct registered mobile phone number - After successful registration, all fields in the database are verified to be normal;

[0063] Path 3: Registration - Database entry is normal - User status corresponding to the mobile number in the database is normal - After successful registration, all fields in the database are verified to be normal;

[0064] Path 4: Registration - Database entry is normal - The corresponding registration date in the database is correct - After successful registration, all fields in the database are verified to be normal;

[0065] Path 5: Login - Login with any registered mobile number - Login will be successful using any registered mobile number;

[0066] Path 6: Querying User Information - Querying user information by mobile number is normal - Querying user information is normal;

[0067] Path 7: Querying User Information - Querying user information by user ID is normal - Querying user information is normal.

[0068] For example, Figure 4 This diagram illustrates an automated test script file provided in Embodiment 1 of this application, which is an automated test script written based on JMeter. Figure 4 On the interface shown, the thread group of the test plan on the left includes 8 automated test scripts, which means that an automated test script file can include multiple automated test scripts.

[0069] Specifically, the execution process of each automated test script in this automated test script file is as follows:

[0070] Script 1: The registration interface returns a success message when using an unregistered mobile number.

[0071] Script 2: After successful registration, verify that all fields in the database are normal;

[0072] Script 3: Register using a mobile phone number with a 185 prefix;

[0073] Script 4: Login will be successful using any registered mobile phone number;

[0074] Script 5: Register using a mobile phone number starting with 170;

[0075] Script 4: Login will be successful using any registered mobile phone number;

[0076] Script 6: Register using a mobile phone number with a 199 prefix;

[0077] Script 4: Login will be successful using any registered mobile phone number;

[0078] Script 7: User information retrieval is normal;

[0079] Script 8: User information retrieval is normal.

[0080] Reference Figure 3 and Figure 4 This application uses the same naming convention for automated test scripts and functional test cases to establish a corresponding relationship between them. Specifically, the correspondence between automated test scripts and functional test cases can include the following four types.

[0081] The first type is a one-to-one correspondence, where one automated test script corresponds to one functional test case. For example, the functional test case corresponding to Pulse 1 is "The interface for registering with an unregistered mobile phone number returns registration success," and the corresponding automated test script is Script 1. When Script 1 passes verification, the function passes verification.

[0082] The second type is a one-to-many correspondence, where one automated test script corresponds to multiple functional test cases. For example, the functional test case corresponding to Pulse 2, Pulse 3, and Pulse 4 is "verify that all fields in the database are normal after successful registration," corresponding to script 2. That is, one automated test script corresponds to three functional test points. When script 2 passes verification, all three functions pass verification.

[0083] The third type is a many-to-one correspondence, where multiple automated test scripts correspond to one functional test case. For example, the functional test case corresponding to point 5 is "Login is successful using any registered mobile phone number," corresponding to scripts 3, 4, 5, and 6. It's easy to understand that verifying the "Login is successful using any registered mobile phone number" function requires verifying mobile phone numbers from multiple number ranges (185, 170, and 199). Since different number ranges correspond to different automated test scripts, scripts 3, 4, 5, 6, and 4 need to be executed sequentially. When scripts 3, 5, and 6 all pass verification, script 4 also passes verification, and the function passes verification.

[0084] The fourth type is a many-to-many correspondence, where multiple automated test scripts correspond to multiple functional test cases. For example, the functional test cases corresponding to Pulse 6 and Pulse 7 are both named "Querying user information normally," meaning they are two functional test cases with the same name because they have the same function. This function corresponds to scripts 6 and 7.

[0085] During the testing process, multiple functional test cases are involved. When writing the corresponding automated test scripts, a one-to-many or many-to-one correspondence method is adopted. Compared with the method of assigning an automated test script to each functional test case, this method simplifies the writing process of automated test scripts, reduces the difficulty of later maintenance, and facilitates reuse.

[0086] Furthermore, in practical applications, the types of functional test case files are not limited to... Figure 3 Example mind map type; the type of automated test case file is not limited to those written in JMeter. The correspondence between functional test cases and automated test scripts does not need to include all four relationships mentioned above. Technical personnel can write functional test cases and corresponding automated test cases according to actual needs; this application does not restrict the writing method or correspondence between the two.

[0087] In practical applications, the execution entity of the test association method of this application can be a test association device. This device can be implemented through a computer program, such as application software; or, it can be implemented as a medium storing the relevant computer program, such as a USB flash drive or cloud drive; or, it can be implemented through a physical device integrating or installing the relevant computer program, such as a chip. Optionally, this embodiment uses the installation and application of the test association device to a computer as an example.

[0088] S102. Execute the tests according to the automated test script file and obtain the test results of multiple automated test scripts.

[0089] S103. Based on the test results of multiple automated test scripts, update the hash set, which includes hash data corresponding to multiple automated test scripts; wherein, the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script;

[0090] Specifically, the computer executes automated test script files, runs each automated test script within them, and obtains the test results of multiple automated test scripts. These test results are stored in a hash set. It should be noted that the hash set contains multiple hash data, and the hash data structure contains keys (keys, keywords) and values ​​(values ​​corresponding to the keywords). In this application, the script name of each automated test script is stored in the key of each hash data, and its corresponding value stores the test result of that automated test script. This hash data structure storage method facilitates rapid information retrieval.

[0091] S104. For each functional test case in the functional test case file, query the hash set to obtain the first hash data whose key matches the name of the functional test case, and update the test identifier of the functional test case in the functional test case file according to the value of the first hash data. Different test identifiers represent different test results.

[0092] In this configuration, each functional test case in the functional test case file has the same name as its corresponding automated test script. Based on the name of the functional test case, the key and corresponding value matching that name can be retrieved from the hash data, thus obtaining the test result of the stored automated test script. Based on this result, the test identifier of the corresponding functional test case is updated. This setup establishes a link between automated test results and functional test cases, eliminating the need for manual updates, improving work efficiency, and ensuring accuracy.

[0093] For example, the storage format of hash data values ​​can be "pass" to indicate success, "fail" to indicate failure, and "na" to indicate partial success. Test indicators can be expressed as the text "pass," "fail," or "partially pass"; or as a checkmark to indicate success; a cross to indicate failure; an exclamation mark to indicate partial success; or different colors: green for success, red for failure, and orange for partial success; or a combination of the above, such as a green checkmark for success, a red cross for failure, and an orange exclamation mark for partial success. This application does not limit the storage format of hash data values ​​or the test indicators. In practical applications, technicians can customize the settings according to their needs, as long as the test results are correctly represented.

[0094] Furthermore, in S103, the method for updating the hash set based on the test results of multiple automated test scripts specifically includes two cases. Specifically, for each automated test script, the processing is as follows:

[0095] The first scenario: If the current hash set does not contain hash data with the name of the automated test script as its key, then add the corresponding hash data for the automated test script to the hash set. For example, when executing script 1, it's the first execution, and the hash data does not yet store the script name of script 1. Therefore, it's necessary to first add the name of script 1 to the key of the hash set, and simultaneously store the automated test result obtained from executing script 1. Another example: when executing script 4 for the first time, the hash data does not yet store the script name of script 4. Therefore, it's necessary to first add the name of script 4 to the key of the hash set, and simultaneously store the automated test result obtained from executing script 4.

[0096] The second scenario: If the hash data corresponding to the automated test script already exists in the current hash set, then the value of the hash data corresponding to the automated test script is updated based on the current value of the hash data and the test result of the automated test script. For example, when script 4 is executed for the second time, the key of the hash data already stores the script name of script 4, so it is necessary to determine the value of the hash data based on the existing hash data value and the currently obtained automated test result, and then update the hash data value. Another example: when script 4 is executed for the third time, the key of the hash data already stores the script name of script 4, so it is necessary to determine the value of the hash data based on the existing hash data value and the currently obtained automated test result, and then update the hash data value.

[0097] Furthermore, for example, the test result includes one of the following: pass, fail, or partially pass. Based on this, in the second scenario described above, when updating the hash data after judging based on the current value of the hash data and the test result of the automated test script, the judgment specifically includes two scenarios:

[0098] The first scenario: If the current value of the hash data is consistent with the test result of the automated test script, or if the test result represented by the current value of the hash data is partially passed, then the value of the hash data will not be modified. This further includes the following situations: (1) If the current value of the hash data is passed, and the test result obtained from the automated test script is also passed, then the value of the hash data will not be modified; that is, the value of the hash data remains passed. (2) If the current value of the hash data is failed, and the test result obtained from the automated test script is also failed, then the value of the hash data will not be modified; that is, the value of the hash data remains failed. (3) If the current value of the hash data is partially passed, regardless of whether the test result obtained from the automated test script is passed, failed, or partially passed, the value of the hash data will not be modified; that is, the value of the hash data remains partially passed.

[0099] The second scenario: If the current value of the hash data does not represent a partial pass in the test, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; wherein, the modified value represents a partial pass. This further includes the following situations: (1) If the current value of the hash data is pass, but the test result obtained from the automated test script is fail or partially pass, then the value of the hash data is modified to a partial pass. Similarly, (2) If the current value of the hash data is fail, but the test result obtained from the automated test script is pass or partially pass, then the value of the hash data is modified to a partial pass.

[0100] In one example, the steps in S102 to execute tests based on the automated test script file specifically include: S201, determining the types of multiple automated test scripts in the automated test script file; S202, executing the corresponding run commands according to the types of multiple automated test scripts to obtain the test results of the automated test scripts.

[0101] For example, the type of automated test case file can be Java, Python, JMeter, etc. When it's a Java script, the `mvn clean test` command is executed; when it's a Python script, the `python xx.py` command is executed; and when it's a JMeter script, the `jmeter-nt xx.jmx` command is executed. This application supports executing various types of automated test case files and does not restrict their type; in practical applications, anything that can be executed by a computer is acceptable.

[0102] Furthermore, this application supports establishing associations for various types of functional test case files. The functional test case file types can include mind maps (XMind), lists (Excel), etc. Specifically, if the functional test case file is in mind map format, the names of each leaf node in the functional test case file are obtained, and a hash set is queried based on the names of each leaf node. If the functional test case file is in list format, the content of each row under the test case name column in the functional test case file is obtained, and a hash set is queried based on the content of each row. This application does not limit the functional test case file types to these two; there are no restrictions on their types. In practical applications, any file type that can be recognized by a computer and can be associated with the corresponding automated test case file is acceptable.

[0103] The following section uses mind map format functional test cases and Jmeter-written automated test case files as examples to introduce the overall process of the test association method provided in this application.

[0104] First, input the automated test script file and the corresponding functional test case file into the computer. Figure 5 This is a schematic diagram of the input interface for an automated test script file and a functional test case file provided in Embodiment 1 of this application. Figure 5 As shown, the interface includes selection boxes for automated test case files and functional test case files, as well as a "Execute Automation" button. This application develops a front-end interface and back-end service that supports selecting various types of functional test case files and their corresponding automated test case files. After automated execution is complete, the execution results in the functional test case files can be updated accordingly. The functional test case files are not limited to… Figure 5 The XMind type shown; automated test case files are not limited to Figure 5 The jmx type shown.

[0105] Next, clicking the "Execute Automation" button will cause the backend server to execute the `jmeter-nt xx.jmx` command based on the JMX type automated test case file, obtaining the script test results. The backend server will then store these test results in a collection of hash structures.

[0106] Specifically, if the current hash set does not contain hash data with the key of the automated test script's name, then the hash data corresponding to the automated test script is added to the hash set. If the current hash set contains hash data corresponding to the automated test script, then the value of the hash data corresponding to the automated test script is updated based on the current value of the hash data and the test result of the automated test script. Further, if the current value of the hash data matches the test result of the automated test script, or if the current value of the hash data represents a partially passed test result, then the value of the hash data is not modified. If the current value of the hash data does not represent a partially passed test result, and the current value of the hash data does not match the test result of the automated test script, then the value of the hash data is modified; the modified value represents a partially passed test result.

[0107] Figure 6 This is a schematic diagram illustrating the automated test results provided in Embodiment 1 of this application. Specifically, the script test result for "Registering with an unregistered mobile phone number returns successful registration" is "Pass"; the script test result for "Verifying all fields in the database are normal after successful registration" is "Fail"; the script test result for "Registering with a 185-series mobile phone number" is "Pass"; the script test result for "Login successfully with any registered mobile phone number" is "Partially Pass"; the script test result for "Registering with a 170-series mobile phone number" is "Pass"; the script test result for "Registering with a 199-series mobile phone number" is "Pass"; and the script test result for "Querying user information normally" is "Pass". It is understandable that the script for "Login successfully with any registered mobile phone number" was executed 3 times and did not pass all times, so its test result is "Partially Pass".

[0108] Finally, update the execution results in the functional test case file based on the hash set. Figure 7 This is a schematic diagram of the functional test case file after automatically updating the execution results provided in Embodiment 1 of this application, compared to... Figure 3 A test identifier has been added. For example... Figure 7 As shown, the update of the execution result is reflected in the test identifier. Different test identifiers represent different test results. Specifically, Figure 7 The symbols used are checkmarks to indicate passing; crosses to indicate failing; and exclamation marks to indicate partial passing.

[0109] Combination Figure 6 and Figure 7 The test case for the function "Registration successful when using an unregistered mobile number" is marked with a checkmark; the test case for the function "Verifying all fields in the database are normal after successful registration" is marked with a cross; the test case for the function "Login successful using any registered mobile number" is marked with an exclamation mark; and the test case for the function "User information query is normal" is marked with a checkmark.

[0110] If the function test case file is an Excel file, update the content in the "Execution Results" column of the list. You can choose the text "Success", "Failure", or "Partially Pass"; or the letters "Pass", "Fail", or "Na". Any option that clearly represents the result is acceptable.

[0111] The test association method provided in this application includes: obtaining functional test case files and automated test script files; wherein the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts; executing tests according to the automated test script files to obtain test results from the multiple automated test scripts; updating a hash set based on the test results from the multiple automated test scripts, the hash set including hash data corresponding to the multiple automated test scripts; wherein the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script; for each functional test case in the functional test case file, querying the hash set to obtain first hash data whose key matches the name of the functional test case, and updating the test identifier of the functional test case in the functional test case file according to the value of the first hash data, with different test identifiers representing different test results. This application establishes an association between the test results of automated test scripts and the execution results of functional test cases using the same name, and utilizes a hash structure data storage method to achieve fast information retrieval, thereby realizing automatic updating of functional test case execution results, saving time and effort, and improving testing efficiency.

[0112] Example 2

[0113] Figure 8 The schematic diagram of the test association device provided in Embodiment 2 of this application includes an acquisition module 10 and a processing module 20. The acquisition module 10 is used to acquire functional test case files and automated test script files; wherein the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts. The processing module 20 is used to execute tests according to the automated test script files to obtain the test results of the multiple automated test scripts; the processing module 20 is also used to update a hash set based on the test results of the multiple automated test scripts, the hash set including hash data corresponding to the multiple automated test scripts; wherein the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script; it is also used to query the hash set for each functional test case in the functional test case file to obtain first hash data whose key matches the name of the functional test case, and update the test identifier of the functional test case in the functional test case file according to the value of the first hash data, with different test identifiers representing different test results.

[0114] This application establishes a correlation between the test results of automated test scripts and the execution results of functional test cases by naming them with the same name. This enables automatic updates of the execution results of functional test cases, saving time and effort, improving testing efficiency, and also improving accuracy.

[0115] In practical applications, the execution entity of the test association method of this application can be a test association device. This device can be implemented through a computer program, such as application software; or, it can be implemented as a medium storing the relevant computer program, such as a USB flash drive or cloud drive; or, it can be implemented through a physical device integrating or installing the relevant computer program, such as a chip. Optionally, this embodiment uses the installation and application of the test association device to a computer as an example.

[0116] Specifically, the process involves inputting functional test case files and corresponding automated test script files. The computer executes the automated test script files, running each script to obtain test results. These results are then stored in a hash set. It's important to note that the hash set contains multiple hash data sets, each with a key and value. This application stores the script name of each automated test script in the key of each hash data set, and the corresponding value stores the test result of that script. This hash data structure storage method facilitates rapid information retrieval.

[0117] In one example, processing module 20 updates the hash set based on the test results of multiple automated test scripts. Specifically, for each automated test script, the following processing is performed: if the current hash set does not contain hash data with the name of the automated test script as its key, then the hash data corresponding to the automated test script is added to the hash set; if the current hash set contains hash data corresponding to the automated test script, then the value of the hash data corresponding to the automated test script is updated according to the current value of the hash data and the test result of the automated test script. The above clarifies the storage and updating method of hash data in the hash set.

[0118] Specifically, when script 4 is executed for the first time, its name is not yet stored in the hash data. Therefore, the name of script 4 needs to be added to the key of the hash set, along with the automated test result obtained from executing script 4. When script 4 is executed for the second time, its name is already stored in the key of the hash data. Therefore, the hash data value needs to be updated based on the existing hash data value and the currently obtained automated test result. Similarly, when script 4 is executed for the third time, its name is still stored in the key of the hash data.

[0119] In one example, the test result includes one of the following: pass, fail, or partial pass. Based on the current value of the hash data and the test result of the automated test script, the value of the hash data corresponding to the automated test script is updated. Specifically: if the current value of the hash data and the test result of the automated test script are consistent, or if the current value of the hash data represents a partial pass, then the value of the hash data is not modified; if the current value of the hash data does not represent a partial pass, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; the modified value represents a partial pass. The above further elaborates on the method of updating hash data in a hash set.

[0120] Specifically, (1) If the current hash data value is "pass" and the test result of the currently obtained automated test script is also "pass", then the hash data value is not modified, meaning the hash data value remains "pass". (2) If the current hash data value is "fail" and the test result of the currently obtained automated test script is also "fail", then the hash data value is not modified, meaning the hash data value remains "fail". (3) If the current hash data value is "partially pass", regardless of whether the test result of the currently obtained automated test script is "pass", "fail", or "partially pass", the hash data value is not modified, meaning the hash data value remains "partially pass". (4) If the current hash data value is "pass", and the test result of the currently obtained automated test script is "fail" or "partially pass", then the hash data value is modified to "partially pass". (5) If the current hash data value is "fail", and the test result of the currently obtained automated test script is "pass" or "partially pass", then the hash data value is modified to "partially pass".

[0121] In one example, processing module 20 executes tests based on an automated test script file, obtaining test results from multiple automated test scripts. Specifically, this includes: determining the types of multiple automated test scripts in the automated test script file; executing the corresponding run commands based on the types of the multiple automated test scripts; and obtaining the test results of the automated test scripts. This demonstrates that this application supports the execution and result parsing of multiple types of automated test scripts.

[0122] This application supports the execution of various types of automated test case files. Specifically, the types of automated test case files can be Java, Python, JMeter, etc. When it is a Java script, the `mvn clean test` command is executed; when it is a Python script, the `python xx.py` command is executed; when it is a JMeter script, the `jmeter-nt xx.jmx` command is executed. This application supports the execution of various types of automated test case files without limiting their type; in practical applications, anything that can be executed by a computer is acceptable.

[0123] In one example, processing module 20 queries the hash set for each functional test case in the functional test case file. Specifically, if the functional test case file is in mind map format, it retrieves the names of each leaf node in the functional test case file and queries the hash set based on the names of each leaf node. The above describes the method for updating the execution results of functional test cases when the functional test case file is in mind map format.

[0124] In one example, processing module 20 queries the hash set for each functional test case in the functional test case file. Specifically, if the functional test case file is a list, it retrieves the content of each row under the test case name column in the functional test case file and queries the hash set based on each row's content. The above describes the method for updating the execution results of functional test cases when the functional test case file is a list.

[0125] The following section uses mind map format functional test cases and Jmeter-written automated test case files as examples to introduce the overall operation process of the test-related device provided in this application.

[0126] First, input the automated test script file and the corresponding functional test case file into the test-related device. Figure 5 This is a schematic diagram of the input interface for an automated test script file and a functional test case file provided in Embodiment 1 of this application. Figure 5As shown, the interface includes selection boxes for automated test case files and functional test case files, as well as a "Execute Automation" button. This application develops a front-end interface and back-end service that supports selecting various types of functional test case files and their corresponding automated test case files. After automated execution is complete, the execution results in the functional test case files can be updated accordingly. The functional test case files are not limited to… Figure 5 The XMind type shown; automated test case files are not limited to Figure 5 The jmx type shown.

[0127] Next, clicking the "Execute Automation" button will cause the backend server to execute the `jmeter-nt xx.jmx` command based on the JMX type automated test case file, obtaining the script test results. The backend server will then store these test results in a collection of hash structures.

[0128] Specifically, if the current hash set does not contain hash data with the key of the automated test script's name, then the hash data corresponding to the automated test script is added to the hash set. If the current hash set contains hash data corresponding to the automated test script, then the value of the hash data corresponding to the automated test script is updated based on the current value of the hash data and the test result of the automated test script. Further, if the current value of the hash data matches the test result of the automated test script, or if the current value of the hash data represents a partially passed test result, then the value of the hash data is not modified. If the current value of the hash data does not represent a partially passed test result, and the current value of the hash data does not match the test result of the automated test script, then the value of the hash data is modified; the modified value represents a partially passed test result.

[0129] Figure 6 This is a schematic diagram illustrating the automated test results provided in Embodiment 1 of this application. Specifically, the script test result for "Registering with an unregistered mobile phone number returns successful registration" is "Pass"; the script test result for "Verifying all fields in the database are normal after successful registration" is "Fail"; the script test result for "Registering with a 185-series mobile phone number" is "Pass"; the script test result for "Login successfully with any registered mobile phone number" is "Partially Pass"; the script test result for "Registering with a 170-series mobile phone number" is "Pass"; the script test result for "Registering with a 199-series mobile phone number" is "Pass"; and the script test result for "Querying user information normally" is "Pass". It is understandable that the script for "Login successfully with any registered mobile phone number" was executed 3 times and did not pass all times, so its test result is "Partially Pass".

[0130] Finally, update the execution results in the functional test case file based on the hash set. Figure 7 This is a schematic diagram of the functional test case file after automatically updating the execution results provided in Embodiment 1 of this application, compared to... Figure 3 A test identifier has been added. For example... Figure 7 As shown, the update of the execution result is reflected in the test identifier. Different test identifiers represent different test results. Specifically, Figure 7 The symbols used are checkmarks to indicate passing; crosses to indicate failing; and exclamation marks to indicate partial passing.

[0131] Combination Figure 6 and Figure 7 The test case for the function "Registration successful when using an unregistered mobile number" is marked with a checkmark; the test case for the function "Verifying all fields in the database are normal after successful registration" is marked with a cross; the test case for the function "Login successful using any registered mobile number" is marked with an exclamation mark; and the test case for the function "User information query is normal" is marked with a checkmark.

[0132] If the function test case file is an Excel file, update the content in the "Execution Results" column of the list. You can choose the text "Success", "Failure", or "Partially Pass"; or the letters "Pass", "Fail", or "Na". Any option that clearly represents the result is acceptable.

[0133] The test association apparatus provided in this application includes an acquisition module 10 and a processing module 20. The acquisition module 10 is used to acquire functional test case files and automated test script files; wherein the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts. The processing module 20 is used to execute tests according to the automated test script files and obtain the test results of the multiple automated test scripts. The processing module 20 is also used to update a hash set based on the test results of the multiple automated test scripts. The hash set includes hash data corresponding to the multiple automated test scripts; wherein the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script. Furthermore, for each functional test case in the functional test case file, the processing module 20 queries the hash set to obtain first hash data whose key matches the name of the functional test case, and updates the test identifier of that functional test case in the functional test case file according to the value of the first hash data; different test identifiers represent different test results. This application establishes a correlation between the test results of automated test scripts and the execution results of functional test cases using the same name. It utilizes a hash structure data storage method to achieve fast information retrieval, thereby realizing the automatic updating of the execution results of functional test cases, saving time and effort, and improving testing efficiency.

[0134] Example 3

[0135] Figure 9 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of this application, as shown below. Figure 9 As shown, the electronic device includes:

[0136] The electronic device includes a processor 291 and a memory 292; it may also include a communication interface 293 and a bus 294. The processor 291, memory 292, and communication interface 293 can communicate with each other via the bus 294. The communication interface 293 can be used for information transmission. The processor 291 can invoke logical instructions stored in the memory 292 to execute the methods of the above embodiments.

[0137] Furthermore, the logic instructions in the aforementioned memory 292 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium.

[0138] The memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as program instructions / modules corresponding to the methods in the embodiments of this application. The processor 291 executes functional applications and data processing by running the software programs, instructions, and modules stored in the memory 292, thereby implementing the methods in the above-described method embodiments.

[0139] The memory 292 may include a program storage area and a data storage area. The program storage area may store the operating system and application programs required for at least one function; the data storage area may store data created based on the use of the terminal device. Furthermore, the memory 292 may include high-speed random access memory and may also include non-volatile memory.

[0140] This application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method provided in Embodiment 1.

[0141] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0142] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for testing correlation, characterized in that, Obtain functional test case files and automated test script files; wherein, the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts; Based on the automated test script file, execute the test to obtain the test results of the multiple automated test scripts; Based on the test results of the multiple automated test scripts, the hash set is updated. The hash set includes hash data corresponding to the multiple automated test scripts. The key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script. For each functional test case in the functional test case file, the hash set is queried to obtain first hash data whose key matches the name of the functional test case. Based on the value of the first hash data, the test identifier of the functional test case in the functional test case file is updated. Different test identifiers represent different test results. The updating of the hash set based on the test results of the multiple automated test scripts includes: For each automated test script, perform the following processing: If the current hash set does not contain hash data whose key is the name of the automated test script, then add the hash data corresponding to the automated test script to the hash set; if the current hash set contains hash data corresponding to the automated test script, then update the value of the hash data corresponding to the automated test script based on the current value of the hash data and the test result of the automated test script. The step of querying the hash set for each functional test case in the functional test case file includes: the file type of the functional test case file includes mind map format and / or list; when the file type of the functional test case file is mind map format, obtaining the name of each leaf node in the functional test case file, and querying the hash set based on the name of each leaf node; when the file type of the functional test case file is list, obtaining the content of each row under the test case name column in the functional test case file, and querying the hash set based on the content of each row.

2. The method according to claim 1, characterized in that, The test result includes one of the following: pass, fail, or partially pass; The step of updating the hash data value corresponding to the automated test script based on the current hash data value and the test result of the automated test script includes: If the current value of the hash data is consistent with the test result of the automated test script, or if the test result represented by the current value of the hash data is partially passed, then the value of the hash data will not be modified. If the test result represented by the current value of the hash data is not partially passed, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; wherein the modified value represents partially passed.

3. The method according to claim 1, characterized in that, The step of executing tests according to the automated test script file and obtaining the test results of the multiple automated test scripts includes: Determine the types of the plurality of automated test scripts in the automated test script file; Based on the type of the multiple automated test scripts, the corresponding execution command is executed to obtain the test results of the automated test scripts.

4. A test correlation device, characterized in that, The device includes: The acquisition module is used to acquire functional test case files and automated test script files; wherein, the functional test case files include multiple functional test cases, and the automated test script files include multiple automated test scripts; The processing module is used to execute tests according to the automated test script file and obtain the test results of the multiple automated test scripts; The processing module is further configured to update the hash set based on the test results of the plurality of automated test scripts, wherein the hash set includes hash data corresponding to the plurality of automated test scripts; wherein the key of each hash data is the script name of the corresponding automated test script, and the value represents the test result of the corresponding automated test script; The processing module is further configured to query the hash set for each functional test case in the functional test case file, obtain first hash data whose key is consistent with the name of the functional test case, and update the test identifier of the functional test case in the functional test case file according to the value of the first hash data, wherein different test identifiers represent different test results; The processing module is specifically used to perform the following processing for each automated test script: if there is no hash data in the current hash set whose key is the name of the automated test script, then add the hash data corresponding to the automated test script to the hash set; if there is hash data corresponding to the automated test script in the current hash set, then update the value of the hash data corresponding to the automated test script according to the current value of the hash data and the test result of the automated test script. The file type of the functional test case file includes mind map format and / or list; the processing module is further specifically used to obtain the name of each leaf node in the functional test case file when the file type of the functional test case file is mind map format, and query the hash set based on the name of each leaf node; when the file type of the functional test case file is list, obtain the content of each row under the test case name column in the functional test case file, and query the hash set based on the content of each row.

5. The apparatus according to claim 4, characterized in that, The test result includes one of the following: pass, fail, or partially pass; The step of updating the hash data value corresponding to the automated test script based on the current hash data value and the test result of the automated test script includes: If the current value of the hash data is consistent with the test result of the automated test script, or if the test result represented by the current value of the hash data is partially passed, then the value of the hash data will not be modified. If the test result represented by the current value of the hash data is not partially passed, and the current value of the hash data is inconsistent with the test result of the automated test script, then the value of the hash data is modified; wherein the modified value represents partially passed.

6. The apparatus according to claim 4, characterized in that, The processing module executes tests based on the automated test script file and obtains the test results of the multiple automated test scripts, specifically including: Determine the types of the plurality of automated test scripts in the automated test script file; Based on the type of the multiple automated test scripts, the corresponding execution command is executed to obtain the test results of the automated test scripts.

7. An electronic device, characterized in that, include: Memory, processor; Memory; Memory used to store the processor's executable instructions; The processor is configured to execute the method as described in any one of claims 1-3 according to the executable instructions.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-3.

Citation Information

Patent Citations

  • Automatic test verification method for GUI (Graphical User Interface) test

    CN107066376A

  • Test method and apparatus

    CN108459953A