Method, apparatus, electronic device and storage medium for generating test program
By generating and updating the coded array of the test program, the problem of FCT software program's test steps cannot be replaced or added or deleted is solved, and the flexibility and adaptability of the test program is improved, saving modification time and improving testing efficiency.
Patent Information
- Application Number
- CN202411437580.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2044-10-15
AI Technical Summary
The existing FCT software program test steps are fixed and cannot be flexibly replaced or added or deleted, resulting in poor flexibility and adaptability of the test program.
By obtaining the index information of the test program, generating an encoded array, updating the encoding based on the correction information, and generating the CSV file of the target test program, to achieve flexible replacement or deletion of the test steps.
Improves the flexibility and adaptability of the test program, saves modification time, and improves testing efficiency.
Smart Images

Figure CN119512850B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of testing technologies, and in particular, to a method, apparatus, electronic device, and storage medium for generating a test program. Background Art
[0002] Functional Circuit Test (FCT for short) generally specifically refers to the functional test after power-on of a Printed Circuit Board Assembly (PCBA for short), including: measurement of functional parameters such as voltage, current, power, power factor, frequency, duty cycle, position determination, LED brightness and color recognition, LCD character and color recognition, sound recognition, temperature measurement and control, pressure measurement and control, precise micro-motion control, on-line programming of FLASH and Electrically Erasable Programmable Read Only Memory (EEPROM for short), etc. At the same time, FCT refers to a test method that provides an analog operating environment (excitation and load) for the Unit Under Test (UUT for short), enables it to work in various design states, and thus obtains the parameters of each state to verify the functionality of the UUT.
[0003] Currently, the test steps in the FCT software program are usually fixedly written and cannot be swapped in order. For example, the order of a certain test step that needs to be tested first cannot be swapped either. At the same time, the test steps cannot be deleted either. For example, when a certain test step is not needed, it cannot be simply deleted from the test steps of the test program. That is, for the current FCT software program, if it is necessary to swap the order or add / delete steps of the steps (test subroutines) in the test program, it is necessary to make changes by modifying the code, resulting in poor flexibility and adaptability of the test program corresponding to the FCT software program.
[0004] Currently, no effective solution has been proposed for the problem of poor flexibility and adaptability of the test program corresponding to the FCT software program in the related art. Summary of the Invention
[0005] Embodiments of this application provide a method, apparatus, electronic device, and storage medium for generating a test program to at least solve the problem of poor flexibility and adaptability of the test program corresponding to the FCT software program in the related art.
[0006] First aspect, an embodiment of the present application provides a method for generating a test program, including: obtaining a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program, where the first index information is generated after loading the first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subprogram, and the second index information is the first index information corresponding to the selected second test subprogram; detecting, among all the first codes in the first code array corresponding to the first CSV file, the first code currently corresponding to each second index information, to obtain a plurality of second codes, where the sorting of the first codes is used to represent the execution order of each first test subprogram corresponding to the first index information in the currently executed test program; generating a third code associated with each second test subprogram based on the second codes and the correction information corresponding to all the second test subprograms, and updating the first code array according to the third code to generate a second code array, where the third code is used to represent the execution order of the second test subprogram in the target test program after correcting the execution order of all the second test subprograms according to the correction information; based on the second code array, correcting and updating the first CSV file to generate a second CSV file corresponding to the target test program, and initializing and generating the target test program according to the second CSV file.
[0007] Second aspect, an embodiment of the present application provides a device for generating a test program, including:
[0008] An obtaining module, configured to obtain a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program, where the first index information is generated after loading the first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subprogram, and the second index information is the first index information corresponding to the selected second test subprogram;
[0009] A detecting module, configured to detect, among all the first codes in the first code array corresponding to the first CSV file, the first code currently corresponding to each second index information, to obtain a plurality of second codes, where the sorting of the first codes is used to represent the execution order of each first test subprogram corresponding to the first index information in the currently executed test program;
[0010] A processing module, configured to generate a third encoding associated with each of the second test subroutines based on the second encoding and the correction information corresponding to all the second test subroutines, and update the first encoding array according to the third encoding to generate a second encoding array, where the third encoding is used to represent the execution order of the second test subroutines in the target test program after the execution order of all the second test subroutines is corrected according to the correction information;
[0011] A generation module, configured to correct and update the first CSV file based on the second encoding array to generate a second CSV file corresponding to the target test program, and initialize and generate the target test program according to the second CSV file.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, the steps of the method for generating a test program described in the first aspect are implemented.
[0013] In a fourth aspect, an embodiment of the present application provides a storage medium, on which a computer program is stored, and when the program is executed by a processor, the steps of the method for generating a test program described in the first aspect are implemented.
[0014] Compared with the related art, the method, device, electronic device and storage medium for generating a test program provided by the embodiments of the present application adopt obtaining a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program. The first index information is generated after loading the first CSV file corresponding to the test program into a preset table control. One first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to the selected second test subroutine. Among all the first codes in the first coding array corresponding to the first CSV file, each of the first codes currently corresponding to the second index information is detected to obtain a plurality of second codes. The sorting of the first codes is used to represent the execution order of each first test subroutine corresponding to the first index information in the currently executed test program. Based on the second codes and the correction information corresponding to all the second test subroutines, a third code associated with each second test subroutine is generated, and the first coding array is updated according to the third code to generate a second coding array. The third code is used to represent the execution order of the second test subroutine in the target test program after the execution order of all the second test subroutines is corrected according to the correction information. Based on the second coding array, the first CSV file is corrected and updated to generate a second CSV file corresponding to the target test program, and the target test program is initialized according to the second CSV file. By loading the CSV file corresponding to the test program into the table control to generate a coding array including a plurality of index information, encoding correction is performed on the codes corresponding to the selected index information according to the preset correction information, and after the sorting position of the index information in the coding array is changed, the execution order of the test steps of the test program is swapped or the test steps are deleted. The test steps of the test program are controllable, which solves the problem of poor flexibility and adaptability of the test program corresponding to the FCT software program in the related art, and realizes improving the flexibility of test program modification, saving the modification time of the test program, and improving the test efficiency.
[0015] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more comprehensible. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments and descriptions thereof of the present application are used to explain the present application and do not constitute an improper limitation of the present application. In the drawings:
[0017] Figure 1 is a hardware structure block diagram of a terminal for running the method for generating a test program according to the embodiments of the present application;
[0018] Figure 2 is a flowchart of a method for generating a test program according to an embodiment of the present application;
[0019] Figure 3 is a structural block diagram of a device for generating a test program according to an embodiment of the present application. Detailed implementation manners
[0020] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be described and explained below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments provided in the present application without making creative efforts fall within the scope of protection of the present application. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for those of ordinary skill in the art related to the content disclosed in the present application, some design, manufacturing or production changes based on the technical content disclosed in the present application are only conventional technical means and should not be understood that the content disclosed in the present application is insufficient.
[0021] Referring to "embodiment" in the present application means that a specific feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The phrase appears in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those of ordinary skill in the art explicitly and implicitly understand that the embodiments described in the present application can be combined with other embodiments without conflict.
[0022] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the ordinary meanings understood by those with ordinary skills in the technical field to which this application belongs. The words such as "a", "an", "one", "the" and the like involved in this application do not indicate a limitation in quantity and may represent a singular or plural number. The terms "comprise", "include", "have" and any variations thereof involved in this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may further include unlisted steps or units, or may further include other steps or units inherent to these processes, methods, products or devices. The "multiple steps" involved in this application refer to steps greater than or equal to two. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may represent: A exists alone, A and B exist simultaneously, and B exists alone. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.
[0023] The method embodiment provided in this embodiment can be executed on a terminal, a computer or a similar computing device. Taking running on a terminal as an example, Figure 1 is a hardware structure block diagram of a terminal for generating a test program for running the embodiment of this application. As Figure 1 shown, the terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the above terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above terminal. For example, the terminal may further include more or fewer components than those shown in Figure 1 the figure, or may have a different configuration from that shown in Figure 1 the figure.
[0024] The memory 104 can be used to store computer programs, for example, software programs of application software and modules, such as the computer program corresponding to the method for generating a test program in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the terminal through a network. Examples of the above network include but are not limited to the Internet, intranet, local area network, mobile communication network, and combinations thereof.
[0025] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the terminal. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one instance, the transmission device 106 can be a radio frequency (Radio Frequency, abbreviated as RF) module, which is used to communicate with the Internet wirelessly.
[0026] This embodiment provides a method for generating a test program that runs on the above terminal. Figure 2 It is a flowchart of the method for generating a test program according to an embodiment of the present application, as Figure 2 shown, and this process includes the following steps:
[0027] Step S201, obtain a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program, where the first index information is generated after loading the first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to the selected second test subroutine.
[0028] In this embodiment, the method for generating a test program is implemented when the currently executed test program fails to meet the corresponding test requirements. For example, if the voltage test step and the temperature measurement step in the currently executed test program need to be swapped in order, at this time, the current test program needs to be modified to generate a target test program that meets the corresponding test requirements. It can be understood that when it is determined that the current test program needs to be modified, it is necessary to first determine the test subprograms corresponding to the current test program and the execution order of each test subprogram. The execution order of each test subprogram is which test step the test subprogram executes during the execution of the entire test program. In this embodiment, the test subprograms corresponding to the current test program are obtained by loading the first CSV file corresponding to the test program into the table control of the editing program. That is, after clicking on the test program that needs to be modified in the editing program, the corresponding table control will load all the contents in the corresponding first CSV file, convert the obtained index information and the encoding corresponding to the index information into a two-dimensional array, and store it. At the same time, all the obtained index information will be displayed on the editing interface of the editing program, that is, the test subprograms corresponding to the current test program are determined. After the index information is displayed on the editing interface, the target object can select the index information of the test subprogram that needs to be corrected from the editing interface, that is, obtain the second index information.
[0029] Step S202, among all the first encodings in the first encoding array corresponding to the first CSV file, detect the first encoding currently corresponding to each second index information, and obtain a plurality of second encodings, where the sorting of the first encodings is used to represent the execution order of each first test subprogram corresponding to the first index information in the currently executed test program.
[0030] In this embodiment, during the process of modifying the first test subroutine of the test program, the arrangement order of the first index information of the first test subroutine (the serial number indicating which step the first test subroutine is executed at when the test program is executed) is modified. The program itself and program parameters corresponding to the first test subroutine are stored in a preset database. After generating the CSV file corresponding to the test program, by initializing the corresponding CSV file, the execution entity of the test program will retrieve the first test subroutine itself from the database according to the corresponding index information. Then, when the test program is executed, it will sequentially traverse each first test subroutine and execute the steps corresponding to the first test subroutine. Therefore, it can be understood that one first index information maps to one first test subroutine, and one first index information also represents the target information corresponding to one first test subroutine, such as: the test name of the test subroutine, relevant parameters (such as: upper limit, lower limit, and unit). In this embodiment, when modifying or deleting the execution order of the first test subroutine, by changing the encoding position of the corresponding first index information in the corresponding encoding array, that is, the test number. For example, when swapping the execution order of two first test subroutines with test numbers 001 and 003, just swap the positions of the first index information of the two first test subroutines or replace the encoding positions. For example, writing the first index information of the first test subroutine with test number 003 at the original encoding position of the first test subroutine with test number 001 means executing the swapping of the execution order of the two first test subroutines.
[0031] In this embodiment, before modifying or deleting the execution order of the first test subroutine, it is necessary to determine the current encoding position of the first index information corresponding to the corresponding first test subroutine in the first encoding array, that is, to determine the first encoding corresponding to the selected second index information currently, so as to provide initial parameters for subsequent modification of the test subroutine based on the expected correction target (such as: what kind of execution order replacement is made for the second test subroutine corresponding to the second index information) during the selection of the second index information for the target object.
[0032] Step S203: Based on the second encoding and the correction information corresponding to all the second test subroutines, generate a third encoding associated with each second test subroutine, and update the first encoding array according to the third encoding to generate a second encoding array, where the third encoding is used to represent the execution order of the second test subroutine in the target test program after correcting the execution order of all the second test subroutines according to the correction information.
[0033] In this embodiment, after determining the first code (i.e., the second code) currently corresponding to the selected second index information, based on the correction target made by the target object during the process of selecting the second index information (for example: selecting the first index information corresponding to the two first test subroutines with test numbers 001 and 003, and at the same time, making a choice to replace the execution order of the two first test subroutines with test numbers 001 and 003; another example: selecting the first index information corresponding to the first test subroutine with test number 002, and at the same time, making a choice to delete the first test subroutine with test number 002), the second code corresponding to the selected second index information is corrected, so as to update the coding position of the second test subroutine corresponding to the selected second index information in the coding array of the first CSV file, generating a new code, that is, generating a third code associated with each second test subroutine. Then, in the first coding array, the code corresponding to each second test subroutine is modified from the previous second code to the third code, thereby generating a second coding array.
[0034] Step S204: Based on the second coding array, correct and update the first CSV file to generate a second CSV file corresponding to the target test program, and initialize and generate the target test program according to the second CSV file.
[0035] In this embodiment, after determining the second coding array, it is determined that after the corresponding correction is completed, the execution steps of each corresponding test subroutine in the corresponding test program in the future. Then, according to the sorting of the corresponding execution steps, the selected second index information and all unselected first index information are sorted, and the data of the two-dimensional array is encoded, so as to generate a second CSV file based on the first CSV file.
[0036] In this embodiment, after generating the second CSV file, by loading the second CSV file and initializing, it is possible to traverse and call the target test subroutines, so that the execution entity of the test program can sequentially execute the corresponding target test subroutines according to the corresponding test steps, thereby performing the corresponding FCT test.
[0037] Through the above steps S201 to S204, multiple second index information selected from multiple first index information corresponding to the currently executed test program is obtained. The first index information is generated after loading the first CSV file corresponding to the test program into a preset table control. One first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to the selected second test subroutine. Among all the first codes in the first coding array corresponding to the first CSV file, each first code corresponding to the current second index information is detected to obtain multiple second codes. The sorting of the first codes is used to represent the execution order of each first test subroutine corresponding to the first index information in the currently executed test program. Based on the second codes and the correction information corresponding to all the second test subroutines, a third code associated with each second test subroutine is generated, and the first coding array is updated according to the third code to generate a second coding array. The third code is used to represent the execution order of the second test subroutine in the target test program after the execution order of all the second test subroutines is corrected according to the correction information. Based on the second coding array, the first CSV file is corrected and updated to generate a second CSV file corresponding to the target test program, and the target test program is initialized according to the second CSV file. By loading the CSV file corresponding to the test program into the table control to generate a coding array including multiple index information, encoding correction is performed on the codes corresponding to the selected index information according to the preset correction information, and after the sorting position of the index information in the coding array is changed, the execution order of the test steps of the test program is swapped or the test steps are deleted. The test steps of the test program are controllable, which solves the problem of poor flexibility and adaptability of the test program corresponding to the FCT software program in the related art, realizes improving the flexibility of test program modification, saving the modification time of the test program, and improving the test efficiency.
[0038] In some of these embodiments, generating a third code associated with each second test subroutine based on the second codes and the correction information corresponding to all the second test subroutines in step S203 is implemented through the following steps:
[0039] Step 21, according to the correction information, determine the correction mode for currently correcting the second test subroutine, where the correction mode includes modifying the execution order and deleting the test subroutine.
[0040] In this embodiment, the target object (for example: tester) makes a choice on what kind of correction will be made to the second test subroutine (one of the first test subroutines) corresponding to the selected second index information while selecting the corresponding second index information, that is, makes a choice on the correction mode of what kind of correction will be made to the selected second test subroutine.
[0041] Step 22, when the correction mode is execution order modification, detect the preset execution sequence numbers corresponding to each second test subroutine from the correction parameters corresponding to the correction mode, where the preset execution sequence numbers are used to represent the expected execution order of the second test subroutines in the target test program.
[0042] In this embodiment, the correction parameters are also generated correspondingly when the target object makes a correction selection. For example, three first test subroutines with encoding positions 003, 005, and 008 are selected in sequence, then the correction mode is selected as execution order modification, and the execution steps of the three first test subroutines are set to: first execute the first test subroutine with the encoding position of 005, then execute the first test subroutine with the encoding position of 008, and finally execute the first test subroutine with the encoding position of 003. The corresponding correction parameters include: first execute the first test subroutine with the encoding position of 005, then execute the first test subroutine with the encoding position of 008, and finally execute the first test subroutine with the encoding position of 003. At this time, the preset execution sequence numbers corresponding to the three first test subroutines are: 005, 008, 003.
[0043] Step 23, use the second encoding corresponding to the preset execution sequence number as the third encoding associated with the second test subroutine corresponding to the preset execution sequence number.
[0044] In this embodiment, after determining the correction parameters, the encoding positions that the selected first test subroutines (corresponding to the second test subroutines) are expected to be adjusted to are determined. For example, the encoding position of the first test subroutine with the encoding position of 003 is adjusted from 003 to 008, the encoding position of the first test subroutine with the encoding position of 005 is adjusted from 005 to 003, and the encoding position of the first test subroutine with the encoding position of 008 is adjusted from 008 to 005. It can be understood that before the correction, the second encodings associated with the selected first test subroutines (corresponding to the second test subroutines) are: 003, 005, 008. Because it is expected that after the correction, the corresponding preset execution sequence numbers will become: 005, 008, 003. At this time, the expected third encodings associated with the second test subroutines are: 005, 008, 003.
[0045] According to the correction information in the above steps 21 to 23, determine the correction mode for correcting the second test subroutine currently. The correction mode includes execution order modification and test subroutine deletion. In the case where the correction mode is execution order modification, detect the preset execution sequence number corresponding to each second test subroutine from the correction parameters corresponding to the correction mode. The preset execution sequence number is used to represent the expected execution order of the second test subroutine in the target test program. Use the second encoding corresponding to the preset execution sequence number as the third encoding associated with the second test subroutine corresponding to the preset execution sequence number, which realizes the correction of the second encoding corresponding to the selected second index information based on the correction target made by the target object during the process of selecting the second index information, thereby updating the encoding position of the second test subroutine corresponding to the selected second index information in the encoding array corresponding to the first CSV file, generating a new encoding, and providing updated correction parameters for generating the corresponding second CSV file later.
[0046] In some of these embodiments, the first encoding array is updated according to the third encoding to generate a second encoding array, which is implemented through the following steps:
[0047] Step 31, among all the first encodings in the first encoding array, detect all the first encodings except all the third encodings to obtain candidate encodings.
[0048] Step 32, arrange all the candidate encodings and all the third encodings in the order from the front to the back according to the sorting order to generate a second encoding array.
[0049] By detecting all the first encodings except all the third encodings among all the first encodings in the first encoding array in the above steps 31 to 32 to obtain candidate encodings, and arranging all the candidate encodings and all the third encodings in the order from the front to the back according to the sorting order to generate a second encoding array, it realizes the update of the first encoding data and generates new second encoding data.
[0050] In some of these embodiments, in the case where the correction mode is test subroutine deletion, the following steps are further implemented:
[0051] Step 41, in the first encoding array, sequentially delete multiple second encodings in the order from the front to the back according to the sorting order, and among all the first encodings in the first encoding array, detect all the first encodings located after the first deleted second encoding to obtain fourth encodings.
[0052] In this embodiment, when the target object (e.g., the tester) selects the corresponding second index information, the target object can choose to delete the second test subroutine (one of the first test subroutines) corresponding to the second index information. At this time, the corresponding correction parameter is eliminated due to the selection of the correction mode, which can also be understood as the operation of the correction mode on the correction parameter.
[0053] Step 42: Arrange all the fourth codes in ascending order, and arrange the fourth code ranked first in the position of the first deleted second code to generate a second code array.
[0054] In this embodiment, since the selected first test subroutine is deleted, the test steps corresponding to the first test subroutine are vacant. The first test subroutines after the first test subroutine naturally become the first test subroutines for the next test step to execute. Therefore, by moving the codes and index information corresponding to all the first test subroutines after each deleted second test subroutine forward by one step, the generation of the second code array is completed.
[0055] Through the above steps 41 to 42, in the first code array, multiple second codes are sequentially deleted in the order from the front to the back according to the sorting order, and among all the first codes in the first code array, all the first codes located after the first deleted second code are detected to obtain the fourth codes; all the fourth codes are arranged in ascending order, and the fourth code ranked first is arranged in the position of the first deleted second code to generate a second code array, realizing the update of the test program in the deletion mode.
[0056] In some of these embodiments, based on the second code array, the first CSV file is corrected and updated to generate a second CSV file corresponding to the target test program, which is achieved through the following steps:
[0057] Step 51: Obtain all the fifth codes corresponding to the second code array, and determine the third index information associated with each fifth code, where the third index information includes one of the first index information and the second index information.
[0058] Step 52: Among all the first test subroutines corresponding to the first CSV file, based on each third index information associated with each fifth code, determine the first test subroutine corresponding to each fifth code to obtain the target test subroutine.
[0059] In this embodiment, after determining the new second code array, establish the association between all the fifth codes in the second code array and the corresponding first test subroutines, and then determine all the target test subroutines corresponding to the target test program.
[0060] Step 53: Convert the target information corresponding to all target test subroutines and the corresponding fifth encoding into a two-dimensional array to generate a second CSV file.
[0061] In this embodiment, by converting the target information of the target test subroutine and the corresponding fifth encoding into a two-dimensional data, a loadable CSV file is formed. By loading and initializing the CSV file, an executable target test program can be obtained, and the FCT test can be performed according to the expected test steps.
[0062] By performing the above steps 51 to 53 to obtain all the fifth encodings corresponding to the second encoding array, and determining the third index information associated with each fifth encoding, where the third index information includes one of the first index information and the second index information; among all the first test subroutines corresponding to the first CSV file, based on each third index information associated with each fifth encoding, determine the first test subroutine corresponding to each fifth encoding to obtain the target test subroutine; convert the target information corresponding to all target test subroutines and the corresponding fifth encoding into a two-dimensional array to generate a second CSV file, thereby realizing the generation of the CSV file corresponding to the updated target test program.
[0063] In some embodiments, initializing and generating a target test program according to the second CSV file includes the following steps:
[0064] Step 61: After loading the second CSV file into the table control, obtain the target test subroutine corresponding to each fifth encoding.
[0065] Step 62: Initialize and load all target test subroutines according to the sorting of each fifth encoding to obtain the target test program.
[0066] In some embodiments, before obtaining the multiple second index information selected from the multiple first index information corresponding to the currently executed test program, the following steps are further implemented: Obtain the editing control selected by the user from the editing interface corresponding to the table control for loading the second CSV file to generate correction information, where one editing control corresponds to one correction mode.
[0067] This embodiment also provides a device for generating a test program. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used hereinafter, terms such as "module", "unit", "sub-unit", etc. can be a combination of software and / or hardware that can implement a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.
[0068] Figure 3is a structural block diagram of a generating device for a test program according to an embodiment of the present application, as Figure 3 shown, the device includes an obtaining module 31, a detecting module 32, a processing module 33, and a generating module 34, wherein,
[0069] The obtaining module 31 is configured to obtain a plurality of second index information selected from a plurality of first index information corresponding to a currently executed test program, wherein the first index information is generated after loading a first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to a selected second test subroutine;
[0070] The detecting module 32 is coupled to the obtaining module 31 and is configured to detect, among all first encodings of a first encoding array corresponding to the first CSV file, each first encoding currently corresponding to each second index information, to obtain a plurality of second encodings, wherein the sorting of the first encodings is used to represent the execution order of each first test subroutine corresponding to each first index information in the currently executed test program;
[0071] The processing module 33 is coupled to the detecting module 32 and is configured to generate a third encoding associated with each second test subroutine based on the second encodings and correction information corresponding to all second test subroutines, and update the first encoding array according to the third encodings to generate a second encoding array, wherein the third encodings are used to represent the execution order of the second test subroutines in a target test program after the execution order of all second test subroutines is corrected according to the correction information;
[0072] The generating module 34 is coupled to the processing module 33 and is configured to correct and update the first CSV file based on the second encoding array to generate a second CSV file corresponding to the target test program, and initialize and generate the target test program according to the second CSV file.
[0073] Through the above generating device, multiple second index information selected from multiple first index information corresponding to the currently executed test program is obtained. The first index information is generated after loading the first CSV file corresponding to the test program into a preset table control. One first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to the selected second test subroutine. Among all the first codes in the first coding array corresponding to the first CSV file, each first code corresponding to the current second index information is detected to obtain multiple second codes. The sorting of the first codes is used to represent the execution order of the first test subroutines corresponding to each first index information in the currently executed test program. Based on the second codes and the correction information corresponding to all the second test subroutines, a third code associated with each second test subroutine is generated, and the first coding array is updated according to the third code to generate a second coding array. The third code is used to represent the execution order of the second test subroutines in the target test program after the execution order of all the second test subroutines is corrected according to the correction information. Based on the second coding array, the first CSV file is corrected and updated to generate a second CSV file corresponding to the target test program, and the target test program is initialized according to the second CSV file. By loading the CSV file corresponding to the test program into the table control to generate a coding array including multiple index information, and according to the preset correction information, the coding corresponding to the selected index information is corrected. After realizing the replacement of the sorting position of the index information in the coding array, the execution order of the test steps of the test program is swapped or the test steps are deleted, and the test steps of the test program are controllable, which solves the problem of poor flexibility and adaptability of the test program corresponding to the FCT software program in the related art, realizes improving the flexibility of test program modification, saving the modification time of the test program, and improving the test efficiency.
[0074] In some of the embodiments, the processing module 33 further includes:
[0075] A first determination unit, configured to determine a correction mode for currently correcting the second test subroutine according to the correction information, where the correction mode includes execution order modification and test subroutine deletion.
[0076] A first detection unit, coupled to the first determination unit, is configured to, when the correction mode is execution order modification, detect a preset execution sequence number corresponding to each second test subroutine from the correction parameters corresponding to the correction mode, where the preset execution sequence number is used to represent the expected execution order of the second test subroutine in the target test program.
[0077] The first processing unit, which is coupled to the first detection unit, is configured to use the second code corresponding to the preset execution sequence number as the third code associated with the second test subroutine corresponding to the preset execution sequence number.
[0078] In some embodiments, the processing module 33 is further configured to detect all the first codes in the first code array except all the third codes to obtain candidate codes; arrange all the candidate codes and all the third codes in the order from the front to the back according to the sorting order to generate a second code array.
[0079] In some embodiments, when the correction mode is to delete the test subroutine, the generating device is further configured to sequentially delete a plurality of second codes in the first code array in the order from the front to the back according to the sorting order, and detect all the first codes located after the first deleted second code in all the first codes in the first code array to obtain fourth codes; arrange all the fourth codes in ascending order, and arrange the fourth code with the first sorting in the position of the first deleted second code to generate a second code array.
[0080] In some embodiments, the generating module 34 further includes:
[0081] The first obtaining unit is configured to obtain all the fifth codes corresponding to the second code array and determine the third index information associated with each fifth code, where the third index information includes one of the first index information and the second index information.
[0082] The second determining unit, which is coupled to the first obtaining unit, is configured to determine the first test subroutine corresponding to each fifth code based on each third index information associated with each fifth code in all the first test subroutines corresponding to the first CSV file to obtain the target test subroutine.
[0083] The first generating unit, which is coupled to the second determining unit, is configured to perform a two-dimensional array conversion on the target information corresponding to all the target test subroutines and the corresponding fifth codes to generate a second CSV file.
[0084] In some embodiments, the generating module 34 is further configured to obtain the target test subroutine corresponding to each fifth code after loading the second CSV file into the table control; initialize and load all the target test subroutines according to the sorting of each fifth code to obtain the target test program.
[0085] In some of these embodiments, before obtaining a plurality of second index information selected from a plurality of first index information corresponding to a currently executed test program, the generating device is further configured to obtain an editing control selected by a user from an editing interface corresponding to the table control for loading the second CSV file, so as to generate the correction information, where one editing control corresponds to one correction mode.
[0086] This embodiment further provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0087] Optionally, the above electronic device may further include a transmission device and an input / output device. The transmission device is connected to the above processor, and the input / output device is connected to the above processor.
[0088] Optionally, in this embodiment, the above processor may be configured to execute the following steps through a computer program:
[0089] S1, obtain a plurality of second index information selected from a plurality of first index information corresponding to a currently executed test program, where the first index information is generated after loading a first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subprogram, and the second index information is the first index information corresponding to a selected second test subprogram.
[0090] S2, in all first codes of the first coding array corresponding to the first CSV file, detect the first code currently corresponding to each second index information, and obtain a plurality of second codes, where the sorting of the first codes is used to represent the execution order of each first test subprogram corresponding to the first index information in the currently executed test program.
[0091] S3, based on the second codes and the correction information corresponding to all second test subprograms, generate a third code associated with each second test subprogram, and update the first coding array according to the third code to generate a second coding array, where the third code is used to represent the execution order of the second test subprogram in the target test program after the execution order of all second test subprograms is corrected according to the correction information.
[0092] S4, based on the second coding array, correct and update the first CSV file to generate a second CSV file corresponding to the target test program, and initialize and generate the target test program according to the second CSV file.
[0093] It should be noted that the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.
[0094] In addition, in combination with the method for generating a test program in the above embodiments, an embodiment of the present application can be implemented by providing a storage medium. A computer program is stored on the storage medium; when the computer program is executed by a processor, the method for generating any one of the test programs in the above embodiments is implemented.
[0095] Those skilled in the art should understand that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0096] The above embodiments only represent several implementation manners of the present application, and the description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A method for generating a test program, characterized in that, Including: Obtaining a plurality of second index information selected from a plurality of first index information corresponding to a currently executed test program, wherein the first index information is generated after loading a first CSV file corresponding to the test program into a preset table control, and one first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to a selected second test subroutine; Detecting, among all first encodings of a first encoding array corresponding to the first CSV file, each first encoding currently corresponding to the second index information, to obtain a plurality of second encodings, wherein the sorting of the first encodings is used to represent the execution order of each first test subroutine corresponding to the first index information in the currently executed test program; Generating a third encoding associated with each second test subroutine based on the second encoding and correction information corresponding to all the second test subroutines, and updating the first encoding array according to the third encoding to generate a second encoding array, wherein the third encoding is used to represent the execution order of the second test subroutine in a target test program after correcting the execution order of all the second test subroutines according to the correction information; Based on the second encoding array, correcting and updating the first CSV file to generate a second CSV file corresponding to the target test program, and initializing and generating the target test program according to the second CSV file, wherein Generating a third encoding associated with each second test subroutine based on the second encoding and correction information corresponding to all the second test subroutines, including: Determining a correction mode for currently correcting the second test subroutine according to the correction information, wherein the correction mode includes execution order modification and test subroutine deletion; When the correction mode is execution order modification, detecting, from correction parameters corresponding to the correction mode, a preset execution sequence number corresponding to each second test subroutine, wherein the preset execution sequence number is used to represent the expected execution order of the second test subroutine in the target test program; Taking the second encoding corresponding to the preset execution sequence number as the third encoding associated with the second test subroutine corresponding to the preset execution sequence number; Updating the first encoding array according to the third encoding to generate a second encoding array, including: Detecting, among all the first encodings of the first encoding array, all the first encodings except all the third encodings to obtain candidate encodings; Arranging all the candidate encodings and all the third encodings in the order from front to back in the sorting order to generate the second encoding array.
2. The generation method according to claim 1, wherein When the correction mode is test subroutine deletion, the method further includes: In the first encoding array, delete a plurality of the second encodings in the order from front to back according to the sorting order, and detect all the first encodings in all the first encodings of the first encoding array that are located after the first deleted second encoding to obtain a fourth encoding; Arrange all the fourth encodings in ascending order, and arrange the fourth encoding sorted first in the position of the first deleted second encoding to generate the second encoding array.
3. The generation method according to claim 1, characterized in that Based on the second encoding array, correct and update the first CSV file to generate a second CSV file corresponding to the target test program, including: Obtain all the fifth encodings corresponding to the second encoding array, and determine the third index information associated with each fifth encoding, where the third index information includes one of the first index information and the second index information; In all the first test subroutines corresponding to the first CSV file, based on each third index information associated with each fifth encoding, determine the first test subroutine corresponding to each fifth encoding to obtain a target test subroutine; 4. The generation method according to claim 3, wherein Perform two-dimensional array conversion on the target information corresponding to all the target test subroutines and the corresponding fifth encodings to generate the second CSV file. Initialize and generate the target test program according to the second CSV file, including: After loading the second CSV file into the table control, obtain the target test subroutine corresponding to each fifth encoding; 5. The generation method according to claim 1, characterized in that Initialize and load all the target test subroutines according to the sorting of each fifth encoding to obtain the target test program.
6. A generating device for a test program, characterized in that, Before obtaining a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program, the method further includes: obtaining an editing control selected by a user from an editing interface corresponding to the table control loading the second CSV file to generate the correction information, where one editing control corresponds to one correction mode. Including: An obtaining module, configured to obtain a plurality of second index information selected from a plurality of first index information corresponding to the currently executed test program, where the first index information is generated after loading the first CSV file corresponding to the test program into a preset table control, one first index information corresponds to one first test subroutine, and the second index information is the first index information corresponding to the selected second test subroutine; A detecting module, configured to detect the first encoding currently corresponding to each second index information in all the first encodings of the first encoding array corresponding to the first CSV file to obtain a plurality of second encodings, where the sorting of the first encoding is used to represent the execution order of the first test subroutine corresponding to each first index information in the currently executed test program; a processing module, configured to generate a third code associated with each second test subroutine based on the second code and correction information corresponding to all the second test subroutines, and to update the first code array according to the third code to generate a second code array, wherein the third code is used to represent the execution order of the second test subroutines in the target test program after the execution order of all the second test subroutines is corrected according to the correction information; a generating module, configured to modify and update the first CSV file based on the second encoding array to generate a second CSV file corresponding to the target test program, and initialize and generate the target test program according to the second CSV file, wherein the processing module further includes: A first determining unit is configured to determine a current correction mode for correcting the second test subroutine based on the correction information, wherein the correction mode includes executing order modification and test subroutine deletion; a first detection unit, coupled to the first determination unit, for detecting, when the correction mode is execution order modification, a preset execution order number corresponding to each second test subroutine from the correction parameters corresponding to the correction mode, wherein the preset execution order number is used to represent an expected execution order of the second test subroutine in the target test program; a first processing unit coupled to the first detection unit and configured to use the second code corresponding to the preset execution sequence number as the third code associated with the second test subroutine corresponding to the preset execution sequence number; The processing module is further configured to detect all first codes except all third codes among all first codes in the first code array to obtain candidate codes; and arrange all candidate codes and all third codes in a sorted order from front to back to generate a second code array.
7. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to run the computer program to perform the steps of the test program generation method according to any one of claims 1 to 5.
8. A storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by a processor, the test program generation method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Ordered batch test method and system, terminal and storage medium
CN111338964A
Method, device and system for generating test sample
CN116560969A