Automatic test case data updating method and device and computer storage medium

By using an automated test case data update method, the TST files of the VectorCAST tool are updated in batches using the information in the CSV file, which solves the problem of test case batch update failure in the existing technology and improves test efficiency.

CN120631747APending Publication Date: 2025-09-12中汽新能(天津)电池科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510575100.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-06
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

In existing technologies, the VectorCAST tool cannot update test cases in batches, requiring testers to manually modify each one, which is inefficient.

Method used

This paper provides an automated test case data update method. By reading batch test case information from a CSV file and performing variable value replacement operations in sequence, the test cases are updated from a first format file to a second format file. The method is particularly suitable for TST files of the VectorCAST tool.

Benefits of technology

It enables rapid batch updating of test cases, improves testing efficiency, and avoids the inefficiency of duplication of work and manual modification of each case.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631747A_ABST
    Figure CN120631747A_ABST
Patent Text Reader

Abstract

The invention discloses an automatic test case data updating method and device and a computer storage medium. The updating method comprises the following steps: in response to a file reading instruction, reading a first format file containing batch test cases, and extracting batch test case names, input / output variable names and variable types in the first format file; variable value replacement operation is executed based on the sequence of the extracted batch test cases, the value of the input / output variable of each test case in the first format is replaced into the corresponding input / output variable of the corresponding test case in the second format to be stored, and the corresponding test case of the second format file is obtained. According to the test case updating method and device, the read variables of the test cases in the first format file can be updated to the second format file for storing the test script through the preset scanning replacement updating technology, the function requirement for rapidly updating all the test cases is met, and therefore the problem that in the prior art, the test cases cannot be updated in batches is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of test case updating, and in particular to a method and device for updating automated test case data, and a computer storage medium. Background Art

[0002] During software testing, testers typically need to write numerous test cases. These clearly define input variables and expected output variables, and are often combined with automated testing tools to complete testing tasks. When requirements change, the corresponding test cases must also be updated due to changes in the functionality and methods implemented. However, the characteristics of different testing tools lead to different approaches for testers when updating test cases.

[0003] VectorCAST is a dynamic automated testing tool for C / C++ code from Vector, enabling both unit / integration and system testing. Adhering to industry standards such as ASPICE and ISO 26262, VectorCAST is suitable for embedded systems with high security and reliability requirements, reducing development risk and improving code quality.

[0004] The VectorCAST tool itself has the function of adding or deleting test cases. By using CSV (Comma-Separated Values) files to write test cases and then importing them into the VectorCAST tool, multiple test cases can be added with one click. When necessary, they can be combined to test more complex application scenarios.

[0005] However, if the application policy changes, the test cases need to be changed synchronously according to the policy. The tool cannot batch update the imported test cases, and these test cases can only be modified manually one by one. If you want to update multiple test cases, you need to delete all the test cases and re-import the updated test cases to retest. The test case operation steps involving combined testing are more cumbersome, such as Figure 11 ,This feature greatly reduces the testing efficiency of testers.

[0006] To match this testing tool, a method that can quickly update test cases is needed to improve testing efficiency. Summary of the Invention

[0007] The purpose of the present invention is to overcome the deficiencies and defects of the prior art and to provide a method and device for updating automated test case data, and a computer storage medium.

[0008] An object of the present invention is to provide a method for updating automated test case data, comprising the steps of:

[0009] In response to the file reading instruction, the first format file containing the batch test cases is read, and the batch test case names, input / output variable names and variable types in the first format file are extracted;

[0010] Variable value replacement operations are performed based on the order of the extracted batch test cases, and the values ​​of the input / output variables of each test case in the first format are replaced with the corresponding input / output variables of the corresponding test case in the second format and saved to obtain the corresponding test case of the second format file.

[0011] Preferably, before the step of executing the variable value replacement operation based on the order of the extracted batch test cases, the step also includes a step of determining whether the input / output variable name matches the number of variable types. If they match, the step of executing the variable value replacement operation based on the order of the extracted batch test cases is performed, otherwise the step ends.

