Test method and device, electronic equipment and storage medium

By using the teardown function in the pytest testing framework to release driver resources when the target test case fails, the problem of resources not being released in abnormal situations in the pytest testing framework is solved, ensuring the smooth execution and reliability of tests.

CN121958071APending Publication Date: 2026-05-01GEER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GEER TECH CO LTD
Filing Date
2024-10-29
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

The existing pytest testing framework fails to release driver resources in a timely manner when an exception occurs, causing subsequent test cases to fail to execute and hindering the smooth progress of testing.

Method used

When the target test case fails, the pytest testing framework's teardown function is used to trigger a callback of the driver resources to release them.

Benefits of technology

This ensures that subsequent test cases can be executed normally, guarantees the smooth testing of the device under test, and improves the reliability and efficiency of testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121958071A_ABST
    Figure CN121958071A_ABST
Patent Text Reader

Abstract

The invention provides a test method and device, electronic equipment and a storage medium. The method comprises the steps that multiple test cases of to-be-tested equipment are acquired; a target test case is executed to test the to-be-tested device, and the target test case is any one of the multiple test cases; and under the condition that the test result corresponding to the target test case is failure, releasing the driver resource corresponding to the target test case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of testing technology, and more specifically, to a testing method, apparatus, electronic device, and storage medium. Background Technology

[0002] In existing technologies, the pytest testing framework releases driver resources based on the yield logic. However, since the exception occurs before the release operation, if the test result corresponding to the target test case fails, the driver resources corresponding to the target test case will not be released. This will cause the next test case to fail to execute because it cannot call the driver normally, thus hindering the smooth execution of the test. Summary of the Invention

[0003] One object of the present disclosure is to provide a testing method, apparatus, electronic device, and storage medium.

[0004] According to an objective aspect of this disclosure, a testing method is provided, comprising:

[0005] Obtain multiple test cases for the device under test;

[0006] The target test case is executed to test the device under test, wherein the target test case is any one of the plurality of test cases;

[0007] If the test result corresponding to the target test case fails, release the driver resources corresponding to the target test case.

[0008] Optionally, the execution of the target test case to test the device under test includes:

[0009] Based on the target test case, the pytest testing framework generates the corresponding test instructions.

[0010] The test commands are sent to the device under test for execution based on the pytest testing framework.

[0011] The response results of the device under test to the test command are obtained based on the pytest testing framework.

[0012] Optionally, the execution of the target test case to test the device under test includes:

[0013] Based on the target test case, the pytest testing framework generates the corresponding test instructions.

[0014] The test instructions are parsed using the Appium testing framework, and then converted into corresponding interactive commands. These interactive commands are then sent to the device under test (DUT) so that the DUT can perform the interactive operation corresponding to the interactive commands.

[0015] The Appium testing framework is used to obtain the response result of the device under test to the interactive command, and the response result is returned to the PyTest testing framework.

[0016] Optionally, the method further includes:

[0017] The test result corresponding to the target test case is determined based on the response result;

[0018] The test results of the device under test are obtained based on the test results corresponding to the target test cases.

[0019] Optionally, determining the test result corresponding to the target test case based on the response result includes:

[0020] The response result is compared with the target result of the target test case;

[0021] If the response result is consistent with the target result, the test result corresponding to the target test case is determined to be successful;

[0022] If the response result is inconsistent with the target result, the test result corresponding to the target test case is determined to be a failure.

[0023] Optionally, before obtaining multiple test cases for the device under test, the method further includes:

[0024] Check whether the test environment of the device under test is normal;

[0025] Under normal test conditions, the step of obtaining multiple test cases for the device under test is executed.

[0026] Optionally, releasing the driver resources corresponding to the target test case includes:

[0027] The teardown function in the pytest testing framework is used to trigger a callback of the driver resources corresponding to the target test case, so as to release the driver resources corresponding to the target test case.

[0028] According to a second aspect of this disclosure, a testing apparatus is provided, comprising:

[0029] The test case acquisition module is used to acquire multiple test cases for the device under test.

[0030] The test case execution module is used to execute the target test case to test the device under test, wherein the target test case is any one of the plurality of test cases;

[0031] The resource release module is used to release the driver resources corresponding to the target test case when the test result corresponding to the target test case fails.

[0032] According to a third aspect of this disclosure, an electronic device is provided, including a processor and a memory, the memory being used to store a computer program, and the processor being used to execute the method as described in the first aspect of this disclosure under the control of the computer program.

