Pytest architecture-based test method and system, electronic equipment and storage medium

By introducing management modules, databases and presentation layers into the pytest architecture, the problem of slow acquisition of test cases and inconvenient management in the automated test of the existing pytest framework is solved, and the effect of quickly obtaining and managing test cases and results is achieved.

CN120066973AActive Publication Date: 2025-05-30CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510533793.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-05-30
Estimated Expiration
2045-04-27

AI Technical Summary

Technical Problem

The automated testing method of the existing pytest framework is difficult to quickly obtain specified test cases, and it lacks effective management of test cases and test results, so it cannot intuitively provide users with corresponding test cases and test results.

Method used

By introducing management modules, databases and presentation layers into the pytest architecture, the pytest execution engine uses the target path of test cases from the database, quickly obtain the specified test cases, and bind the test results with the user ID and store them in the database, so that the display layer can display the test results.

Benefits of technology

It quickly obtains specified test cases for testing, and stores and presents test results, solving the problems of slow acquisition of test cases and inconvenient management, and improving testing efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066973A_ABST
    Figure CN120066973A_ABST
Patent Text Reader

Abstract

The invention relates to the field of testing, and discloses a test method and system based on a pytest architecture, electronic equipment and a storage medium, the test method comprises the following steps: in response to a test instruction issued by a display layer, controlling a pytest execution engine to obtain a target path of a test case specified by the test instruction from a database, enabling the pytest execution engine to obtain a specified test case based on the target path; wherein the database, the management module and the display layer all belong to the same program, and the path of the test case in the database is added through a matching engine; the test instruction carries a user identifier; and controlling the pytest execution engine to test based on the specified test case, and controlling the pytest execution engine to bind a test result with the user identifier and the target path, storing the test result, the user identifier and the target path in a database, and opening an access right to a user corresponding to the user identifier so as to display the target path and the test result on a display layer. According to the method and the device, the specified test case can be quickly obtained for testing, and the corresponding test result is displayed on the display layer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of vehicles, and particularly to a test method, system, electronic device, and storage medium based on the pytest architecture. Background Art

[0002] The automated test method of the related pytest framework obtains test case instances from an externally connected use case repository for testing. It is necessary to determine the specified test cases from numerous test cases, and it is impossible to quickly obtain the specified test cases to meet the test requirements.

[0003] In addition, there is a lack of management for test cases and test results, and it is impossible to intuitively provide users with the corresponding test cases and their test results. Summary of the Invention

[0004] In view of the above problems, this application provides a test method, system, electronic device, and storage medium based on the pytest architecture, which is used to quickly obtain specified test cases for testing and display the corresponding test results on the display layer.

[0005] According to one aspect of this application, a test method based on the pytest architecture is provided. The test method is applied to a management module, and the management module includes a pytest execution engine, a matching engine, a synchronization unit, and an editing unit. The test method includes: in response to a test instruction issued by the display layer, controlling the pytest execution engine to obtain the target path of the test case specified by the test instruction from the database, so that the pytest execution engine obtains the specified test case based on the target path; wherein the database, the management module, and the display layer all belong to the same program, and the path of the test case in the database is added by the matching engine; the test instruction carries a user identifier; the editing unit is used to respond to the modification instruction issued by the display layer, modify the test case in the database, and transmit the modified test case to the synchronization unit, so that the synchronization unit synchronizes the modified test case to an externally connected use case repository; controlling the pytest execution engine to perform tests based on the specified test case, and controlling the pytest execution engine to bind the test result with the user identifier and the target path, store it in the database, and open the access permission to the user corresponding to the user identifier, so as to display the test result in the database on the display layer.

[0006] In an optional manner, the test method further includes: controlling the synchronization unit to obtain original test cases from an externally connected use case repository, so that the matching engine determines target test cases that meet the preset matching rules, and stores the target test cases in the database.

[0007] In an alternative manner, the test method further includes: in response to a modification instruction issued by the display layer, controlling the editing unit to modify the test cases in the database, and invoking the synchronization unit to upload the modified test cases to the use case repository.