[0012] Preferably, the step of performing a variable value replacement operation based on the order of the extracted batch test cases, replacing the value of the input / output variable of each test case in the first format with the corresponding input / output variable of the corresponding test case in the second format and saving the value, includes:

[0013] Scan the second format file line by line according to each test case name;

[0014] After scanning the corresponding test case name, scan the input / output variable names under this test case name;

[0015] After the input / output variable name is scanned, the value of the input / output variable in the first format is replaced with the input / output variable of the corresponding test case in the second format and saved.

[0016] Preferably, when scanning line by line in the second format file according to each test case name, if no test case name is scanned after the line-by-line scanning detection is completed, the test case update is directly terminated.

[0017] Preferably, when scanning the input / output variable names under the test case name, if no variable is scanned, the scanning of the input / output variables of this test case is exited.

[0018] Preferably, when each test case scans to the last line, it also includes:

[0019] Determine whether this test case has any input / output variables that have not been scanned and recorded. If so, rescan the input / output variables that have not been scanned and recorded.

[0020] Preferably, if the number of rescans reaches a preset number of scans and it is determined that there are still variables that have not been scanned and recorded, the scan of this test case is exited and an exception is reported.

[0021] Preferably, the first format file is a CSV file, and the second format file is a TST file.

[0022] Another object of the present invention is to provide a device for updating automated test case data, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for updating the automated test case data.

[0023] Another object of the present invention is to provide a computer storage medium having a readable computer program stored thereon, which implements the method for updating the automated test case data when executed by a processor.

[0024] After startup, the method of the present invention can update the variables of the test cases read in the first format file to the second format file storing the test script through a preset scanning and replacing update technology, thereby achieving the functional requirement of quickly updating all test cases, thereby solving the problem of being unable to update test cases in batches under the existing technology.

[0025] The method of the present invention is particularly suitable for updating the test cases in a TST file storing VectorCAST test scripts using the test cases in a CSV file. That is, the test cases in the TST file are updated based on the test case information in the CSV file, replacing the conventional method of updating existing test cases in VectorCAST software. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 This is a flowchart of a method for updating automated test case data according to an embodiment of the present invention.

[0027] Figure 2 A schematic diagram of the format of a CSV file according to an embodiment of the present invention.

[0028] Figure 3 This is a schematic diagram of the unmodified TST file content according to an embodiment of the present invention.

[0029] Figure 4 Schematic diagram of the TST file content modified after using the method of an embodiment of the present invention.

[0030] Figure 5 Provide a detailed flowchart of the test case update method for this patent.

[0031] Figure 6 This is a diagram showing the results of a successful update test case according to an embodiment of the present invention.

[0032] Figure 7-10 This is a diagram showing information displayed during the update test case process of an embodiment of the present invention.

[0033] Figure 11 Schematic diagram of how to update test cases for existing VectorCAST tools. DETAILED DESCRIPTION

[0034] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0035] See also Figure 1 As shown, in an embodiment of the present application, a method for updating automated test case data is provided, comprising the steps of:

[0036] S1 response file read instruction, read the first format file containing batch test cases, extract the first format file batch test case name, input / output variable name and variable type;

[0037] S2. Execute the variable value replacement operation based on the order of the extracted batch test cases, replace the value of the input / output variable of each test case in the first format with the corresponding input / output variable of the corresponding test case in the second format and save it to obtain the corresponding test case of the second format file.

[0038] In an embodiment of the present application, before the step of performing the variable value replacement operation based on the order of the extracted batch test cases, the step of determining whether the input / output variable names match the number of variable types is further included. If so, the step of performing the variable value replacement operation based on the order of the extracted batch test cases is performed, otherwise the step is terminated. That is, in the present application, after reading or extracting the batch test case names, input / output variable names, and variable types in the first format file, it is first necessary to determine whether the input / output variable names match the number of variable types. If not, the subsequent processing flow is terminated and the update process is no longer executed. If they do match, the subsequent flow is continued to execute and the variable value replacement operation of the test case is performed.

