A method, apparatus, and medium for executing test cases

By converting test cases into Excel files and executing them using a Python interpreter and the pytest framework, the problem of ordinary testers executing complex test cases is solved, improving testing efficiency and coverage.

CN115168230BActive Publication Date: 2026-06-26JINAN INSPUR DATA TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINAN INSPUR DATA TECH CO LTD
Filing Date
2022-07-27
Publication Date
2026-06-26

Smart Images

  • Figure CN115168230B_ABST
    Figure CN115168230B_ABST
Patent Text Reader

Abstract

The application discloses a method, device and medium for executing test cases, and is suitable for the technical field of testing. Based on the extension of pytest test framework, the test cases are converted into excel file information containing interface test information, the interface parameter information is obtained by reading the excel file information and configuration information through a Python interpreter; the interface parameter information is configured through the parameter passing mode and pre-post steps of the pytest test framework to execute the corresponding test cases, and request information is sent to the server to obtain the execution result; and the test result is obtained by comparing the execution result with the expected result of the test case. Even without experienced and skilled testers, the current complex test case execution can be completed, the difficulty of writing automated test cases is greatly reduced, the coverage level of automated testing is improved, and the efficiency of executing test cases is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of testing technology, and in particular to a method, apparatus, and medium for executing test cases. Background Technology

[0002] With the continuous improvement of informatization, network data is experiencing explosive growth, placing higher demands on server data storage capabilities. Meanwhile, the increasingly mainstream distributed massive storage systems, due to their complex structure and numerous functions, are leading to increasingly complex test case execution and a continuously rising total number of test cases.

[0003] Existing automated remote testing methods often require maintaining a large number of test scripts to execute test cases. This increases the complexity of script execution and demands comprehensive skills and expertise from testers. For ordinary testers with limited experience or skills, executing test cases can be difficult, leading to longer execution times and impacting subsequent operations.

[0004] Therefore, finding a method for executing test cases is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] The purpose of this invention is to provide a method, apparatus, and medium for executing test cases, which greatly reduces the difficulty of writing automated test cases, helps to improve the coverage level of automated tests, and improves the efficiency of executing test cases.

[0006] To address the aforementioned technical problems, this invention provides a method for executing test cases, comprising:

[0007] Obtain test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information;

[0008] The Python interpreter reads information from the Excel file and configuration information to obtain interface parameter information.

[0009] Configure the interface parameter information by using the parameter passing method, pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and send request information to the server to obtain the execution results;

[0010] Compare the execution results with the expected results of the test cases to obtain the test results.

[0011] Preferably, the process of converting information from an Excel file includes the following steps:

[0012] Write test cases within the test scope;

[0013] Fill in the Excel file according to the interface test cases;

[0014] Enter the titles of each heading in the first row of the Excel file;

[0015] Fill in the test cases according to the titles;

[0016] Each of the second to Nth rows in the Excel file corresponds to one API request.

[0017] Each worksheet in the Excel file corresponds to the interface test information under the same test case category.

[0018] The process of converting interface test information under the same test case category into corresponding test cases is completed to complete the conversion of information in the Excel file.

[0019] Preferably, the interface parameter information is obtained by reading the Excel file information and configuration information through a Python interpreter, including:

[0020] Read the configuration information to obtain the hierarchical relationship of test case types and test case hierarchy;

[0021] Determine the configuration level of test cases based on the hierarchical relationships;

[0022] Read the interface test information from the Excel file and determine the interface parameter information of the test cases by matching it with the configuration level.

[0023] Preferably, sending a request to the server to obtain the execution result includes:

[0024] Send API request information to the server via HTTP / HTTPS protocol to obtain execution results.

[0025] Preferably, comparing the execution result with the expected result of the test case to obtain the test result includes:

[0026] Obtain the execution steps of the test cases corresponding to the execution results;

[0027] If each execution step meets the expected completion rate, the test result is considered successful.

[0028] If at least one execution step fails to meet the expected completion rate, the test result is determined to be a failure.