[0008] In an alternative manner, controlling the pytest execution engine to perform tests based on the specified test cases and storing the test results in the database includes: controlling the pytest execution engine to execute a test function to perform tests based on the specified test cases; if the tests are completed, controlling the pytest execution engine to execute a first hook function to capture the test results in the corresponding output stream and store them in the database, and sending the test report corresponding to the test results to the display layer so that the display layer can display the test report; wherein, the test report is a report generated based on the test results and the relevant data of the test results.

[0009] In an alternative manner, the test method further includes: controlling the pytest execution engine to execute the dependencies in the configuration file to initialize the connection to the database, and controlling the pytest execution engine to invoke an addition function to add a user identifier; controlling the pytest execution engine to execute a second hook function to create an output stream and a buffer corresponding to the specified test cases.

[0010] In an alternative manner, the test method further includes: if the log information of the specified test cases in the buffer is detected, controlling the pytest execution engine to execute a third hook function to store the log information in the buffer into the attributes of the specified test cases and clear the buffer.

[0011] According to another aspect of the present application, a test system based on the pytest architecture is provided. The test system includes a management module, a database, and a display layer. The management module includes a pytest execution engine, a matching engine, a synchronization unit, and an editing unit. The pytest execution engine is configured to obtain the target path of the test case specified by the test instruction from the database, and obtain the specified test case based on the target path. Wherein, the path of the test case in the database is added by the matching engine, and the test instruction carries a user identifier. The pytest execution engine is further configured to perform a test based on the specified test case, and bind the test result to the user identifier and the target path, and store it in the database to display the test result in the database on the display layer. The editing unit is configured to modify the test case in the database in response to a modification instruction issued by the display layer, and transmit the modified test case to the synchronization unit. The synchronization unit is configured to obtain the original test case from an externally connected use case repository, and synchronize the test case modified by the editing unit to the use case repository.

[0012] According to one aspect of the present application, an electronic device is provided, including: a controller; a memory for storing one or more programs, which when executed by the controller, are configured to execute the above-mentioned test method.

[0013] According to one aspect of the present application, a computer-readable storage medium is further provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the above-mentioned test method.

[0014] According to one aspect of the present application, a computer program product or a computer program is further provided. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned test method.

[0015] The present application constructs a corresponding test program through the pytest architecture, including a management module, a database, and a display layer. Through the display layer, the user can not only issue test instructions, but also intuitively know the test results. At the same time, the pytest execution engine in the management module can quickly obtain the specified test case for testing based on the target path stored in the local database, and store the test result in the database, which is convenient for unified management of test cases and test results. Among them, the matching engine in the management module can flexibly add the path of the test case, and does not need to directly store the instance of the test case in the database, thus realizing the lightweight management of the test case.

[0016] The above description is only an overview of the technical solution of this application. In order to understand the technical means of this application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of this application more obvious and understandable, the following specific embodiments of this application are specifically given. Brief Description of the Drawings

[0017] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with this application, and are used together with the specification to explain the principles of this application. Obviously, the drawings in the following description are only some embodiments of this application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0018] Figure 1 It is a schematic flowchart of a test method based on the pytest architecture shown in an exemplary embodiment of this application.

[0019] Figure 2 It is a schematic diagram of a test system based on the pytest architecture shown in an exemplary embodiment of this application.

[0020] Figure 3 is based on Figure 1 It is a schematic flowchart of another test method shown in the exemplary embodiment shown.

[0021] Figure 4 It is a schematic diagram of another test system based on the pytest architecture shown in an exemplary embodiment of this application.

[0022] Figure 5 It is a schematic diagram of yet another test system based on the pytest architecture shown in an exemplary embodiment of this application.

[0023] Figure 6 is based on Figure 1 It is a schematic flowchart of another test method shown in the exemplary embodiment shown.

[0024] Figure 7 is based on Figure 1 、 Figure 3 、 Figure 6 It is a schematic flowchart of another test method shown in any of the exemplary embodiments shown in

[0025] Figure 8 It is a schematic flowchart of the pytest execution engine executing tests shown in an exemplary embodiment of this application.

[0026] Figure 9It is a schematic structural diagram of a computer system of an electronic device shown in an exemplary embodiment of the present application. Detailed implementation manners