[0039] In an embodiment of the present application, the variable value replacement operation is performed based on the order of the extracted batch test cases, and the value of the input / output variable of each test case in the first format is replaced with the corresponding input / output variable of the corresponding test case in the second format and saved, including the following steps:

[0040] According to each test case name, scan line by line in the second format file; after scanning the corresponding test case name, scan the input / output variable name under this test case name; after scanning the input / output variable name, replace the value of the input / output variable in the first format with the input / output variable of the corresponding test case in the second format and save it.

[0041] Among them, in the first format file, there is more than one test case, and there can be multiple test cases. In the case of multiple test cases, the above process is executed for each test case, and its input / output variables are replaced.

[0042] Among them, there are multiple input / output variables under each test case. Specifically, when scanning the input / output variables, after scanning one input / output variable and completing the update of the corresponding value, other input / output variables are scanned and updated until all input / output variables are scanned and updated, combined with the scanning and updating of this test case.

[0043] Since the present application is to use the test cases in the first format file to update the test cases in the second format file, in the embodiment of the present application, when scanning line by line in the second format file according to each test case name, if the corresponding test case name is not scanned when the line-by-line scanning detection is completed, it is considered that the conditions for test case update are not met, and the test case update is directly terminated.

[0044] In addition, since the present application is to use the test cases in the first format file to update the test cases in the second format file, in the embodiment of the present application, when scanning the input / output variable names under the test case name, if the corresponding input / output variables are not scanned, it will be considered that the update conditions are not met, and the scanning of the input / output variables of this test case will be exited.

[0045] During the test case scanning process, in order to prevent omission of updates of input / output variables of a test case, in the embodiment of the present application, when each test case is scanned to the last line, the following steps are further included:

[0046] Determine whether this test case has any input / output variables that have not been scanned and recorded. If so, rescan the input / output variables that have not been scanned and recorded.

[0047] The type and number of the corresponding input / output variables for each or each test case are fixed. During each scanning process mentioned above, they will be recorded or marked when scanned. Based on the record of the scanning process, it can be determined whether the input / output variables have not been scanned and recorded, thereby effectively determining whether the entire scan is completed. If it is determined that the scan is not completed, it is necessary to rescan.

[0048] For example, if the number of rescans reaches a preset number of scans, such as 3 times, and it is determined that there are still variables that have not been scanned and recorded, the scan of this test case is exited and the exception is reported. If the variables are scanned within the preset number of scans and there are no more variables that have not been scanned and recorded, the scan update of this test case is completed.

[0049] Exemplarily, in an embodiment of the present application, the first format file is a CSV file (file with a CSV suffix), and the second format file is a TST file (file with a TST suffix).

[0050] In an exemplary embodiment of the present application, the method for updating automated test case data can be applied to situations where the test cases in a CSV file are used to update the test cases in a TST file that stores VectorCAST test scripts. The test cases in the CSV file can be quickly updated to the TST file that stores the VectorCAST test scripts, thereby achieving rapid update of test cases and improving testing efficiency.

[0051] Specifically, in an embodiment of the present application, when updating test cases in a TST file storing a VectorCAST test script, the test case name, input variables, and expected output variable names are searched in the TST file storing the VectorCAST test script. If the above information is found, the values ​​corresponding to the variables in the CSV file are replaced in the TST file to achieve the requirements of batch and rapid updating of test cases.

[0052] The following is an example of updating the TST file storing the VectorCAST test script according to the CSV file. The specific implementation process of this application is as follows: Figure 5 As shown, the steps include the following:

