Test Method, System, Electronic Device and Storage Medium Based on pytest Architecture

Through the testing methods and systems based on the pytest architecture, the problems of slow acquisition and inconvenient management of test cases in the existing pytest framework are solved, and the effect of quickly obtaining and displaying test results is achieved, improving the testing efficiency and lightweight use case management.

CN120066973BActive Publication Date: 2025-07-08CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The automated testing method of the existing pytest framework cannot quickly obtain specified test cases, and lacks effective management of test cases and test results, so it cannot be provided intuitively to users.

Method used

Based on the pytest architecture, test methods and systems are built, including management modules, databases and presentation layers. Test cases are quickly obtained through the pytest execution engine and stored test results in the database to achieve unified management of test cases and results.

Benefits of technology

It realizes rapid acquisition of specified test cases and intuitive presentation of test results, reduces operational complexity, improves testing efficiency, and realizes lightweight management of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120066973B_ABST
    Figure CN120066973B_ABST
Patent Text Reader

Abstract

The present application relates to the field of testing, and discloses a testing method, system, electronic device, and storage medium based on the pytest architecture. The testing method includes: in response to a test instruction issued by the presentation 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 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; controlling the pytest execution engine to perform testing 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 target path and the test result on the presentation layer. The present application can quickly obtain the specified test case for testing and display the corresponding test result on the presentation layer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of vehicle technologies, 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 a specified test case from numerous test cases, and it is impossible to quickly obtain the specified test case 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 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 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; where 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 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 presentation 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 presentation layer so that the presentation 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 case 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 case 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 the present application. In order to understand the technical means of the present 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 the present application more obvious and understandable, the following specific embodiments of the present application are specifically given. Brief Description of the Drawings

[0017] The drawings herein are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application. Obviously, the drawings in the following description are only some embodiments of the present 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 the present application.

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

[0020] Figure 3 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 the present 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 the present application.

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

[0024] Figure 7 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 the present 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 examples thereof 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 and indicates 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] For this reason, 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 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 further used to perform testing 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, 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 cases for testing based on the target paths stored in the local database, and store the test results in the database, facilitating the 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, on the basis of 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. Based on the preset matching rules, the matching engine 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] The test cases are stored in the database, not their instance contents, 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 it is a target test case that meets the preset matching rules by checking whether the file format of the original test case conforms to the preset storage format, so as to store the path of the target test case 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". A test file contains a test function, 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, a synchronization unit is set in the management module to automatically obtain the latest original test cases from the external use case repository in real time, determine the target test cases that meet the preset matching rules therefrom, and synchronously store the paths of the target test cases 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 queries and analyses.

[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 the modification instruction issued by the display 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 synchronize the test cases modified by the editing unit to the use case repository.

[0052] Users can issue a modification instruction through the display layer. The management module responds to the modification instruction issued by the display 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 clear division of labor. 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, which is a schematic flowchart of another test method. This test method at least includes S610 to S620 in S120 as shown in Figure 1 shown, and is introduced in detail as follows.

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

[0056] The 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 a specified test case 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] The 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 program's source code. 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 through 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, it can automatically store data such as test results 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 at least further includes 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 testing. 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] Further, 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 testing. 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 logs are not mixed. pytest_runtest_setup also obtains 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 stacks, and logs in the corresponding output streams, store the captured test results in the database in the form of CaseResult, bind them to the test case IDs in the corresponding test projects, and can also be bound to user IDs for subsequent query and analysis. At the same time, 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] From this, 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 stacks, standard output, etc., will be automatically stored, ensuring the integrity and traceability of the test results.

[0075] Another aspect of the present application further provides an electronic device, 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.

[0076] Please refer to Figure 9 , Figure 9 which is a schematic structural diagram of a computer system of an electronic device shown in an exemplary embodiment of the present application, and shows a schematic structural diagram of a computer system of an 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 limitations 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-mentioned 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 a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; 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 required. 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 required, so that the computer program read from it can be installed into the storage section 908 as required.

[0080] In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present application include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for performing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 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 performed.

[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 above two. A 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 may 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, a computer-readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or combined with an instruction execution system, apparatus, or device. In the present application, a 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. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and the computer-readable medium can send, propagate, or transmit a program for use by or combined with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted by any suitable 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 function. 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 involved in the embodiments described in 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 on the units themselves in some cases.

[0084] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned test method is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist alone without being assembled into the electronic device.

[0085] On the other hand, the present application also provides a computer program product or a computer program, and 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 an embodiment 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 a program stored in a Read-Only Memory (ROM) or a program loaded from a storage section into a Random Access Memory (RAM), such as executing the method in the above embodiment. 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 section including a keyboard, a mouse, etc.; an output section including, for example, a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc. and a speaker, etc.; a storage section including a hard disk, etc.; and a communication section including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 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 section 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 easily make corresponding adaptations or modifications according to the main concept and spirit of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope required by the claims.

Claims

1. A testing method based on the pytest framework, characterized in that The described 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 a test instruction issued by the presentation 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 presentation layer all belong to the same program, and the path of the test case in the database is the path of the original test case that conforms to the preset matching rule added by the matching engine, and the original test case is obtained by the synchronization unit from an externally connected use case repository; the test instruction carries a user identifier; the editing unit is used to respond to the modification instruction issued by the presentation 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 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 target path and the test result on the presentation layer.

2. The test method according to claim 1, characterized in that, The test method further includes: Controlling the synchronization unit to obtain the original test case from the use case repository, so that the matching engine determines the target test case that conforms to the preset matching rule, and stores the path of the target test case in the database.

3. The test method according to claim 2, wherein The test method further includes: In response to the modification instruction issued by the presentation layer, controlling the editing unit to modify the test case in the database, and calling the synchronization unit to upload the modified test case to the use case repository.

4. The test method according to claim 1, wherein Controlling the pytest execution engine to perform tests based on the specified test case and storing the test result in the database includes: Controlling the pytest execution engine to execute a test function to perform tests based on the specified test case; If the test is completed, controlling the pytest execution engine to execute a first hook function to capture the test result in the corresponding output stream and store it in the database, and send the test report corresponding to the test result 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 result and the relevant data of the test result.

5. The test method according to any one of claims 1 to 4, characterized in that, 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 call 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 case.

6. The test method according to claim 5, wherein The test method further includes: 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.

7. A test system based on the 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. Among them, the path of the test case in the database is the path of the original test case that conforms to the preset matching rules added by the matching engine. The original test case is obtained by the synchronization unit from the externally connected use case repository, and the test instruction carries a user identifier. The pytest execution engine is also used to perform tests based on the specified test case, bind the test results to the user identifier and the target path, and store them in the database to display the target path and test results on the display layer. 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. The synchronization unit is used to obtain the original test case from the use case repository and synchronize the test case modified by the editing unit to the use case repository.

8. An electronic device, characterized in that, Including: A controller; A memory for storing one or more programs. When the one or more programs are executed by the controller, the controller implements the test method described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, A computer-readable instruction is stored thereon. When the computer-readable instruction is executed by the processor of the computer, the computer executes the test method described in 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 the processor, it implements the test method described in any one of claims 1 to 6.

Citation Information

Patent Citations

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

    CN115437933A

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

    CN115437935A