[0027] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0028] The block diagrams shown in the drawings are only functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0029] The flowcharts shown in the drawings are only exemplary descriptions, and do not necessarily include all contents and operations / steps, nor do they necessarily need to be executed in the described order. For example, some operations / steps can be decomposed, while some operations / steps can be combined or partially combined. Therefore, the actual execution order may change according to the actual situation.

[0030] In the present application, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.

[0031] Although the automated testing method of the related pytest framework has improved the testing efficiency to a certain extent, there are still problems such as slow acquisition of test cases and inability to intuitively provide users with corresponding test cases and their test results.

[0032] Therefore, one aspect of the present application provides a testing method based on the pytest architecture. For details, please refer to Figure 1 , Figure 1 It is a schematic flowchart of a testing method based on the pytest architecture shown in an exemplary embodiment of the present application. This testing method is applied to a management module, and the management module includes a pytest execution engine and a matching engine; the testing method at least includes S110 to S120, which are introduced in detail as follows.

[0033] S110: In response to a test instruction issued by the presentation layer, control the pytest execution engine to obtain the target path of the test case specified by the test instruction from the database, so that the pytest execution engine can obtain the specified test case based on the target path; wherein, the database, the management module, and the presentation layer all belong to the same program, and the path of the test case in the database is added by the matching engine; the test instruction carries a user identifier.

[0034] The test program of this application is built based on the pytest framework, and a database and a presentation layer are set in the test program to facilitate the storage of test cases and the display of relevant data information. The pytest execution engine in the management module serves as the test engine, which can quickly obtain the path of the corresponding test case from the database, so that it can obtain the test case specified by the test instruction based on the corresponding path.

[0035] The database does not directly store the instances of test cases, but the paths of test cases, which greatly reduces the storage resources of common databases and makes the database more lightweight. At the same time, this application reasonably divides and refines the module functions. The matching engine in the management module can add the paths of test cases to the database, and the matching engine and the pytest execution engine can cooperate, so that the paths in the database can be added or modified in real time during the test process.

[0036] The presentation layer is a window for displaying images and also an operable user interface. Users can operate the management module through the presentation layer. For example, the GUI (Graphics User Interface) layer can display relevant image information, and users can also trigger corresponding instructions through the GUI layer to send them to the management module of this application.

[0037] The test instruction not only specifies the corresponding test case, but also can carry a user identifier to bind the test information with the user identifier, which is convenient for subsequent permission management. For example, only the user corresponding to the bound user identifier is allowed to access the test results.

[0038] S120: Control the pytest execution engine to perform tests based on the specified test case, and control the pytest execution engine to bind the test results with the user identifier and the target path, store them in the database, and open the access permission to the user corresponding to the user identifier, so as to display the target path and the test results on the presentation layer.

[0039] Exemplarily, the pytest execution engine calls the corresponding function to load the specified test cases for software testing, and stores the test results obtained from the testing in a database. The display layer can display the test results based on the data stored in the database. In some embodiments, the test results and the corresponding test cases can also be displayed. The above test method and test system will be introduced exemplarily below.

[0040] Please refer to Figure 2 , Figure 2 which is a schematic diagram of a test system based on the pytest architecture shown in an exemplary embodiment of the present application. The test system includes a management module, a database, and a display layer. The management module includes a pytest execution engine and a matching engine; the pytest execution engine is used to obtain the target path of the test cases specified by the test instruction from the database, and obtain the specified test cases based on the target path; wherein, the paths of the test cases in the database are added through the matching engine in the management module; the test instruction carries a user identifier; the pytest execution engine is also used to perform tests based on the specified test cases, bind the test results with the user identifier and the target path, store them in the database, and open the access permission to the user corresponding to the user identifier to display the test results in the database on the display layer.

[0041] It should be noted that the test system provided here and the test method provided in the embodiments of the present application belong to the same concept. The specific manners in which each module and unit perform operations have been described in detail in the method embodiments and will not be elaborated here.