[0053] Among them, before extracting or reading the test case of the CSV file, a file selection step is included: first, select the CSV file storing the test case, determine whether the selected file is a CSV file (CSV suffix file), if not, wait for the CSV file to be selected until the selection is completed, and after the CSV file selection is completed, proceed to the step of selecting the TST file; if so, enter the step of selecting the TST file (if not, it is not allowed to enter the step of selecting the TST file. If the selected file is not a TST file, it will not enter the subsequent process and wait for the selected file to be a TST file);

[0054] After completing the CSV and TST file selection through the above file selection, enter the file reading and variable update operation steps: read the CSV file to determine whether the CSV format is correct. If not, an error message will be displayed, and then the test case update will be ended directly; if so, the test case name, input / output variable name and variable type in the CSV file will be extracted; after completing the content extraction, determine whether the variable name and type quantity match; if the variable name and type quantity do not match successfully, an error message will be displayed, and then the test case update will be ended directly; if the match is completed, the TST file will be read and the TST file will be scanned line by line; search in the TST file according to the test case name of the CSV file, if it is found line by line If the test is completed and no test case is searched, the test case update will be ended directly; if the corresponding test case can be searched in the TST file according to the test case name, the input and output variable names of the test case will be searched after the test case name; if the variable name in any CSV file is not found in the test case, the test case will be recorded and the variable search for the test case will be exited; if the variable name in the CSV file is searched, the value of each variable in the CSV file will be replaced with the variable of the corresponding test case in the TST file and recorded; among them, when the last line of this test case is found, it is judged according to the record result whether all the variables in this test case have been searched and replaced ;

[0055] If all variables are searched and updated, the update of this test case is completed and the search for other test case names continues; if there are other variables that have not been searched, the unrecorded variables are searched again in this test case, and repeated multiple times, such as 3 times; if there are still other variables that have not been searched, the search of this test case is exited; after determining that all test case updates are completed, save the processed TST file and end this test case update.

[0056] Through the above method, the purpose of quickly updating test cases in batches can be achieved;

[0057] Specifically, in the embodiment of the present application, for a CSV file, there are multiple rows, wherein the first row is an invalid data row. The first two cells in the first row have no data and are not involved in the judgment of the variable type. The content is to facilitate understanding when manually reading the CSV file; the first two cells in the second row are NAMES and NOTES, representing names and comments respectively. The contents of these two cells are not searched as valid data in the TST file. The third cell specifies the type of input / output variables, that is, starting from the third cell, the information in each cell represents the variable name of each test case. The format of the cell content adopts the form of "variable type: variable name". The variable types are input or output types, which are reflected in the file as IN or OUT. The actual situation is IN:ABC or OUT:ABC, etc. The variable name can be manually specified. Starting from the third row, each row is a test case, wherein the first cell is the name of this test case, and the second cell is the comment of this test case, but the comment information does not participate in the positioning and modification process of the test case. Starting from the third cell, the specific values ​​of each variable are as follows. Figure 2 shown.

[0058] Below, the data format of CSV file and TST file is used as an example to illustrate the update process of the specific test case of the embodiment of the present application. Figures 2 to 10 As shown:

[0059] The first step is to select the storage path for the CSV file. If the selected file is not a CSV file, it cannot be displayed or selected. The second step is to select the storage path for the TST file. If the selected file is not a TST file, it cannot be displayed or selected. The third step is to select the two files, click Start Processing, and then update the test case.

[0060] After starting the test case update process, search the test case name in the first column of CSV in the TST file. At the same time, due to the characteristics of the TST file, when searching for the test case name, make sure that the line above the line where the test case name is located is "TEST.NEW" (such as Figure 3 As shown), the current line is "TEST.NAME: use case name", and the next line is "TEST.NOTES:"; when all the above conditions are met at the same time, the test case is found. The specific situation in the file is as follows Figure 3 As shown in the position where the test case name is marked;

[0061] Among them, after completing the search for a test case, it is necessary to record and print the name of the test case found, such as Figure 7As shown, you can see that the terminal prints out the test case name information that meets the requirements. After completing the test case name search, continue searching after the line where the test case name is located. If the first found content is "TEST.END_NOTES", then search for each variable name in the test case from that line onwards. The specific situation in the file is as follows Figure 3 The test case input variable name position is marked as shown in the figure;