[0033] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described in the first aspect of this disclosure.

[0034] Through the embodiments of this disclosure, if the test result corresponding to the target test case fails when executing the target test case to test the device under test, releasing the driver resources corresponding to the target test case can ensure that subsequent test cases can continue to be executed normally, thus ensuring the smooth execution of the test of the device under test.

[0035] Other features and advantages of the invention will become clear from the following detailed description of exemplary embodiments of the invention with reference to the accompanying drawings. Attached Figure Description

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

[0037] Figure 1 This is a block diagram illustrating the hardware configuration of an electronic device that can implement embodiments of the present disclosure;

[0038] Figure 2 This is a flowchart of a test method according to an embodiment of the present disclosure;

[0039] Figure 3 This is a block diagram of a test apparatus according to an embodiment of the present disclosure;

[0040] Figure 4 This is a block diagram of an electronic device according to an embodiment of the present disclosure. Detailed Implementation

[0041] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of the invention.

[0042] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.

[0043] Techniques, methods, and apparatus known to those skilled in the art in the relevant field may not be discussed in detail, but where appropriate, such techniques, methods, and apparatus should be considered part of the specification.

[0044] In all the examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.

[0045] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0046] <Hardware Configuration>

[0047] Figure 1 This is a block diagram illustrating the hardware configuration of an electronic device that can implement embodiments of the present disclosure.

[0048] Electronic device 1000 can be a portable computer, desktop computer, etc. For example... Figure 1 As shown, the electronic device 1000 may include a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, an input device 1600, a speaker 1700, a microphone 1800, etc. The processor 1100 may be a CPU, a microprocessor (MCU), etc. The memory 1200 may include, for example, ROM (Read-Only Memory), RAM (Random Access Memory), or non-volatile memory such as a hard disk. The interface device 1300 may include, for example, a USB interface, a headphone jack, etc. The communication device 1400 may be capable of wired or wireless communication, specifically including Wi-Fi communication, Bluetooth communication, 2G / 3G / 4G / 5G communication, etc. The display device 1500 may be, for example, an LCD screen, a touch screen, etc. The input device 1600 may include, for example, a touch screen, a keyboard, motion input, etc. Users can input / output voice information through the speaker 1700 and the microphone 1800.

[0049] Figure 1The electronic devices shown are merely illustrative and in no way intended to limit this disclosure, its application, or use. In embodiments applied to this disclosure, the memory 1200 of the electronic device 1000 is used to store instructions for controlling the processor 1100 to operate to perform any of the methods provided in the embodiments of this disclosure. Those skilled in the art will understand that, although... Figure 1 The electronic device 1000 is shown with multiple devices shown; however, this disclosure may relate only to some of these devices. For example, electronic device 1000 may only relate to processor 1100 and storage device 1200. Those skilled in the art can design instructions based on the schemes disclosed herein. How the instructions control the processor to operate is well known in the art and will not be described in detail here.

[0050] <Method Implementation>

[0051] This disclosure provides a testing method that can be implemented by an electronic device. The electronic device can be an electronic product capable of performing functional tests on the device under test; for example, the electronic device can be such as... Figure 1 The electronic device shown is 1000.

[0052] In one embodiment, the electronic device implementing the method of this embodiment is equipped with at least the pytest framework, and the method of this embodiment can be implemented based on the pytest framework.

[0053] Figure 2 This is a flowchart of a test method according to an embodiment of the present disclosure.

[0054] like Figure 2 As shown, the method includes the following steps S2100 to S2300:

[0055] Step S2100: Obtain multiple test cases for the device under test.

[0056] In this embodiment, the test cases can be pre-created based on the pytest testing framework and used to perform functional testing on the device under test.

[0057] This embodiment allows you to pre-select settings based on the test scenario and create corresponding test cases.

[0058] Furthermore, the electronic device performing the method of this embodiment can establish a communication connection with the device under test via wired or wireless means to test the device under test.

[0059] In embodiments where the electronic device and the device under test (DUT) establish a communication connection via a wired method, the electronic device can communicate via a USB data cable. In embodiments where the electronic device and the DUT establish a communication connection via a wireless method, the electronic device can communicate via Wi-Fi, Bluetooth, or other similar methods.

[0060] The device under test in this embodiment can be an electronic product such as virtual reality glasses, a mobile phone, or a tablet computer.