[0042] The present application constructs a corresponding test program through the pytest architecture, including a management module, a database, and a display layer. Through the display layer, users can not only issue test instructions but also intuitively know the test results. At the same time, the pytest execution engine in the management module can quickly obtain the specified test cases for testing based on the target paths stored in the local database, and store the test results in the database, which is convenient for unified management of the test cases and test results. Among them, the matching engine in the management module can flexibly add the paths of the test cases without directly storing the instances of the test cases in the database, thus realizing the lightweight management of the test cases.

[0043] In another exemplary embodiment of the present application, the role of the synchronization unit in the management module is introduced in detail. Please specifically refer to Figure 3 , Figure 3 which is Figure 1 a schematic flowchart of another test method shown in the exemplary embodiment shown. This test method, based on S110 to S120 shown in Figure 1 , further includes at least S310; wherein, the management module further includes a synchronization unit, which is introduced in detail as follows.

[0044] S310: Control the synchronization unit to obtain the original test cases from the externally connected use case repository, so that the matching engine determines the target test cases that meet the preset matching rules, and stores the target test cases in the database.

[0045] The use case repository is a repository independent of the program to which the management module belongs. It can be a massive repository storing test cases, test codes, etc. in the cloud. For example, the use case repository can be a git repository.

[0046] Please refer to Figure 4 , Figure 4 FIG. is a schematic diagram of another test system based on the pytest architecture shown in an exemplary embodiment of the present application. The management module further includes a synchronization unit. The synchronization unit can automatically obtain the original test cases from the externally connected use case repository. The matching engine, based on the preset matching rules, matches the original test cases with the relevant fields of the test items and test cases in the database to determine the storage folder of the original test cases, and uses its path name as its storage name.

[0047] When the test cases are stored in the database, it is not the instance content of the test cases that is stored, but the file path file of the test cases. In some embodiments, the description desc of the test cases will also be stored. Please refer to the content shown in Table 1 for the exemplary traversal code.

[0048] Among them, the preset matching rules include but are not limited to the storage format rules of test items and test files. The matching engine can quickly determine whether the original test cases are target test cases that meet the preset matching rules by checking whether the file format of the original test cases conforms to the preset storage format, and thus store the paths of the target test cases in the database. For example, the test items in the database are folders starting with "test_" and ending with "project", and the test case files are files starting with "test_" and ending with ".py". There is one test function in a test file, corresponding to one test case. At the same time, the test cases belong to the corresponding test items. Please refer to the directory code shown in Table 2 below for the code architecture involved between them.

[0049] In order to quickly obtain the test items, the test items of the present application can be obtained through pseudocode to quickly find all test items that meet the matching rules from the project directory. The exemplary pseudocode is shown in Table 3 below.

[0050] In this embodiment, by setting a synchronization unit in the management module, the latest original test cases are automatically obtained from the external use case repository in real time, the target test cases that meet the preset matching rules are determined therefrom, and the paths of the target test cases are synchronously stored in the local database. Users no longer need to manually pull or submit test case codes, greatly reducing the complexity of operations and the probability of errors. Through the matching engine, the test projects and test case files are automatically scanned and classified. By setting storage rules, the automated storage and management of test cases are ensured, and they are structurally stored in the database to support subsequent query and analysis.

[0051] In another exemplary embodiment of the present application, the management module further includes an editing unit, as Figure 5 shown, Figure 5 is a schematic diagram of another test system based on the pytest architecture shown in an exemplary embodiment of the present application. The management module further includes an editing unit and a synchronization unit; the editing unit is used to modify the test cases in the database in response to a modification instruction issued by the presentation layer, and transmit the modified test cases to the synchronization unit; the synchronization unit is used to obtain the original test cases from the externally connected use case repository, and is used to synchronize the test cases modified by the editing unit to the use case repository.

[0052] The user can issue a modification instruction through the presentation layer. The management module responds to the modification instruction issued by the presentation layer, controls the editing unit to modify the test cases in the database, and calls the synchronization unit to upload the modified test cases to the use case repository.

[0053] The editing unit and the synchronization unit have different functions and their division of labor is clear. The synchronization unit can serve as a bridge between the management module and the external use case repository, while the editing unit modifies the test cases in the local database and can also transmit the modified test cases to the synchronization unit so that the synchronization unit uploads the modified test cases to the use case repository to achieve real-time synchronization between the local database and the external test repository.