[0062] According to the variable name starting from the third cell of the second row of CSV and its variable type, search in the next row of the row where the above content is located. If the variable type is "IN", the starting content of the variable row in the TST file is "TEST.VALUE:" and there is "< <global>>.Variable name:"; Only after the above conditions are met can the variable be found. If the variable type is "OUT", the starting content of the variable line in the TST file is "TEST.EXPECTED:" and there is also "< <global>>.Variable name:"; only then can we confirm that the variable has been found. In the above, statements are allowed between the prefix and GLOBAL of each line. The specific situation in the file is as follows Figure 3 The test case variable name is marked as shown in the position;

[0063] After completing the variable query, replace the value of the corresponding variable in the CSV file with the "< <global>>.Variable name:" and record and print, such as Figure 8 As shown in the figure, we can see that the corresponding variables are found and updated in each test case. If "TEST.END" is found for the first time during the process of searching for variables line by line, it means that the variable query for this test case is completed. The specific situation in the file is as follows: Figure 3 The test case ending position is marked in the middle. At this point, if each variable is recorded successfully, it means that all the input and output variables in the CSV are found in the test case and the value replacement is completed. You can continue to query the next test case. If some variables are not recorded, it means that some variables are not found. At this time, the query position returns to the most recent line with "TEST.END_NOTES:" and re-queries the unmarked variables, such as three times in a loop. If there are still variables that are not recorded and printed after three queries, an exception message is reported, and then the variable is skipped and the query continues, such as Figure 9 As shown, you can see that the variable names that do not exist in the TST file but exist in the CSV file are printed out in the terminal.

[0064] After completing all variable queries and replacements for each test case, report the completed replacement information, such as Figure 7 and Figure 2 As shown, the test case name and test case variable information can be found and printed in the terminal, and the replacement is completed.

[0065] Among them, when the last line of the TST file is found, if all test case names have been recorded and printed as found, the test case update operation is ended and the replacement is completed; if the test case name in the CSV file is not found in the TST file, the exception information is reported and the test case search is ended. Figure 10 and Figure 2 As shown, it can be seen that the test cases named ISO_CASE9_004 and ISO_CASE9_005 are printed in the terminal and exist in the CSV file, but are not found in the TST file.

[0066] Among them, after completing the update of this test case, the replaced file will be saved as a new TST file. The storage location is consistent with the original TST file address. The processed TST file will be saved as the original file name_processed.tst, such as Figure 6 As shown, it can display the update completion and the storage path.

[0067] After completing the test case update, open the original file name _processed.tst. Taking ISO_CASE9_003 as an example, you can see that the values ​​of each variable in the updated test case have changed according to the values ​​entered in the CSV file, as shown in the following example: Figure 2 、 Figure 3 、 Figure 4 As shown, you can see Figure 4 The updated test case variable values ​​are displayed Figure 3 The comparison of values ​​before and after the update can be done according to Figure 2 The input value is updated accordingly, indicating that the test case is updated successfully.

[0068] Take the VectorCAST tool update test case as an example, Figure 11 As shown in the figure, when VectorCAST uses CSV files for test case management, it has the function of adding or deleting test cases. By adding or deleting test cases, the addition or deletion of test cases can be completed. However, it does not have the function of batch modifying imported test cases. The operation method is as follows Figure 11 As shown, in the method for updating test cases, the update of some test cases is implemented by modifying and saving one by one; the update of all test cases is implemented by deleting all, re-importing and combining.

[0069] By adopting the method or technology of the embodiments of the present application, in a scenario where existing test cases need to be updated in batches, all test cases can be directly replaced and automatically updated according to the contents of the CSV file, thereby achieving the purpose of automatic batch modification of test cases, thereby effectively increasing the testing efficiency of testers, avoiding the repetitive work caused by deleting all test cases and the inefficiency of manually modifying test cases one by one.