[0029] Preferably, before comparing the execution result with the expected result of the test case to obtain the test result, the method further includes:

[0030] If the execution time of a test case exceeds the preset time, the skip command is invoked to skip the test case and execute the next test case.

[0031] The flag command is invoked to mark test cases as expected failure cases.

[0032] Preferably, it also includes;

[0033] Obtain the results of each execution step;

[0034] Summarize the results of each step and generate a test report in HTML format.

[0035] To address the aforementioned technical problems, the present invention also provides an apparatus for executing test cases, comprising:

[0036] The acquisition module is used to acquire test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information.

[0037] The reading module is used to read information from an Excel file and configuration information using the Python interpreter to obtain interface parameter information.

[0038] The execution module is used to configure the interface parameter information through the parameter passing method, pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and send request information to the server to obtain the execution results;

[0039] The comparison module is used to compare the execution results with the expected results of the test cases to obtain the test results.

[0040] To address the aforementioned technical problems, the present invention also provides an apparatus for executing test cases, comprising:

[0041] Memory, used to store computer programs;

[0042] A processor is used to implement the steps of executing test cases as described above when executing a computer program.

[0043] To address the aforementioned technical problems, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for executing test cases as described above.

[0044] This invention provides a method for executing test cases, comprising: acquiring test cases and corresponding configuration information, and converting the test cases into an Excel file containing interface test information; reading the Excel file information and configuration information through a Python interpreter to obtain interface parameter information; configuring the interface parameter information using the parameter passing method, pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and sending a request to the server to obtain the execution results; comparing the execution results with the expected results of the test cases to obtain the test results. This method is an extension of the pytest testing framework. By converting test cases into Excel files containing interface test information and outputting test results through a Python interpreter and the pytest testing framework, even inexperienced and unskilled testers can complete the execution of complex test cases, greatly reducing the difficulty of writing automated test cases, improving the coverage of automated tests, and increasing the efficiency of test case execution.

[0045] In addition, the present invention also provides an apparatus and medium for executing test cases, which have the same beneficial effects as the method for executing test cases described above. Attached Figure Description

[0046] To more clearly illustrate the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A flowchart illustrating a method for executing test cases provided in an embodiment of the present invention;

[0048] Figure 2 A schematic diagram of an Excel spreadsheet data structure provided by the present invention;

[0049] Figure 3 A structural diagram of an apparatus for executing test cases provided in an embodiment of the present invention;

[0050] Figure 4 A structural diagram of another apparatus for executing test cases provided in an embodiment of the present invention;

[0051] Figure 5 A flowchart of another method for executing test cases provided in an embodiment of the present invention. Detailed Implementation

[0052] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present invention.

[0053] The core of this invention is to provide a method, apparatus, and medium for executing test cases, which greatly reduces the difficulty of writing automated test cases, helps to improve the coverage level of automated tests, and improves the efficiency of executing test cases.

[0054] To enable those skilled in the art to better understand the present invention, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0055] It should be noted that the method for executing test cases provided by this invention is applicable to interface test case scenarios with simple test case steps, a large number of test cases, and the need for repeated verification, so as to reduce the difficulty of writing automated test cases and improve the coverage level of automated testing.

[0056] Figure 1 A flowchart of a method for executing test cases provided in an embodiment of the present invention is shown below. Figure 1 As shown, the method includes:

[0057] S11: Obtain test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information;

[0058] S12: Read the information from the Excel file and configuration information using the Python interpreter to obtain the interface parameter information;

[0059] S13: Configure the interface parameter information through the parameter passing method, pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and send request information to the server to obtain the execution results;

[0060] S14: Compare the execution results with the expected results of the test cases to obtain the test results.

[0061] Specifically, before obtaining test cases and corresponding configuration information at the data layer, a Python environment is set up and the dependency packages of each framework in the Python environment are installed; the framework code corresponding to each framework is pulled from git; and the correct development environment for interface automation testing is built.