[0054] In another exemplary embodiment of the present application, how to control the pytest execution engine to perform tests based on specified test cases and store the test results in the database is introduced in detail. For details, please refer to Figure 6 , Figure 6 is based on Figure 1 shown in the exemplary embodiment shown, Figure 1 Another flowchart of a test method is shown in S120. The test method at least includes S610 to S620 in S120 as shown in

[0055] S610: Control the pytest execution engine to execute the test function to perform tests based on specified test cases.

[0056] A test function is a function used to load specified test cases for testing. The test function can start testing by scanning a specified test case file (such as specified test cases in a specified project) and recording eligible test cases.

[0057] S620: If the test is completed, control the pytest execution engine to execute the first hook function to capture the test results in the corresponding output stream and store them in the database, and send the test report corresponding to the test results to the display layer so that the display layer can display the test report; wherein, the test report is a report generated based on the test results and related data of the test results.

[0058] A hook function is a programming mechanism that allows developers to insert custom code at specific stages of program execution. Hook functions are usually used to extend or modify the behavior of a program without directly modifying the source code of the program. The first hook function here is a function used to capture test results. Different test results correspond to different output streams, such as stdout (the output stream corresponding to successful tests) and stderr (the output stream corresponding to failed tests). In some embodiments, the first hook function can also capture data related to test results such as log information, and in the case of a test failure, the first hook function can also capture error stack information, simplify the stack output, and store it.

[0059] This application can establish a connection between the first hook function and the report generation tool, so that after the report generation tool captures relevant test data in the first hook function, the report generation tool automatically generates a test report based on the relevant test data it captures. The test report can be a report integrated by a report generation tool such as Allure. The report generation tool extracts the test results from the database and generates a graphical report for developers and testers to view and analyze the test execution status.

[0060] At the same time, the synchronization unit of this application will automatically perform two-way synchronization with the test cases in the external repository. During the test process executed by the pytest execution engine, data such as test results can be automatically stored in the database, and the report generation tool can automatically generate corresponding test reports, thus achieving the effects of test case management, execution, result display, and data persistence.

[0061] In another exemplary embodiment of this application, the initialization configuration function of the pytest execution engine is introduced in detail. For details, please refer to Figure 7 , Figure 7 is based on Figure 1 , Figure 3 , Figure 6 The flowchart of another test method shown in any of the exemplary embodiments shown. This test method further includes at least S710 to S720, which are introduced in detail as follows.

[0062] S710: Control the pytest execution engine to execute the dependencies in the configuration file to initialize the database connection, and control the pytest execution engine to call the addition function to add the user identifier.

[0063] Exemplarily, the pytest execution engine executes the fixture (dependency) in conftest.py (configuration file), such as initializing the database connection to ensure that the database can be operated during the test. pytest_addoption() adds the user_id option to the command-line arguments of pytest to dynamically pass in the user identifier.

[0064] S720: Control the pytest execution engine to execute the second hook function to create the output stream and buffer corresponding to the specified test case.

[0065] The second hook function can create independent output streams (stdout and stderr) for each test case and capture the log output. The hook function also obtains the passed-in user_id, sets the start time for the current test case, and creates a buffer object to capture the output.

[0066] Furthermore, in some embodiments, if the log information of the specified test case in the buffer is detected, control the pytest execution engine to execute the third hook function to store the log information in the buffer into the attributes of the specified test case and clear the buffer.

[0067] After each test case is executed, the third hook function stops capturing the output stream, stores the data in the buffer into the attributes of the specified test case, and clears the buffer, improving the utilization efficiency of the buffer.

[0068] The following combines Figure 8 , and makes an exemplary description of the process of the pytest execution engine executing the test. Figure 8 is a schematic flowchart of the pytest execution engine executing the test shown in an exemplary embodiment of the present application.

[0069] Before the pytest execution engine executes the test, it will first perform initialization configuration. Based on the dependencies in the configuration file, it initializes the database connection to ensure that the database can be operated during the test. The pytest execution engine also adds the user identifier through pytest_addoption(), allowing users to dynamically specify the user ID during the test, supporting automatic matching of test case data according to the user ID, and providing a personalized test execution plan.