[0070] Another object of an embodiment of the present application is to provide a device for updating automated test case data, comprising one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for updating the automated test case data.

[0071] Another object of an embodiment of the present application is to provide a computer storage medium having a readable computer program stored thereon, which, when executed by a processor, implements the method for updating the automated test case data.

[0072] From the above, it can be seen that the method of the embodiment of the present application, after startup, can update the variables of the test cases in the read first format file to the second format file storing the test script through the preset scan replacement update technology, thereby achieving the functional requirement of quickly updating all test cases, thereby solving the problem of being unable to update test cases in batches under the existing technology.

[0073] The method of the embodiment of the present application is particularly suitable for updating the test cases in a TST file that stores VectorCAST test scripts using the test cases in a CSV file. That is, the test cases in the TST file are updated based on the test case information in the CSV file, replacing the conventional method of updating existing test cases in the VectorCAST software.

[0074] The basic principles, main features and advantages of the present invention are shown and described above. It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments and that the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention.

[0075] The embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are therefore intended to be embraced therein.

[0076] In addition, it should be understood that although this specification is described in terms of implementation methods, not every implementation method contains only one independent technical solution. This narrative method of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other implementation methods that can be understood by those skilled in the art.< / global> < / global> < / global>

Claims

1. A method for updating automated test case data, characterized in that: Contains steps: In response to the file reading instruction, the first format file containing the batch test cases is read, and the batch test case names, input / output variable names and variable types in the first format file are extracted; Variable value replacement operations are performed based on the order of the extracted batch test cases, and the values ​​of the input / output variables of each test case in the first format are replaced with the corresponding input / output variables of the corresponding test case in the second format and saved to obtain the corresponding test case of the second format file.

2. The method for updating automated test case data according to claim 1, characterized in that: Before the step of executing the variable value replacement operation based on the order of the extracted batch test cases, the step also includes determining whether the input / output variable name matches the number of variable types. If so, the step of executing the variable value replacement operation based on the order of the extracted batch test cases is performed, otherwise the step ends.

3. The method for updating automated test case data according to claim 1, characterized in that: The step of performing a variable value replacement operation based on the order of the extracted batch test cases, replacing the value of the input / output variable of each test case in the first format with the corresponding input / output variable of the corresponding test case in the second format and saving the value, includes: Scan the second format file line by line according to each test case name; After scanning the corresponding test case name, scan the input / output variable names under this test case name; After the input / output variable name is scanned, the value of the input / output variable in the first format is replaced with the input / output variable of the corresponding test case in the second format and saved.

4. The method for updating automated test case data according to claim 3, characterized in that: When scanning the second format file line by line for each test case name, if no test case name is scanned after the line-by-line scanning is completed, the test case update is directly terminated.

5. The method for updating automated test case data according to claim 3, characterized in that: When scanning the input / output variable names under the test case name, if no variable is scanned, the scanning of the input / output variables of this test case is exited.

6. The method for updating automated test case data according to claim 3, characterized in that: When each test case scans to the last line, it also includes: Determine whether this test case has any input / output variables that have not been scanned and recorded. If so, rescan the input / output variables that have not been scanned and recorded.

7. The method for updating automated test case data according to claim 6, characterized in that: If the number of rescans reaches the preset number of scans and it is determined that there are still variables that have not been scanned and recorded, the scan of this test case will be exited and the exception will be reported.

8. The method for updating automated test case data according to claim 1, characterized in that: The first format file is a CSV file, and the second format file is a TST file.

9. The device for updating automated test case data is characterized in that: The invention comprises one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for updating automated test case data as described in any one of claims 1 to 8.

10. A computer storage medium, characterized in that A readable computer program is stored thereon, and when the program is executed by a processor, the method for updating automated test case data as described in any one of claims 1 to 8 is implemented.