[0062] To enable testers without coding skills to quickly and easily execute simple test cases in batches using Python by filling in formatted data files, an easy-to-execute interface testing automation framework is proposed. This framework is mainly divided into a common method layer, a test case layer, and a data layer. It is an extension of the pytest testing framework. Testers only need to fill in the formatted interface test data in the Excel file of the data layer to quickly and accurately execute relatively simple test cases.

[0063] Within the testing scope, testers write test cases and create Excel files based on the interface test cases. This involves converting the test cases and configuration information into an Excel file containing interface test information, storing various parameters of the interface test in the Excel file.

[0064] As a preferred embodiment, the conversion process includes the following steps:

[0065] Write test cases within the test scope;

[0066] Fill in the Excel file according to the interface test cases;

[0067] Enter the titles of each heading in the first row of the Excel file;

[0068] Fill in the test cases according to the titles;

[0069] Each of the second to Nth rows in the Excel file corresponds to one API request.

[0070] Each worksheet in the Excel file corresponds to the interface test information under the same test case category.

[0071] The process of converting interface test information under the same test case category into corresponding test cases is completed to complete the conversion of information in the Excel file.

[0072] Figure 2 This is a schematic diagram of an Excel spreadsheet data structure provided by the present invention, such as... Figure 2 As shown, the first row is the title, used to guide testers in filling out the form. Each subsequent row corresponds to an interface request, and each test case can correspond to multiple requests. Each worksheet stores the interface test information for one module, and each Excel file can correspond to a higher level within the module to clearly define the hierarchy.

[0073] The converted Excel file is stored in the data layer, along with a YAML file. The YAML file stores various configuration information and supports storing data such as objects, dictionaries, lists, and composite structures. Indentation is used to represent hierarchical relationships, which can effectively configure information of various types and levels.

[0074] The Python interpreter reads information from an Excel file and configuration data to obtain interface parameters. Based on the configuration information contained in different sheets, different modules and interfaces are tested. It should be noted that the modules in this embodiment refer to test case classification modules, which are different from the modules within the framework. During the reading process, methods defined in the method layer are called. This method layer stores various predefined methods, primarily including the `yaml` module to extract basic configuration information from the YAML file, such as the Excel file path, log file path, database connection information, and commonly used basic settings parameters; the method used is `safe_load()` under `yaml`, which takes an object generated after opening and reading the file content. The `xlrd` module extracts various interface test parameters from the Excel file, such as module name, test case name, test case level, request URL, request body, request method, and expected result; it mainly uses `xlrd.open_workbook(self.excel_path).sheet_by_name(self.test_module)`, and then calls the method returned by this method to convert all interface test information into a list-tuple format. For example, after calling the various parameter information using the methods mentioned above and generating the object, the interface test information obtained by calling the above methods is converted into a list nested tuple using another method. This invention does not specifically limit the other method, as long as it can convert the interface test information into a list nested tuple.

[0075] A custom logging module appends different levels of log messages to a specified path, internally adding time information: `time.strftime("%Y-%m-%d%H:%M:%S")`. The `requests` module generates session objects. It sends different types of API requests and retrieves API parameters. A custom generator module centrally generates method layer objects for easier subsequent unified management.

[0076] After obtaining the interface parameters, the pytest testing framework configures the interface parameter information using its parameter passing methods and pre- and post-processing steps to execute the corresponding test cases. A request is then sent to the server to obtain the execution results. Test case execution occurs at the test case layer, which primarily involves the use of pytest framework functionalities. This includes the built-in decorator `pytest.mark.parametrize` which receives interface parameter information from an Excel file, and custom pre- and post-processing steps at the method, class, and module levels using the `conftest` file in the same directory. This parameter passing method greatly simplifies test code and is suitable for simple interface tests with a large number of test cases requiring repeated verification, significantly improving code maintainability.

[0077] Adding pre- or post-processing steps simply requires predefining the processing methods and levels in the conftest file, and then directly adding the method name from conftest as a parameter to the methods that need to be processed.