[0061] In one embodiment of this disclosure, before performing steps S2100 to S2300 of this embodiment, the method further includes: detecting whether the test environment of the device under test is normal; if the test environment is normal, performing steps S2100 to S2300 of this embodiment.

[0062] In this embodiment, the test environment is normal and may include at least one of the following: the electronic device starts the pytest test framework, the electronic device starts the appium test framework, and the electronic device provides the resources required to execute multiple test cases.

[0063] Furthermore, if an abnormality is detected in the test environment, steps S2100 to S2300 of this embodiment are not executed. Instead, the tester needs to troubleshoot the problem and retest until the test environment is detected to be normal. Then, steps S2100 to S2300 of this embodiment are executed to test the device under test, so as to ensure the accuracy of the test results of the device under test.

[0064] Step S2200: Execute the target test cases to test the device under test.

[0065] The target test case is any one of the multiple test cases.

[0066] In one embodiment of this disclosure, any one of the multiple test cases may be selected as the target test case.

[0067] In another embodiment of this disclosure, each test case may have a number indicating its execution order. Alternatively, multiple test cases may be traversed according to the number, and the currently traversed test case may be used as the target test case.

[0068] In one embodiment of this disclosure, executing target test cases to test the device under test includes: obtaining corresponding test instructions based on the target test cases using the pytest testing framework; sending the test instructions to the device under test for execution using the pytest testing framework; and obtaining the response results of the device under test to the test instructions using the pytest testing framework.

[0069] In this embodiment, the target test cases do not involve testing the interactive functions of the device under test. The target test cases can be executed solely based on the pytest testing framework to test the device under test.

[0070] In this embodiment, the electronic device can communicate directly with the device under test through the pytest testing framework.

[0071] Furthermore, the response result can reflect the execution status of the test command in the electronic device; specifically, it can indicate whether the electronic device correctly executes the test command. For example, the response result can be a specific numerical value, a numerical range, or a specific image.

[0072] In one embodiment of this disclosure, executing target test cases to test the device under test includes: obtaining corresponding test instructions based on the target test cases using the pytest testing framework; parsing the test instructions using the appium testing framework, converting the parsed test instructions into corresponding interactive commands, sending the interactive commands to the device under test so that the device under test performs the interactive operation corresponding to the interactive commands; obtaining the response result of the device under test to the interactive commands using the appium testing framework, and returning the response result to the pytest testing framework.

[0073] In this embodiment, the target test case is used to test the interactive functions of the device under test. It can be based on the Appium testing framework and the PyTest testing framework, which are used to execute the target test case together to test the device under test.

[0074] In this embodiment, the electronic device can communicate directly with the device under test through the Appium testing framework, and the Pytest testing framework can call the Appium testing framework to perform interactive function tests on the device under test.

[0075] Furthermore, since the pytest testing framework cannot control the device under test to perform interactive operations, the appium testing framework can be called to control the device under test to perform interactive operations and test the interactive functions of the device under test.

[0076] This embodiment enables automated batch testing of multiple functions (including interactive functions) of the device under test, improving testing efficiency and reducing testing costs.

[0077] Step S2300: If the test result corresponding to the target test case fails, release the driver resources corresponding to the target test case.

[0078] In existing technologies, the pytest testing framework releases driver resources based on the yield logic. However, since the exception occurs before the release operation, if the test result corresponding to the target test case fails, the driver resources corresponding to the target test case will not be released. This will cause the next test case to fail to execute because it cannot call the driver normally, thus hindering the smooth execution of the test.

[0079] In one example, the underlying code for the fixture architecture of the existing pytest testing framework could be as follows:

[0080] @pytest.fixture

[0081] def login():

[0082] driver = webdriver.Chrome()

[0083] driver.get("http: / / xxxxx.com")

[0084] yield driver

[0085] print("Test over,please close driver,release source.")

[0086] driver.quit()

[0087] In this embodiment, if the device under test fails to open the website http: / / xxxxxxxx.com, the driver resources will not be released, and subsequent test cases that require access to these driver resources will be unable to execute.

[0088] In one embodiment of this disclosure, releasing the driver resources corresponding to the target test case includes: performing a callback of the driver resources corresponding to the target test case based on the teardown function in the pytest testing framework, so as to release the driver resources corresponding to the target test case.