[0070] Before each test case is executed, the pytest execution engine executes pytest_runtest_setup (i.e., the second hook function above) to create corresponding test output streams (stdout and stderr) and buffers for each specified test case, ensuring that the logs are not mixed. pytest_runtest_setup also retrieves the incoming user_id parameter and records the start time when the current test case is being tested.

[0071] The pytest execution engine calls the test function pytest.main() to load the specified test cases for execution. After each test case is executed, pytest_runtest_makereport (i.e., the first hook function above) is triggered to calculate the execution duration of the test case, capture the test results, error stack traces, and logs in the corresponding output streams, and store the captured test results in the database in the form of CaseResult. At the same time, it is bound to the test case ID in the corresponding test project and can also be bound to the user ID for subsequent query and analysis. Meanwhile, the Allure report generation tool generates an Allure report based on the captured data.

[0072] After pytest_runtest_makereport is triggered, the pytest execution engine executes pytest_runtest_teardown (i.e., the third hook function above) to stop capturing the output stream, store the log information in the buffer into the attributes of the specified test case for subsequent use, and clear the buffer to improve the utilization efficiency of the buffer.

[0073] It can be seen that the pytest execution engine precisely controls log capture and result recording through the three hook functions pytest_runtest_setup, pytest_runtest_makereport, and pytest_runtest_teardown, automatically capturing and storing relevant data at each stage, thus ensuring the integrity of test execution and data consistency.

[0074] In addition, users can batch execute test cases through simple operations on the presentation layer. The pytest execution engine will automatically execute the tests and collect the execution results, further reducing manual intervention. The execution results will be recorded in the database in real time, supporting query and analysis. All execution information, including logs, error stack traces, standard output, etc., will be automatically stored, ensuring the integrity and traceability of the test results.

[0075] Another aspect of the present application also provides an electronic device, including: a controller; a memory for storing one or more programs, which, when executed by the controller, are configured to perform the above-described test method.

[0076] Please refer to Figure 9 , Figure 9 which is a schematic structural diagram of a computer system of the electronic device shown in an exemplary embodiment of the present application, showing a schematic structural diagram of a computer system of the electronic device suitable for implementing the embodiments of the present application.

[0077] It should be noted that Figure 9 the computer system 900 of the electronic device shown is only an example and should not impose any limitation on the functions and usage scope of the embodiments of the present application.

[0078] As Figure 9 shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 902 or the program loaded from the storage section 908 into the random access memory (RAM) 903, such as executing the method in the above embodiments. In the RAM 903, various programs and data required for system operation are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0079] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed so that a computer program read from it can be installed into the storage section 908 as needed.

[0080] In particular, according to an embodiment of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present application includes a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 909 and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, various functions defined in the system of the present application are executed.

[0081] It should be noted that the computer-readable medium shown in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. And in the present application, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable computer program. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted by any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0082] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. Among them, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the above-mentioned module, program segment, or part of code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in an order different from that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0083] The units described in the embodiments of the present application can be implemented in software or in hardware, and the described units can also be provided in a processor. Among them, the names of these units do not constitute a limitation to the units themselves in some cases.

[0084] Another aspect of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the foregoing test method is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist separately and not be assembled into the electronic device.

[0085] Another aspect of the present application also provides a computer program product or a computer program, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the test methods provided in the above various embodiments.

[0086] According to one aspect of the embodiments of the present application, a computer system is further provided, including a Central Processing Unit (CPU), which can perform various appropriate actions and processes according to the program stored in the Read-Only Memory (ROM) or the program loaded from the storage part into the Random Access Memory (RAM), such as executing the methods in the above embodiments. In the RAM, various programs and data required for system operation are also stored. The CPU, ROM, and RAM are connected to each other via a bus. An Input / Output (I / O) interface is also connected to the bus.

[0087] The following components are connected to the I / O interface: an input part including a keyboard, a mouse, etc.; an output part including such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc. and a speaker, etc.; a storage part including a hard disk, etc.; and a communication part including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part performs communication processing via a network such as the Internet. A drive is also connected to the I / O interface as required. A removable medium, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive as required so that a computer program read from it can be installed into the storage part as required.