[0078] In the test case layer, the `request` method is called to send different types of interface requests. The server sends request information, and the execution results are obtained. The system sends request information to the server and records the corresponding RESTful API interface information through browser packet capture, including the target IP address, target request method, request headers, and request body. Before execution, character content validation is performed on the expected results of each RESTful API step. When the test cases are converted into an Excel spreadsheet line by line, specific strings that confirm the successful execution of the test cases are included in the expected return results, typically "success" or other specific return content that sufficiently confirms the test case execution is error-free.

[0079] The execution results are compared with the expected results of the test cases to obtain the test results. The `assert` statement is used to check if the expected result is returned by the interface; if so, the test case execution is successful; otherwise, it fails. The allure-pytest extension module is used to generate test results. After installing this module, simply modify the relative path of the .py file in the executable file, right-click and execute to automatically generate key information including test case execution result statistics, execution environment information, and details of each test case execution. Here, `os.system` is mainly used to execute almost fixed command-line commands, allowing testers to easily begin automated testing.

[0080] As a preferred embodiment, comparing the execution result with the expected result of the test case to obtain the test result includes:

[0081] Obtain the execution steps of the test cases corresponding to the execution results;

[0082] If each execution step meets the expected completion rate, the test result is considered successful.

[0083] If at least one execution step fails to meet the expected completion rate, the test result is determined to be a failure.

[0084] Specifically, if all execution steps of the same test case meet expectations, the test result is considered successful; if any step fails to meet expectations, the test case is deemed to have failed. To improve the efficiency of test case execution, another embodiment can prevent subsequent execution steps from being executed if a step fails to meet expectations, thus directly determining the current test case as failed. This invention is not specifically limited and can be configured according to actual circumstances. If the test case execution results are to be checked based on the generation of a subsequent test report, then all execution steps need to be completed before determining the test result.

[0085] In the test case layer, each .py file typically contains a class, and each method within that class corresponds to a module, which in turn corresponds to a worksheet in an Excel file. Each class then corresponds to an Excel file, meaning each .py file represents a separate Excel file, forming a large module. Multiple .py files can be executed at once, resulting in a large number of test cases per run, which significantly improves the efficiency of automated testing.

[0086] This invention provides a method for executing test cases, comprising: acquiring test cases and corresponding configuration information, and converting the test cases into an Excel file containing interface test information; reading the Excel file information and configuration information through a Python interpreter to obtain interface parameter information; configuring the interface parameter information using the parameter passing method, pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and sending a request to the server to obtain the execution results; comparing the execution results with the expected results of the test cases to obtain the test results. This method is an extension of the pytest testing framework. By converting test cases into Excel files containing interface test information and outputting test results through a Python interpreter and the pytest testing framework, even inexperienced and unskilled testers can complete the execution of complex test cases, greatly reducing the difficulty of writing automated test cases, improving the coverage of automated tests, and increasing the efficiency of test case execution.

[0087] Based on the above embodiments, step S12, which involves reading the Excel file information and configuration information using a Python interpreter to obtain the interface parameter information, includes:

[0088] Read the configuration information to obtain the hierarchical relationship of test case types and test case hierarchy;

[0089] Determine the configuration level of test cases based on the hierarchical relationships;

[0090] Read the interface test information from the Excel file and determine the interface parameter information of the test cases by matching it with the configuration level.

[0091] Specifically, reading configuration information is mainly used to obtain the hierarchical relationship of test case types and test cases, and then determine the configuration level based on each hierarchical relationship. The interface parameter information is then determined based on the correspondence between the configuration level and the interface test information, facilitating the execution of subsequent test cases. At the test case layer, when executing test cases, it is necessary to handle the pre- and post-steps at the method level, class level, and module level according to the custom conftest file in the same directory, in order to improve the efficiency of test case execution.

[0092] The present invention provides a method for reading Excel file information and configuration information using a Python interpreter to obtain interface parameter information, which facilitates the execution of subsequent test cases and improves the efficiency of test case execution.

[0093] Based on the above embodiments, step S13, which involves sending a request to the server to obtain the execution result, includes:

[0094] Send API request information to the server via HTTP / HTTPS protocol to obtain execution results.

[0095] It's important to note that sending a request to the server to retrieve the execution result specifically involves sending an Application Programming Interface (API) request to the server via Hypertext Transfer Protocol (HTTP) / Hypertext Transfer Protocol over Secure Socket Layer (HTTPS). This is primarily based on the front-end retrieving the request information. HTTP is a request-and-response, stateless, application-layer protocol, often based on TCP / IP for data transmission. It's the most widely used network protocol on the internet, and all WWW files must adhere to this standard. HTTP was originally designed to provide a method for publishing and receiving HTML pages. HTTPS, built on SSL / TLS and HTTP, is a network protocol that enables encrypted transmission and authentication. It is more secure than HTTP. The main functions of HTTPS can be divided into two categories: establishing a secure information channel to ensure data transmission security and verifying the authenticity of websites.

[0096] The present invention provides a method for sending API interface request information to the server via HTTP / HTTPS protocol to obtain execution results, which facilitates subsequent verification and detection.

[0097] Based on the above embodiments, before comparing the execution results with the expected results of the test cases to obtain the test results, the method further includes:

[0098] If the execution time of a test case exceeds the preset time, the skip command is invoked to skip the test case and execute the next test case.

[0099] The flag command is invoked to mark test cases as expected failure cases.

[0100] Specifically, when the execution time of a test case exceeds a preset time, the `pytest.mark.skip` command is invoked to skip a set of test cases to allow execution of the next test case. The `pytest.mark.xfail` command is then invoked to temporarily mark the test case execution as expected as failed. After all execution steps of the test case are completed, the test cases marked as expected as failed are executed again. If the number of executions exceeds a threshold, the test case is discarded.

[0101] The present invention provides that when the execution time of a test case exceeds a preset time, a skip command is invoked to skip the test case and execute the next test case; a mark command is invoked to mark the test case as an expected failure case, thereby improving the efficiency of test case execution.

[0102] Based on the above embodiments, the method further includes:

[0103] Obtain the results of each execution step;

[0104] Summarize the results of each step and generate a test report in HTML format.

[0105] The present invention provides a method to record the results of all steps in all test cases, and automatically generate an HTML format test report by summarizing the results for subsequent review by staff, thereby improving the quality of test case requirements.

[0106] The foregoing has described in detail various embodiments of the method for executing test cases. Based on this, the present invention also discloses an apparatus for executing test cases corresponding to the above-described method. Figure 3 This is a structural diagram of an apparatus for executing test cases provided in an embodiment of the present invention. Figure 3 As shown, the apparatus for executing test cases includes:

[0107] Module 11 is used to obtain test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information.

[0108] The reading module 12 is used to read information from an Excel file and configuration information through the Python interpreter to obtain interface parameter information.

[0109] Execution module 13 is used to configure interface parameter information through the parameter passing method and pre- and post-steps of the pytest testing framework to execute the corresponding test cases and send request information to the server to obtain the execution results;

[0110] Comparison module 14 is used to compare the execution result with the expected result of the test case to obtain the test result.

[0111] Since the embodiments of the device part correspond to the embodiments described above, please refer to the embodiments described in the method part for the embodiments of the device part, and will not be repeated here.

[0112] This invention provides an apparatus for executing test cases, comprising: acquiring test cases and corresponding configuration information, and converting the test cases into an Excel file containing interface test information; reading the Excel file information and configuration information through a Python interpreter to obtain interface parameter information; configuring the interface parameter information to execute the corresponding test cases through the parameter passing method, pre- and post-steps of the pytest testing framework, and sending request information to the server to obtain the execution results; comparing the execution results with the expected results of the test cases to obtain the test results. This apparatus is an extension of the pytest testing framework. By converting test cases into Excel files containing interface test information and outputting test results through a Python interpreter and the pytest testing framework, even inexperienced and unskilled testers can complete the execution of complex test cases, greatly reducing the difficulty of writing automated test cases, improving the coverage level of automated testing, and increasing the efficiency of test case execution.