[0089] In this embodiment, the teardown function is used to call back the driver resources corresponding to the target test case, which ensures that the driver resources can be released normally, thereby ensuring that subsequent test cases can continue to execute normally and ensuring the smooth execution of the test of the device under test.

[0090] In one example, the fixture architecture principle code of the pytest testing framework in this embodiment can be as follows:

[0091] @pytest.fixture

[0092] def login(request):

[0093] def login_teardown()

[0094] driver.quit()

[0095] request.addfinalizer(login_teardown)

[0096] driver = webdriver.Chrome()

[0097] driver.get("http: / / xxxxx.com")

[0098] return driver

[0099] In this embodiment, if the device under test fails to open the website http: / / xxxxxxxx.com, the driver resources can still be released normally, ensuring that subsequent test cases that need to call the driver resources can be executed normally.

[0100] Through the embodiments of this disclosure, if the test result corresponding to the target test case fails when executing the target test case to test the device under test, releasing the driver resources corresponding to the target test case can ensure that subsequent test cases can continue to be executed normally, thus ensuring the smooth execution of the test of the device under test.

[0101] In one embodiment of this disclosure, the method further includes: determining the test result corresponding to the target test case based on the response result; and obtaining the test result of the device under test based on the test result corresponding to the target test case.

[0102] In this embodiment, the test results of the device under test (DUT) may include the test results of all test cases. Specifically, the test results of the DUT may include the numbers of all test cases and their corresponding test results.

[0103] Once the test results of the test equipment are obtained, the test results can be stored and / or displayed for testers to view and trace.

[0104] If any test case fails, the test results of the device under test may also include the response results and target results corresponding to the test case that failed.

[0105] In one embodiment of this disclosure, determining the test result corresponding to the target test case based on the response result includes: comparing the response result with the target result of the target test case; if the response result is consistent with the target result, determining that the test result corresponding to the target test case is successful; if the response result is inconsistent with the target result, determining that the test result corresponding to the target test case is unsuccessful.

[0106] In this embodiment, the target results can be set in advance according to the test items of each test case, and the target results can be entered into the expected results list.

[0107] In this embodiment of the disclosure, there are two ways to determine the test results, which the user can choose: one is to compare while testing, and the other is to compare after the test is completed.

[0108] In an implementation of test-and-compare, the response result of each test case can be compared with the corresponding target result after each test case is executed to obtain the test result of the test case.

[0109] In an embodiment where comparison is performed after all test cases have been executed, the response result of each test case can be compared with the corresponding target result to obtain the test result of that test case.

[0110] This embodiment allows for the comparison of the response results of the target test cases with the set target results to determine the test results of the target test cases. This can improve the accuracy and objectivity of the test results of the device under test, and also ensure the consistency of the testing process to avoid the influence of human factors on the test results of the device under test.

[0111] <Device Embodiment>

[0112] This embodiment also provides a testing device, such as... Figure 3 As shown, the test device 3000 includes a test case acquisition module 3100, a test case execution module 3200, and a resource release module 3300.

[0113] The test case acquisition module 3100 is used to acquire multiple test cases for the device under test.

[0114] The test case execution module 3200 is used to execute the target test case to test the device under test, wherein the target test case is any one of the plurality of test cases.

[0115] The resource release module 3300 is used to release the driver resources corresponding to the target test case when the test result corresponding to the target test case fails.

[0116] In one embodiment of this disclosure, the use case execution module 3200 is used to:

[0117] Based on the target test case, the pytest testing framework generates the corresponding test instructions.

[0118] The test commands are sent to the device under test for execution based on the pytest testing framework.

[0119] The response results of the device under test to the test command are obtained based on the pytest testing framework.

[0120] In one embodiment of this disclosure, the use case execution module 3200 is used to:

[0121] Based on the target test case, the pytest testing framework generates the corresponding test instructions.

[0122] The test instructions are parsed using the Appium testing framework, and then converted into corresponding interactive commands. These interactive commands are then sent to the device under test (DUT) so that the DUT can perform the interactive operation corresponding to the interactive commands.

[0123] The Appium testing framework is used to obtain the response result of the device under test to the interactive command, and the response result is returned to the PyTest testing framework.

[0124] In one embodiment of this disclosure, the testing apparatus 3000 further includes:

[0125] A module for determining the test result corresponding to the target test case based on the response result;

[0126] A module for obtaining the test results of the device under test based on the test results corresponding to the target test case.

