Software testing method and device, storage medium and terminal
By dynamically importing the test keyword module and executing the test method, the problem of inefficiency caused by the instability of the Ride editor is solved, and efficient test result generation and accuracy improvement are achieved.
Patent Information
- Application Number
- CN202410888729.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-11-22
AI Technical Summary
The efficiency and accuracy of traditional manual testing methods are difficult to meet the requirements of information product update and iteration speed, and the instability of the Ride editor leads to failure to save use case configuration information, import exceptions and retraction problems, affecting testing efficiency.
By obtaining test cases in Excel tables, dynamically import test keyword modules, instantiate and execute test methods, generate test results, and use Python's dynamic import mechanism to reduce startup time and memory usage to avoid import exceptions.
Improves testing efficiency, avoids use case storage failures and import exceptions caused by editor instability, reduces memory usage, and enhances test accuracy.
Smart Images

Figure CN119003330A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a software testing method and device, a storage medium, and a terminal. Background Art
[0002] Traditional manual testing usually adopts the method of writing use cases first and then testing. The testing efficiency and accuracy cannot meet the update and iteration speed requirements of rapidly developing information products, and it also requires a lot of manpower and cost resources.
[0003] In order to solve the above problems, the Robot Framework keyword-driven test framework has been widely used. Its core idea is to separate the writing and execution of test cases, and to implement specific test steps by calling pre-defined operations to improve the test efficiency and low accuracy. However, first of all, due to the slow response of the Ride editor of the Robot Framework keyword-driven test framework, or even the uncertainty of stuck, it is very easy to cause the completed use case configuration information to fail to be saved successfully, resulting in all previous efforts being wasted, thereby reducing the test efficiency; secondly, since the Ride editor needs to manually import dependent libraries, it is easy to have import exceptions, which affects the writing of test scripts, and there are cases where the import library explodes due to unknown reasons, and the corresponding operations cannot be used, and a restart is required to solve the problem. Restarting the editor may cause the completed use case configuration information to fail to be saved successfully; finally, due to the fact that the cells of the Ride editor are retracted and cannot be saved, the complete parameters cannot be viewed when doing interface testing, and the cells need to be manually lengthened for viewing, thereby slowing down the test efficiency. Therefore, a software testing method is urgently needed to improve the above problems. Summary of the invention
[0004] In view of this, the present application provides a software testing method and device, storage medium, and terminal, the main purpose of which is to improve the existing problem of low testing efficiency caused by editor instability and the need to manually stretch cells in the editor to view complete parameters.
[0005] According to one aspect of the present application, a software testing method is provided, comprising:
[0006] Obtain an Excel table to be run for the target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword;
[0007] Dynamically import the keyword module corresponding to the test keyword, assign the keyword module to a first variable, obtain a class from the first variable, instantiate the class, call the instantiated class method to assign it to a second variable, and execute the second variable;
[0008] The test result of the target test object is generated based on the test result of each of the test cases.
[0009] Preferably, the dynamically importing the keyword module corresponding to the test keyword and assigning the keyword module to the first variable includes:
[0010] Determine the storage path of the keyword module, the storage path is the path from the project root directory to the keyword module;
[0011] According to the storage path, using the import built-in function, the keyword module is imported into the sys.modules built-in function, where the sys.modules built-in function is used to store loaded modules;
[0012] The keyword module is obtained from the sys.modules built-in function and assigned to the first variable.
[0013] Preferably, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to the second variable, and executing the second variable includes:
[0014] Using the getattr built-in method, obtaining the class from the first variable, and assigning the class to the third variable;
[0015] Instantiating the third variable, and assigning the instantiated third variable to the fourth variable;
[0016] The class method is called from the fourth variable using the getattr built-in method, the class method is assigned to the second variable, and the second variable is executed.
[0017] Preferably, before dynamically importing the keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable, the method further includes:
[0018] A plurality of keyword modules are created in advance and stored in a keyword database, so that corresponding keyword modules are dynamically imported from the keyword database according to the test keyword, wherein the keyword module contains corresponding classes, and the name of the class is the same as the file name of the keyword module.
[0019] Preferably, the step of obtaining an Excel table to be run for the target test object and reading each test case from the Excel table to be run includes:
[0020] In response to a test instruction for the target test object, selecting a matching Excel file according to the category of the target test object;
[0021] An Excel table to be run is selected from the Excel file, and each test case is read from the Excel table to be run.
[0022] Preferably, the test case also carries corresponding configuration parameters, wherein the configuration parameters include the trigger position coordinates of the button screenshot, and the trigger position coordinates are used to complete the automated clicking task of the button.
[0023] Preferably, after generating the test result of the target test object based on the test results of each of the test cases, the method further comprises:
[0024] Determine the personnel to receive the test results based on the team organizational structure;
[0025] Obtain the email address of the person to be received, and send the test result to the email address.
[0026] According to another aspect of the present application, a software testing device is provided, comprising:
[0027] A test case reading module is used to obtain an Excel table to be run for a target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword;
[0028] A test execution module, used for dynamically importing a keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable;
[0029] The test result generating module is used to generate the test result of the target test object based on the test result of each of the test cases.
[0030] Preferably, the test execution module is used to:
[0031] Determine the storage path of the keyword module, the storage path is the path from the project root directory to the keyword module;
[0032] According to the storage path, using the import built-in function, the keyword module is imported into the sys.modules built-in function, where the sys.modules built-in function is used to store loaded modules;
[0033] The keyword module is obtained from the sys.modules built-in function and assigned to the first variable.
[0034] Preferably, the test execution module is further used to:
[0035] Using the getattr built-in method, obtaining the class from the first variable, and assigning the class to the third variable;
[0036] Instantiating the third variable, and assigning the instantiated third variable to the fourth variable;
[0037] The class method is called from the fourth variable using the getattr built-in method, the class method is assigned to the second variable, and the second variable is executed.
[0038] Preferably, before the test execution module, the device further includes:
[0039] The keyword module creation module is used to pre-create multiple keyword modules and store them in a keyword database so as to dynamically import corresponding keyword modules from the keyword database according to the test keyword. The keyword module contains corresponding classes, and the name of the class is the same as the file name of the keyword module.
[0040] Preferably, the test case reading module is used to:
[0041] In response to a test instruction for the target test object, selecting a matching Excel file according to the category of the target test object;
[0042] An Excel table to be run is selected from the Excel file, and each test case is read from the Excel table to be run.
[0043] Preferably, the test case also carries corresponding configuration parameters, wherein the configuration parameters include the trigger position coordinates of the button screenshot, and the trigger position coordinates are used to complete the automated clicking task of the button.
[0044] Preferably, after the test result generating module, the device further includes a test result sending module, which is used to:
[0045] Determine the personnel to receive the test results based on the team organizational structure;
[0046] Obtain the email address of the person to be received, and send the test result to the email address.
[0047] According to another aspect of the present application, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the testing method of the above-mentioned software.
[0048] According to another aspect of the present application, there is provided a terminal, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0049] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the testing method of the above software.
[0050] By means of the above technical solution, the technical solution provided by the embodiment of the present application has at least the following advantages:
[0051] The present application provides a software testing method and device, storage medium, and terminal. First, an Excel table to be run for a target test object is obtained, and each test case is read from the Excel table to be run, and the test case carries a corresponding test keyword; secondly, a keyword module corresponding to the test keyword is dynamically imported, the keyword module is assigned to a first variable, and a class is obtained from the first variable, the class is instantiated, the instantiated class method is called and assigned to a second variable, and the second variable is executed; finally, the test result of the target test object is generated based on the test results of each test case. Compared with the prior art, the embodiment of the present application, on the one hand, reads the test case through an Excel table with strong stability, avoids the unsuccessful saving of the use case configuration information due to the instability of the editor, thereby improving the test efficiency; on the other hand, based on Python, the keyword module corresponding to the test keyword is dynamically imported, because the required module is imported according to the demand, rather than all modules are loaded, the startup time is reduced and the memory usage is reduced, and at the same time, the import abnormality that may occur due to the manual import of the dependent library is avoided, thereby improving the test efficiency.
[0052] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0054] Figure 1 A flowchart of a software testing method provided by an embodiment of the present application is shown;
[0055] Figure 2 A flowchart of another software testing method provided in an embodiment of the present application is shown;
[0056] Figure 3 A button screenshot provided in an embodiment of the present application is shown;
[0057] Figure 4 A block diagram of a software testing device provided in an embodiment of the present application is shown;
[0058] Figure 5 A schematic diagram of the structure of a terminal provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0059] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0060] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0061] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present application, its application, or uses.
[0062] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0063] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0064] The embodiments of the present application can be applied to computer systems / servers, which can operate with many other general or special computing system environments or configurations. Examples of well-known computing systems, environments and / or configurations suitable for use with computer systems / servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0065] Computer systems / servers may be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. In general, program modules may include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers may be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules may be located on local or remote computing system storage media including storage devices.
[0066] The present application embodiment provides a software testing method, such as Figure 1 As shown, the method includes:
[0067] 101. Obtain an Excel spreadsheet to be run for the target test object, and read each test case from the Excel spreadsheet to be run.
[0068] Among them, the test case carries the corresponding test keywords, for example, open_app, sleep, etc.; the test object can be a web test, an API interface test, an Android application test, etc.; the Excel table is used to store the test case and the corresponding keyword database, test keywords, multiple configuration parameters, etc. In an embodiment of the present application, the current execution end can be a test module of the software, which uses the openpyxl library to load the Excel file, read the test cases of a single table or all tables, and display the read test cases in the form of a dictionary. In a specific application scenario, the first row of the Excel table can be used as the key of the dictionary, for example, "test steps" as the key, and the actual steps as the value. It should be noted that a test case can contain multiple test steps, for example, "test steps": "open the browser", "enter the URL".
[0069] 102. Dynamically import the keyword module corresponding to the test keyword, assign the keyword module to the first variable, obtain the class from the first variable, instantiate the class, call the instantiated class method to assign it to the second variable, and execute the second variable.
[0070] The first variable is used to represent the md variable, which is used to store the dynamically imported keyword module for use in subsequent codes; the second variable is used to represent the keyword variable, which is used to store the class method to execute the test case. In the embodiment of the present application, the keyword module is imported and then the class method is obtained from it.
[0071] It should be noted that in order to reduce coupling and improve the reuse rate of code, in the embodiment of the present application, the keyword module and the class method are stored one-to-one, and the two are set to the same name. Based on this, the class method written in the Excel table cannot be called using the traditional package import method, and direct operation will result in an error. Therefore, in the embodiment of the present application, Python's dynamic import mechanism is used for dynamic package import, which avoids the import anomalies that may occur due to manual import of dependent libraries and improves test efficiency; and using Python's dynamic import mechanism, it is possible to import the required modules according to demand instead of loading all modules, which reduces startup time and reduces memory usage.
[0072] 103. Generate test results of the target test object based on the test results of each test case.
[0073] In the embodiment of the present application, the test results of all test cases are counted to obtain the test results of the target test object, wherein the test results of the target test object can be displayed in the form of an HTML report. Specifically, a Web service can be created through the Flask framework to display the HTML report of the test results. First, the test summary data of the homepage index.html is displayed through the " / result" route. Further, the test summary data can be queried from the database to generate an HTML table. Further, by clicking on each test case, based on the " / detail / <report_date> "The route enters the detail.html page and displays the test details of the detail page, that is, the situation of each step executed by the current test case, including error information.
[0074] Compared with the prior art, the embodiments of the present application, on the one hand, reads test cases through a highly stable Excel spreadsheet, thereby avoiding the unsuccessful saving of test case configuration information due to editor instability, thereby improving test efficiency; on the other hand, based on Python's dynamic import of keyword modules corresponding to test keywords, since the required modules are imported according to demand instead of loading all modules, the startup time and memory usage are reduced, and at the same time, import anomalies that may occur due to manual import of dependent libraries are avoided, thereby improving test efficiency.
[0075] The present application embodiment provides another software testing method, such as Figure 2 As shown, the method includes:
[0076] 201. In response to a test instruction for a target test object, select a matching Excel file according to a category of the target test object.
[0077] Among them, the categories of test objects may include web testing, API interface testing, Android application testing, etc. In the embodiment of the present application, in response to the test instructions for the target test object, go to the cases directory where the test cases are stored, and select a matching Excel file according to the category of the test object. It should be noted that there are multiple Excel files stored in the cases directory, including web automation test files, API interface automation test files, Android application automation test files, etc., which store corresponding test cases respectively. It can be understood that the structure of each Excel file is the same, the difference is that the file names are different, which can be used to distinguish. In addition, demo can also be included, and the filling method can refer to demo.
[0078] 202. Select an Excel table to be run from the Excel file, and read each test case from the Excel table to be run.
[0079] In the embodiment of the present application, after the Excel file is determined according to the category of the test object, the Excel table to be run can be selected from the Excel file, which can be a specified one or several tables, or all tables. For example, when specifying a table, the table name sheet name can be manually entered. If the manually entered table name is not received within a preset time (such as 30s), Table 1 or other default tables can be automatically executed; when multiple tables are specified, they can be separated by English commas and Enter can be clicked; when all tables need to be run, they can be automatically executed after setting a preset time (such as 5s). Further, each test case is read from the Excel table to be run.
[0080] 203. Dynamically import the keyword module corresponding to the test keyword, and assign the keyword module to the first variable.
[0081] Specifically, determine the storage path of the keyword module. The storage path is the path from the project root directory to the keyword module. It can be understood that, first of all, it is necessary to determine the location of the keyword module in the project, and it is necessary to piece together the complete path from the project root directory to the keyword module before the keyword module can be imported. If the path is incomplete, it cannot be imported. Further, according to the storage path, the keyword module is imported into the sys.modules built-in function using the import built-in function. The sys.modules built-in function is used to store loaded modules. The sys.modules built-in function can be understood as a dictionary for storing loaded modules. Finally, get the keyword module from the sys.modules built-in function and assign it to the first variable md for use in subsequent codes, thereby completing the import of the keyword module.
[0082] 204. Obtain a class from the first variable, instantiate the class, call the instantiated class method to assign it to the second variable, and execute the second variable.
[0083] In an embodiment of the present application, first, the getattr built-in method is used to obtain the class from the first variable md, and the class is assigned to the third variable cls; further, the third variable cls is instantiated. Specifically, the instantiation can be achieved by adding brackets "()" after the third variable cls, and the instantiated third variable is assigned to the fourth variable instance; finally, the getattr built-in method is used to call the class method from the fourth variable instance, the class method is assigned to the second variable keyword, and the second variable keyword is executed. Specifically, the execution operation can be achieved by adding brackets "()" after the second variable keyword. In addition, if keyword needs to pass in parameters, it only needs to be passed in in the brackets after the function name.
[0084] It should be noted that before dynamically importing the keyword module corresponding to the test keyword, assigning the keyword module to the first variable, obtaining the class from the first variable, instantiating the class, calling the instantiated class method to assign it to the second variable, and executing the second variable, the embodiment method also includes: pre-creating multiple keyword modules, storing them in a keyword database, so as to dynamically import the corresponding keyword modules from the keyword database according to the test keyword, the keyword module contains the corresponding class, and the name of the class is the same as the file name of the keyword module.
[0085] Specifically, the embodiment of the present application can use MySQL database to store the execution information of the test case. The tester needs to deploy the database locally or on the server in advance and build a fixed table name and column name to store the packaged keyword database, which can include web automation test files, API interface automation test files, Android application automation test files, encryption and decryption, and custom storage parameters, etc., and write the keywords to be used in Excel, and then write the keywords in each library to realize the function of calling the corresponding class method. In addition, the corresponding parameter description of the class method can also be included to help the tester understand, so that testers without coding ability can also perform test tasks.
[0086] In addition, you need to import the tool module and project configuration file. The tool module is used to store custom tools, including database tools for executing SQL statements, and a rollback mechanism can be configured to prevent data from being destroyed; it can also include a logging tool for printing information when the use case is executed; it can also include an Excel reading tool for piecing together the information in the Excel table, such as test cases, keyword databases, test keywords, configuration parameters, etc. into a dictionary and reading it out. The configuration file can include the request address, database configuration information, mailbox configuration information, project path, etc., to facilitate direct calls in the code.
[0087] It can be understood that when starting the test, a communication connection is first established between the current execution end and the keyword database and the ADB debug bridge. In the embodiment of the present application, the adb tool is needed to obtain the currently linked Android device ID, the device resolution, etc., and it can also support multi-device links so that testers can freely select devices.
[0088] 205. Generate test results of the target test object based on the test results of each test case.
[0089] In the embodiment of the present application, the test results of the target test object are generated based on the test results of each test case. The specific process has been described in detail in step 103 of the embodiment and will not be repeated here.
[0090] 206. Determine the person to receive the test results based on the team organizational structure; obtain the email address of the person to receive the test results, and send the test results to the email address.
[0091] Among them, the team organizational structure is used to record the personnel relationships within and outside the team, including superior-subordinate relationships, cooperative relationships, etc. In the embodiment of the present application, the personnel who need the test results to carry out the next task can be determined based on the cooperative relationships in the team organizational structure, and they can be determined as the personnel to be received; the superior reviewer who needs to confirm the test results can be determined based on the superior-subordinate relationships in the team organizational structure, and they can be determined as the personnel to be received. Furthermore, the email address of the above-mentioned personnel to be received is obtained, and the test results are sent to the email address.
[0092] In addition, you can manually add people who need to receive the test results, and send the test results to the designated person's email address based on the pre-stored mapping relationship between the person and the email address.
[0093] In one embodiment of the present application, for further definition and explanation, the test case also carries corresponding configuration parameters, the configuration parameters include the trigger position coordinates of the button screenshot, and the trigger position coordinates are used to complete the automated clicking task of the button.
[0094] The button screenshot is as follows Figure 3 As shown, the trigger position coordinates are used to characterize Figure 3 The numbers 1-9 on the middle button screenshot.
[0095] Specifically, you can take a screenshot of a button in the App and save it in a specified folder, for example, the ScreenShot folder. You can name it arbitrarily. The screenshot format can be PNG format, JPG format, etc. At the same time, the keyword module is required to support the 9 position coordinates of clicking the screenshot.
[0096] It should be noted that, according to the clarity of the button screenshot, the corresponding position coordinates can be selected as the trigger position coordinates and added to the configuration parameters of the test case, so that the automatic clicking task of the button can be realized when the trigger position coordinates are clicked. For example, when the button screenshot is relatively clear, the position coordinate 5 can be used as the trigger position coordinate; when the button screenshot is not clear, the button and the clear area around it can be screenshoted together, and then a clear position can be selected from the 9 position coordinates as the trigger position coordinate.
[0097] In an embodiment of the present application, for further limitation and explanation, a log file for recording logs generated during this test may also be included. Exemplarily, the log file may be in the format of time-log level-running initiator-step information. Each time the test is started, the previous log information may be cleared to facilitate quick location of the problem in this test.
[0098] The present application provides a software testing method, firstly, obtaining an Excel table to be run for a target test object, reading each test case from the Excel table to be run, the test case carrying a corresponding test keyword; secondly, dynamically importing a keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable; finally, generating a test result of the target test object based on the test results of each of the test cases. Compared with the prior art, the embodiment of the present application, on the one hand, reads the test case through an Excel table with strong stability, avoids the unsuccessful saving of the use case configuration information due to the instability of the editor, thereby improving the test efficiency; on the other hand, based on Python dynamically importing the keyword module corresponding to the test keyword, because the required modules are imported according to the demand, rather than loading all modules, the startup time is reduced and the memory usage is reduced, and at the same time, the import abnormality that may occur due to the manual import of the dependent library is avoided, thereby improving the test efficiency.
[0099] Furthermore, as a response to the above Figure 1 To implement the method shown, the present application embodiment provides a software testing device, such as Figure 4 As shown, the device comprises:
[0100] Test case reading module 31, test execution module 32, test result generation module 33.
[0101] The test case reading module 31 is used to obtain an Excel table to be run for a target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword;
[0102] A test execution module 32, used for dynamically importing a keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable;
[0103] The test result generating module 33 is used to generate the test result of the target test object based on the test result of each of the test cases.
[0104] In a specific application scenario, the test execution module is used to:
[0105] Determine the storage path of the keyword module, the storage path is the path from the project root directory to the keyword module;
[0106] According to the storage path, using the import built-in function, the keyword module is imported into the sys.modules built-in function, where the sys.modules built-in function is used to store loaded modules;
[0107] The keyword module is obtained from the sys.modules built-in function and assigned to the first variable.
[0108] In a specific application scenario, the test execution module is also used to:
[0109] Using the getattr built-in method, obtaining the class from the first variable, and assigning the class to the third variable;
[0110] Instantiating the third variable, and assigning the instantiated third variable to the fourth variable;
[0111] The class method is called from the fourth variable using the getattr built-in method, the class method is assigned to the second variable, and the second variable is executed.
[0112] In a specific application scenario, before the test execution module, the device further includes:
[0113] The keyword module creation module is used to pre-create multiple keyword modules and store them in a keyword database so as to dynamically import corresponding keyword modules from the keyword database according to the test keyword. The keyword module contains corresponding classes, and the name of the class is the same as the file name of the keyword module.
[0114] In a specific application scenario, the test case reading module is used to:
[0115] In response to a test instruction for the target test object, selecting a matching Excel file according to the category of the target test object;
[0116] An Excel table to be run is selected from the Excel file, and each test case is read from the Excel table to be run.
[0117] In a specific application scenario, the test case also carries corresponding configuration parameters, and the configuration parameters include the trigger position coordinates of the button screenshot, and the trigger position coordinates are used to complete the automatic clicking task of the button.
[0118] In a specific application scenario, after the test result generating module, the device further includes a test result sending module, which is used to:
[0119] Determine the personnel to receive the test results based on the team organizational structure;
[0120] Obtain the email address of the person to be received, and send the test result to the email address.
[0121] The present application provides a software testing device, firstly, obtaining an Excel table to be run for a target test object, reading each test case from the Excel table to be run, the test case carrying a corresponding test keyword; secondly, dynamically importing a keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable; finally, generating a test result of the target test object based on the test results of each test case. Compared with the prior art, the embodiment of the present application, on the one hand, reads the test case through an Excel table with strong stability, avoids the unsuccessful saving of the test case configuration information due to the instability of the editor, thereby improving the test efficiency; on the other hand, based on Python dynamically importing the keyword module corresponding to the test keyword, because the required modules are imported according to the demand, rather than loading all modules, the startup time is reduced and the memory usage is reduced, and at the same time, the import abnormality that may occur due to the manual import of the dependent library is avoided, thereby improving the test efficiency.
[0122] According to an embodiment of the present application, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the software testing method in any of the above method embodiments.
[0123] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0124] Figure 5 A schematic diagram of the structure of a terminal provided according to an embodiment of the present application is shown, and the specific embodiment of the present application does not limit the specific implementation of the terminal.
[0125] like Figure 5 As shown, the terminal may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0126] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0127] The communication interface 404 is used to communicate with other devices such as clients or other servers.
[0128] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above software testing method embodiment.
[0129] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0130] The processor 402 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the computer device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0131] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0132] The program 410 may be specifically configured to enable the processor 402 to perform the following operations:
[0133] Obtain an Excel table to be run for the target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword;
[0134] Dynamically import the keyword module corresponding to the test keyword, assign the keyword module to a first variable, obtain a class from the first variable, instantiate the class, call the instantiated class method to assign it to a second variable, and execute the second variable;
[0135] The test result of the target test object is generated based on the test result of each of the test cases.
[0136] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device of the test method of the above software, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0137] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0138] The method and system of the present application may be implemented in many ways. For example, the method and system of the present application may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present application are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present application may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present application. Therefore, the present application also covers a recording medium storing a program for executing the method according to the present application.
[0139] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.
[0140] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A software testing method, characterized in that: include: Obtain an Excel table to be run for the target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword; Dynamically import the keyword module corresponding to the test keyword, assign the keyword module to a first variable, obtain a class from the first variable, instantiate the class, call the instantiated class method to assign it to a second variable, and execute the second variable; The test result of the target test object is generated based on the test result of each of the test cases.
2. The method according to claim 1, characterized in that The dynamically importing the keyword module corresponding to the test keyword and assigning the keyword module to the first variable includes: Determine the storage path of the keyword module, the storage path is the path from the project root directory to the keyword module; According to the storage path, using the import built-in function, the keyword module is imported into the sys.modules built-in function, where the sys.modules built-in function is used to store loaded modules; The keyword module is obtained from the sys.modules built-in function and assigned to the first variable.
3. The method according to claim 2, characterized in that The obtaining of a class from the first variable, instantiating the class, calling the instantiated class method to assign it to the second variable, and executing the second variable includes: Using the getattr built-in method, obtaining the class from the first variable, and assigning the class to the third variable; Instantiating the third variable, and assigning the instantiated third variable to the fourth variable; The class method is called from the fourth variable using the getattr built-in method, the class method is assigned to the second variable, and the second variable is executed.
4. The method according to any one of claims 1 to 3, characterized in that: Before dynamically importing the keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method and assigning it to a second variable, and executing the second variable, the method further includes: A plurality of keyword modules are created in advance and stored in a keyword database, so that corresponding keyword modules are dynamically imported from the keyword database according to the test keyword, wherein the keyword module contains corresponding classes, and the name of the class is the same as the file name of the keyword module.
5. The method according to claim 1, characterized in that The step of obtaining an Excel table to be run for a target test object and reading each test case from the Excel table to be run includes: In response to a test instruction for the target test object, selecting a matching Excel file according to the category of the target test object; An Excel table to be run is selected from the Excel file, and each test case is read from the Excel table to be run.
6. The method according to claim 1, characterized in that The test case also carries corresponding configuration parameters, which include the trigger position coordinates of the button screenshot, and the trigger position coordinates are used to complete the automatic clicking task of the button.
7. The method according to claim 1, characterized in that After generating the test result of the target test object based on the test results of each of the test cases, the method further includes: Determine the personnel to receive the test results based on the team organizational structure; Obtain the email address of the person to be received, and send the test result to the email address.
8. A software testing device, characterized in that: include: A test case reading module is used to obtain an Excel table to be run for a target test object, and read each test case from the Excel table to be run, wherein the test case carries a corresponding test keyword; A test execution module, used for dynamically importing a keyword module corresponding to the test keyword, assigning the keyword module to a first variable, obtaining a class from the first variable, instantiating the class, calling the instantiated class method to assign it to a second variable, and executing the second variable; The test result generating module is used to generate the test result of the target test object based on the test result of each of the test cases.
9. A storage medium, wherein at least one executable instruction is stored in the storage medium, characterized in that: The executable instructions enable the processor to execute operations corresponding to the software testing method according to any one of claims 1 to 7.
10. A terminal, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, wherein the executable instruction enables the processor to execute an operation corresponding to the software testing method according to any one of claims 1-7.