[0113] Figure 4 A structural diagram of another apparatus for executing test cases provided in an embodiment of the present invention is shown below. Figure 4 As shown, the device includes:

[0114] Memory 21 is used to store computer programs;

[0115] Processor 22 is used to implement the steps of executing test cases when executing a computer program.

[0116] The device for executing test cases provided in this embodiment may include, but is not limited to, a tablet computer, a laptop computer, or a desktop computer.

[0117] The processor 22 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 22 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 22 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 22 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 22 may also include an Artificial Intelligence (AI) processor, which handles computational operations related to machine learning.

[0118] The memory 21 may include one or more computer-readable storage media, which may be non-transitory. The memory 21 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 21 is used to store at least the following computer program 211, which, after being loaded and executed by the processor 22, is capable of implementing the relevant steps of the method for executing test cases disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 21 may also include an operating system 212 and data 213, etc., and the storage method may be temporary storage or permanent storage. The operating system 212 may include Windows, Unix, Linux, etc. The data 213 may include, but is not limited to, the data involved in the method for executing test cases, etc.

[0119] In some embodiments, the apparatus for executing test cases may further include a display screen 23, an input / output interface 24, a communication interface 25, a power supply 26, and a communication bus 27.

[0120] Those skilled in the field can understand, Figure 4 The structure shown does not constitute a limitation on the apparatus for executing test cases and may include more or fewer components than illustrated.

[0121] The processor 22 implements the method for executing test cases provided in any of the above embodiments by calling instructions stored in the memory 21.

[0122] This invention provides an apparatus for executing test cases, comprising: acquiring test cases and corresponding configuration information, and converting the test cases into an Excel file containing interface test information; reading the Excel file information and configuration information through a Python interpreter to obtain interface parameter information; configuring the interface parameter information to execute the corresponding test cases through the parameter passing method, pre- and post-steps of the pytest testing framework, and sending request information to the server to obtain the execution results; comparing the execution results with the expected results of the test cases to obtain the test results. This apparatus is an extension of the pytest testing framework. By converting test cases into Excel files containing interface test information and outputting test results through a Python interpreter and the pytest testing framework, even inexperienced and unskilled testers can complete the execution of complex test cases, greatly reducing the difficulty of writing automated test cases, improving the coverage level of automated testing, and increasing the efficiency of test case execution.

[0123] Furthermore, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by processor 22, implements the steps of the method for executing test cases as described above.

[0124] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0125] For an introduction to the computer-readable storage medium provided by the present invention, please refer to the above method embodiments. The present invention will not be described in detail here, but it has the same beneficial effects as the above method for executing test cases.

[0126] Figure 5 A flowchart of another method for executing test cases provided in an embodiment of the present invention is shown below. Figure 5 As shown, the flowchart includes the following steps:

[0127] Step 1: Testers set up a Python environment on Windows, install the necessary dependency packages for each framework, pull the framework code from Git, and build the correct interface automation development environment.

[0128] Step 2: Testers write test cases within the test scope and fill in an Excel file based on the interface test cases. Figure 5 The Excel files, numbered A01 to A02, store various parameters for the interface tests. The first row is the header, guiding testers in filling out the form. Each subsequent row corresponds to an interface request, and each test case can correspond to multiple requests. Each worksheet stores the interface test information for one module, and each Excel file can be categorized into higher-level sections above the module to clearly define the data hierarchy.

[0129] Step 3: The Python program reads the local Excel file, executes test cases for different modules and interfaces based on the information contained in different sheets, and sends various requests to the RESTful API interface of the storage server application via HTTP / HTTPS protocol and obtains the execution results. Figure 5 From A03 to A04.

[0130] Step 4: The Python program judges the expected results. If all steps of the same test case meet the expectations, the test case is judged as successful; otherwise, if any step does not produce the expected result, the test case is judged as failed.