[0127] In one embodiment of this disclosure, determining the test result corresponding to the target test case based on the response result includes:

[0128] The response result is compared with the target result of the target test case;

[0129] If the response result is consistent with the target result, the test result corresponding to the target test case is determined to be successful;

[0130] If the response result is inconsistent with the target result, the test result corresponding to the target test case is determined to be a failure.

[0131] In one embodiment of this disclosure, the testing apparatus 3000 further includes:

[0132] A module used to detect whether the test environment of the device under test is normal;

[0133] The test case acquisition module 3100 is used to acquire multiple test cases of the device under test when the test environment is normal.

[0134] In one embodiment of this disclosure, the resource release module 3300 is used for:

[0135] The teardown function in the pytest testing framework is used to trigger a callback of the driver resources corresponding to the target test case, so as to release the driver resources corresponding to the target test case.

[0136] <Electronic Device Examples>

[0137] This embodiment provides an electronic device, such as... Figure 4 As shown, the electronic device 4000 may include a processor 4100 and a memory 4200. The memory 4200 is used to store computer programs, and the processor 4100 is used to control the electronic device to execute the methods of any embodiment of this disclosure under the control of the computer programs.

[0138] <Example of a readable storage medium>

[0139] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the methods described in any of the method embodiments of this disclosure.

[0140] This invention can be a system, method, and / or computer program product. A computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the invention.

[0141] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0142] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0143] The computer program instructions used to perform the operations of this invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing state information from the computer-readable program instructions. This electronic circuitry can execute the computer-readable program instructions to implement various aspects of the invention.

[0144] Various aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0145] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0146] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0147] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions. It will be known to those skilled in the art that implementation in hardware, implementation in software, and implementation using a combination of software and hardware are equivalent.

[0148] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein. The scope of the invention is defined by the appended claims.

Claims

1. A testing method, characterized in that, include: Obtain multiple test cases for the device under test; The target test case is executed to test the device under test, wherein the target test case is any one of the plurality of test cases; If the test result corresponding to the target test case fails, release the driver resources corresponding to the target test case.

2. The method according to claim 1, characterized in that, The execution of the target test cases tests the device under test, including: Based on the target test case, the pytest testing framework generates the corresponding test instructions. The test instructions are parsed using the Appium testing framework, and then converted into corresponding interactive commands. These interactive commands are then sent to the device under test (DUT) so that the DUT can perform the interactive operation corresponding to the interactive commands. The Appium testing framework is used to obtain the response result of the device under test to the interactive command, and the response result is returned to the PyTest testing framework.

3. The method according to claim 1, characterized in that, The execution of the target test cases tests the device under test, including: Based on the target test case, the pytest testing framework generates the corresponding test instructions. The test commands are sent to the device under test for execution based on the pytest testing framework. The response results of the device under test to the test command are obtained based on the pytest testing framework.

4. The method according to claim 2 or 3, characterized in that, The method further includes: The test result corresponding to the target test case is determined based on the response result; The test results of the device under test are obtained based on the test results corresponding to the target test cases.

5. The method according to claim 4, characterized in that, Determining the test result corresponding to the target test case based on the response result includes: The response result is compared with the target result of the target test case; If the response result is consistent with the target result, the test result corresponding to the target test case is determined to be successful; If the response result is inconsistent with the target result, the test result corresponding to the target test case is determined to be a failure.

6. The method according to claim 1, characterized in that, Before acquiring multiple test cases for the device under test, the method further includes: Check whether the test environment of the device under test is normal; Under normal test conditions, the step of obtaining multiple test cases for the device under test is executed.

7. The method according to claim 1, characterized in that, Releasing the driver resources corresponding to the target test case includes: The teardown function in the pytest testing framework is used to trigger a callback of the driver resources corresponding to the target test case, so as to release the driver resources corresponding to the target test case.

8. A testing device, characterized in that, include: The test case acquisition module is used to acquire multiple test cases for the device under test. The test case execution module is used to execute the target test case to test the device under test, wherein the target test case is any one of the plurality of test cases; The resource release module is used to release the driver resources corresponding to the target test case when the test result corresponding to the target test case fails.

9. An electronic device, characterized in that, It includes a processor and a memory, the memory being used to store a computer program, and the processor being used, under the control of the computer program, to execute the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, the computer program implementing the method as described in any one of claims 1 to 7 when executed by a processor.