[0088] The above content is only a preferred exemplary embodiment of the present application and is not used to limit the implementation of the present application. Those of ordinary skill in the art can make corresponding adaptations or modifications very conveniently according to the main concept and spirit of the present application. Therefore, the protection scope of the present application should be subject to the protection scope required by the claims.

Claims

1. A testing method based on the pytest architecture, characterized in that: The test method is applied to a management module, which includes a pytest execution engine, a matching engine, a synchronization unit, and an editing unit; the test method includes: In response to the test instruction issued by the display layer, the pytest execution engine is controlled to obtain the target path of the test case specified by the test instruction from the database, so that the pytest execution engine obtains the specified test case based on the target path; wherein the database, the management module, and the display layer all belong to the same program, and the path of the test case in the database is added by the matching engine; the test instruction carries a user identifier; the editing unit is used to respond to the modification instruction issued by the display layer, modify the test case in the database, and transmit the modified test case to the synchronization unit, so that the synchronization unit synchronizes the modified test case to the externally connected test case warehouse; Control the pytest execution engine to perform testing based on the specified test case, and control the pytest execution engine to bind the test result with the user identifier and the target path, store them in the database, and open access rights to the user corresponding to the user identifier to display the target path and test results in the presentation layer.

2. The testing method according to claim 1, characterized in that: The test method also includes: The synchronization unit is controlled to obtain original test cases from the use case warehouse, so that the matching engine determines target test cases that meet preset matching rules, and stores the target test cases in the database.

3. The testing method according to claim 2, characterized in that: The test method also includes: In response to the modification instruction sent by the presentation layer, the editing unit is controlled to modify the test cases in the database, and the synchronization unit is called to upload the modified test cases to the test case repository.

4. The testing method according to claim 1, characterized in that: Controlling the pytest execution engine to perform testing based on the specified test case and storing the test results in the database includes: Control the pytest execution engine to execute the test function to perform the test based on the specified test case; If the test is completed, the pytest execution engine is controlled to execute the first hook function to capture the test results in the corresponding output stream and store them in the database, and the test report corresponding to the test results is sent to the presentation layer so that the presentation layer displays the test report; wherein the test report is a report generated based on the test results and related data of the test results.

5. The testing method according to any one of claims 1 to 4, characterized in that: The test method also includes: Control the dependencies in the pytest execution engine execution configuration file to initialize the connection to the database, and control the pytest execution engine to call the add function to add a user ID; Control the pytest execution engine to execute the second hook function to create an output stream and a buffer corresponding to the specified test case.

6. The testing method according to claim 5, characterized in that: The test method also includes: If the log information of the specified test case is detected in the buffer, the pytest execution engine is controlled to execute the third hook function to store the log information in the buffer into the attributes of the specified test case and clear the buffer.

7. A test system based on pytest architecture, characterized in that: The test system includes a management module, a database, and a display layer. The management module includes a pytest execution engine, a matching engine, a synchronization unit, and an editing unit; The pytest execution engine is used to obtain the target path of the test case specified by the test instruction from the database, and obtain the specified test case based on the target path; wherein the path of the test case in the database is added by the matching engine, and the test instruction carries a user identifier; The pytest execution engine is also used to perform testing based on the specified test case, and bind the test result with the user identifier and the target path, and store it in the database, so as to display the target path and the test result in the presentation layer; The editing unit is used to modify the test cases in the database in response to the modification instructions issued by the presentation layer, and transmit the modified test cases to the synchronization unit; The synchronization unit is used to obtain the original test case from the external use case warehouse, and to synchronize the test case modified by the editing unit to the use case warehouse.

8. An electronic device, characterized in that: include: Controller; A memory for storing one or more programs, which, when executed by a controller, enables the controller to implement the test method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the testing method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the testing method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Test method, device, equipment, system and medium for operating system

    CN109491916A

  • Automatic testing method and device, computer equipment and storage medium

    CN115437933A

  • Test case generation method and device, computer equipment and storage medium

    CN115437935A

  • Application program testing method, system, device and equipment and storage medium

    CN117520172A