[0131] Step 5: The Python program records the results of all test cases and all steps, summarizes the results, and automatically generates a test report in HTML format. Figure 5 Step A05 in the text.

[0132] For an introduction to another method for executing test cases provided by the present invention, please refer to the above method embodiments. The present invention will not be described again here, but it has the same beneficial effects as the above method for executing test cases.

[0133] The present invention has provided a detailed description of a method, apparatus, and medium for executing test cases. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

[0134] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method for executing test cases, characterized in that, include: Obtain the test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information; The interface parameter information is obtained by reading the information from the Excel file and the configuration information using a Python interpreter. The interface parameter information is configured using the parameter passing method and pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and a request is sent to the server to obtain the execution results. The execution results are compared with the expected results of the test cases to obtain the test results; The conversion process of the Excel file information includes the following steps: Write test cases within the test scope; Fill in the Excel file according to the interface test cases; Enter the titles of each heading in the first row of the Excel file; Fill in the test cases according to the titles described above; Each of the second to Nth rows of the Excel file corresponds to one API request. Each worksheet in the Excel file corresponds to the interface test information under the same test case category. The process of converting the interface test information under the same test case type into the test case is completed; The step of reading the Excel file information and the configuration information through a Python interpreter to obtain interface parameter information includes: Read the configuration information to obtain the hierarchical relationship of the test case types and the hierarchical relationship of the test cases; The configuration level of the test cases is determined based on the hierarchical relationships. The interface test information in the Excel file is read, and the interface parameter information of the test case is determined by comparing it with the correspondence of the configuration level.

2. The method for executing test cases according to claim 1, characterized in that, Sending request information to the server to obtain the execution result includes: The API request information is sent to the server via HTTP / HTTPS protocol to obtain the execution result.

3. The method for executing test cases according to claim 2, characterized in that, The step of comparing the execution result with the expected result of the test case to obtain the test result includes: Obtain the execution steps of the test case corresponding to the execution result; If each of the execution steps meets the expected completion rate of the expected result, then the test result is determined to be successful; If at least one of the execution steps fails to meet the expected completion rate, the test result is determined to be a failure.

4. The method for executing test cases according to claim 3, characterized in that, Before comparing the execution result with the expected result of the test case to obtain the test result, the method further includes: If the execution time of the test case exceeds the preset time, a skip command is invoked to skip the test case and execute the next test case. The mark command is invoked to mark the test case as an expected failure case.

5. The method for executing test cases according to claim 3 or 4, characterized in that, Also includes; Obtain the results of each of the execution steps; Summarize the results of each step and generate a test report in HTML format.

6. An apparatus for executing test cases, characterized in that, include: The acquisition module is used to acquire the test cases and corresponding configuration information, and convert the test cases into an Excel file containing interface test information. The conversion process includes the following steps: writing test cases within the test scope; filling in the Excel file based on the interface test cases; filling in the header names in the first row of the Excel file; filling in the test cases according to the header names; each of the second to Nth rows of the Excel file corresponds to an interface request; each worksheet of the Excel file corresponds to interface test information under the same test case type; and the interface test information under the same test case type is mapped to the test cases to complete the conversion process of the Excel file information. A reading module is used to read the Excel file information and the configuration information through a Python interpreter to obtain interface parameter information. The process of reading the Excel file information and the configuration information through a Python interpreter to obtain interface parameter information includes: reading the configuration information to obtain the hierarchical relationship of the test case types and the hierarchical relationship of the test cases; determining the configuration level of the test cases based on each hierarchical relationship; reading the interface test information from the Excel file information and determining the interface parameter information of the test cases based on the correspondence with the configuration levels. The execution module is used to configure the interface parameter information through the parameter passing method and pre- and post-steps of the pytest testing framework to execute the corresponding test cases, and to send request information to the server to obtain the execution results; The comparison module is used to compare the execution result with the expected result of the test case to obtain the test result.

7. An apparatus for executing test cases, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the method for executing test cases as described in any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method for executing test cases as described in any one of claims 1 to 5.