Test method, device and equipment of data sharing and exchanging platform and storage medium
The automatic testing of the data sharing exchange platform through the method driven by test case cases solves the tedious and high cost of testing scripts in existing technologies, and achieves efficient and accurate testing processes.
Patent Information
- Application Number
- CN202411898089.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-01-24
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
During the testing process of data sharing and exchange platform, the existing technology has problems such as cumbersome and redundant test scripts and high development and maintenance costs, especially in the scenario of accessing massive systems and data.
Drive the test environment deployment and test steps through the test case, and use the test case written by fixed templates as the support of automated testing to generate an automated test script and run in the constructed test environment to obtain the test results.
The cost of development and maintenance of automated testing is reduced, the test efficiency and accuracy are improved, and the test errors caused by the error caused by the human configuration parameter are reduced.
Smart Images

Figure CN119357019A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a testing method, device, equipment and storage medium for a data sharing and exchange platform. Background Art
[0002] The data sharing and exchange platform needs to uniformly manage the data of multiple units and connect the application systems of each unit to complete data exchange and information sharing. The data sharing and exchange platform contains multiple functional components, such as API interfaces, file systems, and database tables. For example, the government data sharing and exchange platform needs to uniformly manage the data of various business units.
[0003] During the testing process of the data sharing and exchange platform, the verification of each type of functional component requires complex and tedious test scenario deployment and prerequisite setting. For example, when testing the routing and forwarding function of an API interface, it is necessary to add a configuration directory, configure the meta-API interface, add the API metadata, add the configuration routing and forwarding association, and review the registration of interface resources and the application for online application of interface resources. Only after the above scenario deployment and prerequisite adjustments are correctly configured, can the interface access verification result be tested.
[0004] However, in the scenario of accessing massive systems and data, the above-mentioned testing method has problems such as cumbersome and redundant test scripts, high development and maintenance costs, etc. in the testing process of the data sharing and exchange platform. Summary of the invention
[0005] The embodiments of the present application provide a testing method, apparatus, device and storage medium for a data sharing and exchange platform, which can drive the deployment of the test environment and the execution of test steps through test cases. In the scenario of accessing massive systems and data, test cases written based on fixed templates can be used as support for automated testing, without the need to develop additional test scripts, thereby reducing the development and maintenance costs of automated testing, improving test efficiency, and improving test accuracy. The technical solution is as follows.
[0006] In one aspect, a method for testing a data sharing and exchange platform is provided, the method comprising: Obtain a target test case corresponding to the tested object in the test case table, wherein the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in a target test case set contained in the test case table, and the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case includes pre-set test environment configuration data and test step data; Constructing a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case to obtain a test environment corresponding to the target test case; Generate an automated test script based on the test step data of the target test case; In the test environment corresponding to the target test case, the automated test script is run to obtain the test result of the tested object corresponding to the target test case.
[0007] On the other hand, a test device for a data sharing and exchange platform is provided, the device comprising: A case acquisition module is used to acquire a target test case corresponding to a tested object in a test case table, wherein the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in a target test case set contained in the test case table, wherein the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case includes pre-set test environment configuration data and test step data; An environment construction module, used to construct a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case, to obtain a test environment corresponding to the target test case; A script generation module, used to generate an automated test script based on the test step data of the target test case; The test module is used to run the automated test script in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case.
[0008] In a possible implementation, the functional components in the data sharing and exchange platform include an interface component, a file system component, and a library table component; each functional component type has a corresponding test case set; the case acquisition module is used to: Obtaining the functional component type of the object under test; The target test case corresponding to the object under test in the test case table is obtained based on the functional component type of the object under test.
[0009] In a possible implementation, the environment construction module includes: A file acquisition submodule, used to acquire a test environment topology class file associated with the test environment topology identifier; the test environment topology class file includes a configuration method of the test environment; The environment construction submodule is used to construct the test environment based on the test environment topology class file and the test environment configuration data of the target test case to obtain the test environment corresponding to the target test case.
[0010] In a possible implementation, the test environment includes a data sharing and exchange platform and a simulation test service; the simulation test service is used to simulate the base data corresponding to the object under test; The environment construction submodule is used to configure the data sharing exchange platform based on the first configuration mode of the data sharing exchange platform indicated by the test environment topology class file and the test environment configuration data; and The simulation test service is configured based on the second configuration mode of the simulation test service indicated by the test environment topology class file and the test environment configuration data.
[0011] In a possible implementation, the test case also includes an expected test result, and the device further includes: A comparison module, used to compare the test results of each test case with the corresponding expected test results to obtain a comparison result of each test case; The pass status determination module is used to comprehensively determine the test pass status of the tested object based on the comparison results of each test case.
[0012] In a possible implementation manner, the device further includes: The report generation module is used to generate a visual test report of the tested object based on the comparison results of each test case and the test pass status.
[0013] On the other hand, a computer device is provided, which includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the above-mentioned test method of the data sharing and exchange platform.
[0014] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The computer program is loaded and executed by a processor to implement the above-mentioned test method of the data sharing and exchange platform.
[0015] On the other hand, a computer program product is provided, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions, which, when executed by a computer, cause the computer to execute to implement the testing method of the data sharing and exchange platform provided in the above-mentioned various optional implementations.
[0016] The technical solution provided by this application may have the following beneficial effects: The testing method of the data sharing and exchange platform provided in the embodiment of the present application pre-sets various test cases corresponding to the tested object. When the functional component in the data sharing and exchange platform has a test requirement as the tested object, the target test case corresponding to the tested object in the test case table is obtained, and the test environment is constructed based on the test environment topology identifier associated with the target test case and the test environment configuration data in the target test case to obtain the test environment corresponding to the target test case; an automated test script is generated based on the test step data of the target test case, and the automated test script is run in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case; through the above method, the test environment deployment and test step execution can be driven by the test case. In the scenario of accessing massive systems and data, the test case written based on the fixed template can be used as the support for automated testing, and there is no need to develop additional test scripts, thereby reducing the development and maintenance costs of automated testing and improving testing efficiency; in addition, by automating the test process, the configuration content of the tester during the test process can be reduced, thereby reducing the test errors caused by human configuration parameter errors and improving the test accuracy.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0019] Figure 1 A flow chart showing a method for testing a data sharing and exchange platform provided by an exemplary embodiment of the present application is shown; Figure 2 A flow chart showing a method for testing a data sharing and exchange platform provided by an exemplary embodiment of the present application is shown; Figure 3 A schematic diagram showing a testing process of a data sharing and exchange platform provided by an exemplary embodiment of the present application is shown; Figure 4 A block diagram of a test device for a data sharing and exchange platform provided by an exemplary embodiment of the present application is shown; Figure 5 A structural block diagram of a computer device shown in an exemplary embodiment of the present application is shown; Figure 6 A structural block diagram of a computer device shown in an exemplary embodiment of the present application is shown. DETAILED DESCRIPTION
[0020] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0021] In order to solve the problems of cumbersome and redundant test scripts, low test efficiency, and high development and maintenance costs in the scenario of accessing massive systems and data in the data exchange platform automated test, the present application embodiment provides a test method for a data sharing exchange platform. Figure 1 A flowchart of a method for testing a data sharing exchange platform provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device, which can be implemented as a server or a terminal, such as Figure 1 As shown, the testing method of the data sharing exchange platform may include the following steps: Step 110, obtain the target test case corresponding to the tested object in the test case table, where the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in the target test case set contained in the test case table, and the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case contains pre-set test environment configuration data and test step data.
[0022] In an embodiment of the present application, each test case in the test case table is written according to a fixed template, and the test case table contains use case information of at least one test case. Each test case can be used to test a function or scenario of the corresponding tested object. Schematically, taking the tested object as an API interface, each test case in its corresponding test case set is used to test the user login function as an example, which may include test cases corresponding to various test scenarios such as successful login, failed login, empty user name, empty password, etc.; when testing the tested object, the computer device can perform detection based on each test case pair corresponding to the tested object in the test case table to comprehensively detect the applicability of the function or scenario of the tested object; the use case information of the test case may include a test case identifier (ID, Identifier), a use case name, prerequisites, test environment configuration data, test step data, and expected test results, etc., and also includes a test environment topology identifier associated with the test case.
[0023] In one possible implementation, the data sharing and exchange platform may include multiple functional components, and the test cases of the multiple functional components may be written in the same test case table. In this case, each functional component may have a corresponding test case set, and the test case set may include test cases corresponding to the functional component. The computer device may locate the corresponding test case set in the test case table by identifying the name, number or other unique identification information of the tested object; schematically, the test case table may be implemented as an Excel table, and the computer device may use the xlrd library to read and operate the test case Excel, such as the "data.xls" file, and the table data in the file is the test case. The xlrd library is an extension component for reading Excel based on Python; the computer device reads the table data in the test case Excel and stores it in the test case dictionary, and extracts the corresponding test case set in the test case dictionary according to the type of the tested object, so as to detect the corresponding type of the tested object based on the test cases in the extracted test case set.
[0024] Step 120 , constructing a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case, to obtain a test environment corresponding to the target test case.
[0025] The test environment topology identifier associated with each test case can also be stored in the test case dictionary to facilitate the computer device to extract the test environment topology identifier corresponding to the test case. The test environment topology identifier is used to accurately point to a specific test environment topology situation. The test environment topology identifier can be a unique identifier in the form of a string, or a digital number according to a specific encoding rule, etc. The present application does not limit the implementation form of the test environment topology identifier.
[0026] The test environment topology identifier is used to indicate the test environment topology corresponding to the target test case. The test environment topology refers to the architecture and layout of the test environment. For example, the various devices contained in the test environment and the connections between the various devices, such as the connection relationship between servers, network devices, and storage devices, etc. Different functional component tests may require different test environment topologies to simulate real usage scenarios. For example, for functional tests involving the transmission of stolen data, a specific distributed server topology may be required to reflect the flow of data between multiple nodes.
[0027] The test environment configuration data includes various specific setting parameters, such as software version information (such as operating system version, database management system version, etc.), hardware resource allocation (such as memory allocation, hard disk storage space, etc.), network-related settings (such as IP address allocation, subnet mask, network management, etc.), and startup configuration of various services, etc., which correspond to the parameter configuration of the test requirements of the test object.
[0028] When constructing a test environment, the computer device can determine the overall test environment architecture based on the above-mentioned test environment topology identifier, and configure parameters according to the various parameters in the test environment configuration data, thereby completing the construction of the test environment corresponding to the target test case.
[0029] Step 130: Generate an automated test script based on the test step data of the target test case.
[0030] Test step data is used to describe the operation steps and verification process for the object being tested, which includes the parameters required for the automated test script, such as the access address, request method, request parameters, expected test results, etc.; for example, for a test case of a data query function component, its test step data may indicate the following test steps: first log in to the system, then enter specific query conditions, then click the query button, and finally view the returned query results.
[0031] When generating an automated test script, the computer device will convert the test step data into corresponding logic code according to the rules of the selected automated test tool and framework, that is, generate the corresponding automated test script; schematically, taking the pytest test framework as an example, the computer device can use the setup function to read the test case to extract the test step data, and then, by adding the decorator @pytest.mark.parametrize() in front of each test function, the test step data of each test case is input into the test script respectively, and the request is constructed in the test function according to the access address, request method and request parameters in the incoming test step data, and verified according to the expected test results, so as to generate an automated test script. Among them, the setup function is divided into module level, class level, function level and function level. The computer device can select the corresponding level of setup function for application based on actual needs, such as selecting the class-level setup function for test case reading.
[0032] Step 140: Run the automated test script in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case.
[0033] Place the written automated test script into the corresponding constructed test environment to ensure that the automated test script can normally access the tested object and related resources, such as servers and databases in the test environment, so that it can perform operations according to the preset steps.
[0034] After starting the execution of the automated test script, the automated test script can simulate user operations or execute corresponding test instructions according to the code logic, and perform a series of operations on the tested object in the test environment. During and after the running of the automated test script, the computer device can collect various relevant information as the test results of the tested object corresponding to the target test case, such as whether the operation is successfully executed, the returned test data, the response time of the function, etc.
[0035] After completing the test of the object under test based on the target test case, the object under test can continue to be tested through other test cases in the test case table to achieve comprehensive detection of the object under test.
[0036] The data sharing platform may include multiple functional components. In this case, if there is a need to test the data sharing platform, the computer device can complete the testing of each functional component based on the test case set corresponding to each functional component in the test case table according to the detection steps of the above-mentioned target test case. After completing the testing of each functional component, the computer device can comprehensively determine the comprehensive testing status of the data sharing exchange platform based on the test results of each functional component.
[0037] In summary, the testing method of the data sharing and exchange platform provided in the embodiment of the present application pre-sets various test cases corresponding to the tested object. When the functional component in the data sharing and exchange platform has a test requirement as the tested object, the target test case corresponding to the tested object in the test case table is obtained, and the test environment is constructed based on the test environment topology identifier associated with the target test case and the test environment configuration data in the target test case to obtain the test environment corresponding to the target test case; an automated test script is generated based on the test step data of the target test case, and the automated test script is run in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case; through the above method, the test environment deployment and test step execution can be driven by the test case. In the scenario of accessing massive systems and data, the test case written based on the fixed template can be used as the support for automated testing, and there is no need to develop additional test scripts, thereby reducing the development and maintenance costs of automated testing and improving testing efficiency; in addition, by automating the test process, the configuration content of the tester during the test process can be reduced, thereby reducing the test errors caused by human configuration parameter errors and improving the test accuracy.
[0038] In a possible implementation, the data sharing and exchange platform includes multiple types of functional components; each functional component type has a corresponding test case set; the computer device can determine the corresponding test case set based on the functional component type of the tested object, and then obtain the corresponding test case; based on this, Figure 2 A flowchart of a method for testing a data sharing exchange platform provided by an exemplary embodiment of the present application is shown. The method can be executed by a computer device, which can be implemented as a server or a terminal, such as Figure 2 As shown, the testing method of the data sharing exchange platform may include the following steps: Step 210: Obtain the functional component type of the object under test.
[0039] In one possible implementation, the functional components in the data sharing and exchange platform include an interface component, a file system component, and a library and table component; wherein the interface component is a component in the data sharing and exchange platform used to connect different systems and realize data interaction. Schematically, the interface component can be a RESTful API interface, a Web Service interface, etc.; the file system component is a component in the data sharing and exchange platform used to store, manage and share files; the library and table component refers to a component in the data sharing and exchange platform that manages the table structure in the database and performs operations such as data storage, query and update in the table.
[0040] Corresponding to the functional component types, the test cases in the test case table can also be divided into three categories, namely, interface test case sets, file system test case sets and library table test case sets. The test steps of each type of test case are different; indicatively, the test of the interface component requires unique data such as access address, request method, request parameters, request header, etc.; the test of the file system component requires login user name, login password, file system address and path, file name, file type and other field data; the test of the library table component requires database type, database login user name, database login password, database library name, database table name, database storage field name and other field data.
[0041] Step 220: Obtain a target test case corresponding to the object under test in the test case table based on the functional component type of the object under test.
[0042] In an embodiment of the present application, a computer device can enter different data extraction branches based on the functional component type of the object under test, that is, determine the test case set corresponding to the object under test in the test case table, and extract the test cases in the test case set as target test cases.
[0043] Step 230 , constructing a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case, to obtain a test environment corresponding to the target test case.
[0044] In a possible implementation, the process of building a test environment can be implemented as follows: Obtain a test environment topology class file associated with a test environment topology identifier; the test environment topology class file includes a configuration method of the test environment; The test environment is constructed based on the test environment topology class file and the test environment configuration data of the target test case to obtain the test environment corresponding to the target test case.
[0045] That is to say, an association relationship is established between the test environment topology identifier and the test environment topology class file, and the test topology class file describes the hardware and software architecture layout of the test environment of the corresponding test case; in a possible implementation method, the computer device can define a test environment topology enumeration to achieve a one-to-one association and binding between the test environment topology ID (i.e., the test environment topology identifier) and the test environment topology class name (Test_topology_X, X is the test environment topology ID); wherein the name of the enumeration member is the test environment topology ID, and the value of the enumeration member is the corresponding test environment topology class file. For example, in the test topology enumeration Test_topology, there is an enumeration member such as "API_MAPPING_01: Test_topology_API_MAPPING_01", indicating that when the topology identifier is "API_MAPPING_01", the associated class file is "Test_topology_API_MAPPING_01".
[0046] Optionally, after obtaining the test environment topology identifier associated with the target test case, the computer device may first check whether the test environment topology identifier exists in the enumeration members. When it is determined that the test environment topology identifier exists in the enumeration members, the computer device may index and obtain the corresponding test environment topology class file; the test environment topology class file contains the method for configuring the test environment, describes the hardware and software architecture layout of the test environment, and may include the allocation of hardware resources such as servers, software deployment such as operating systems, middleware, and databases, and the interaction between components, so as to provide guidance for the construction of the entire test environment.
[0047] Optionally, the test environment includes a data sharing and exchange platform and a simulation test service; the simulation test service is used to simulate the base data of the corresponding tested object; the base data refers to the basic environment data that the tested object relies on during normal operation and interaction. Taking the interface component as an example, if you want to test a data query interface, the simulation test service can simulate a batch of basic data that conforms to the expected input format and business logic of the interface, so that the query interface has data to query during testing, and then simulates the process of the interface receiving requests and returning corresponding query results in the actual usage scenario.
[0048] In the case where the test environment includes a data sharing and exchange platform and a simulation test service, each test environment topology class file may have two functions: configuring the data sharing and exchange platform and configuring the simulation test service; wherein, the configuration of the data sharing and exchange platform may include the configuration of the object under test in the data sharing and exchange platform; for example, when testing the interface capability mapping function of the interface component, the test environment topology Test_topology_API_MAPPING_01 class is preset, and the test environment topology class file corresponding to the Test_topology_API_MAPPING_01 class includes the method of configuring the object under test in the data sharing and exchange platform: registering the directory, adding interface resources, registering resources, and launching resources; and the method of configuring the MockTest Server (simulation test service): providing an interface in a test case for external exposure. The test case of this function is associated with the test topology ID: API_MAPPING_01. The enumeration member "API_MAPPING_01: Test_topology_API_MAPPING_01" is predefined in the test topology enumeration Test_topology. First, it is determined whether there is an enumeration member named API_MAPPING_01. If so, the value of the enumeration member Test_topology_API_MAPPING_01 is returned.
[0049] Through the above configuration, the test topology configuration can be separated by enumeration, making the entire test architecture clearer and more modular. When relevant personnel add, modify or delete a test environment topology configuration, they can simply perform corresponding operations in the enumeration definition and the corresponding test environment topology class file without searching or modifying in the test code, thereby reducing development and maintenance costs. In addition, it also avoids distortion of test results caused by manual configuration environment errors, ensuring the accuracy and stability of test environment construction.
[0050] The test environment topology class file includes a first configuration method for configuring the data sharing exchange platform and a second configuration method for configuring the simulation test service. Therefore, when constructing the environment, the computer device can configure the data sharing exchange platform based on the first configuration method for the data sharing exchange platform indicated by the test environment topology class file and the test environment configuration data; and, The simulation test service is configured based on the second configuration mode of the simulation test service indicated by the test environment topology class file and the test environment configuration data.
[0051] Among them, the data sharing platform configuration items include metadata configuration, data source management and resource management, etc. Each type of configuration item includes operations such as adding, deleting, modifying, querying, registering, reviewing and launching. For example, metadata configuration involves the addition of new business metadata structure descriptions and the modification of the meaning of existing metadata fields; data source management includes the addition of new data source access points and the deletion of data sources that are no longer used; resource management covers operations such as the addition and integration of data resources and the modification of permissions.
[0052] In one possible implementation, the computer device can adopt an interface testing method, use Python's Requests component to realize the encapsulation of automated configuration actions, and then send HTTP requests through the component to simulate each configuration action; next, based on the test environment requirements of the test case, the configuration actions are combined into a test environment configuration combination in a certain order and dependency relationship to obtain the test environment configuration combination required for the current test case, and then each configuration action is adjusted according to the configuration parameters in the test case to complete the configuration deployment of the data sharing and exchange platform.
[0053] In one possible implementation, the test environment configuration combination is divided according to different functional components, that is, the test cases of the same type of functional components are divided into one test environment. After the test environment configuration combination corresponding to different functional components is encapsulated, it is applied to the environment configuration of each test case of the functional component. When applied, the test environment is adaptively adjusted according to the configuration parameters in the test case. For example, for different interface test cases, although based on the same interface component configuration combination, the simulation interface is adjusted according to the interface request parameter range, response verification rules and other parameters specified in each case, to reduce configuration duplication, avoid resource waste, and improve test efficiency.
[0054] In an embodiment of the present application, the simulation test service can be applied not only to the simulation of the interface, but also to the simulation of the file system and the database table. By configuring the simulation test service, the simulation of the base data of the corresponding component can be realized, thereby solving the dependency problem between metadata and enriching the test scenarios.
[0055] The computer device performs simulation test service configuration work according to the steps specified in the second configuration method indicated by the test environment topology class file and in combination with the test environment configuration data, so that the simulation test service can simulate the base data of the corresponding functional component; wherein, the second configuration method indicated by the test environment topology class file can specify specific configuration details in terms of resource allocation, initial state setting, and interaction rules with other related services for the corresponding components of the simulation test service (such as interfaces, file systems, and database-related components). These details complement the test environment configuration data extracted from the test case and jointly guide the configuration work of the simulation test service; schematically, the base data corresponding to the interface component can be implemented in the form of Python flask component simulation; different business scenarios may involve different types of interfaces, such as RESTful interfaces, SOAP interfaces, etc. During simulation, a simulation interface can be constructed based on the specific interface type and the business scenarios specified in the test case (such as interfaces corresponding to query, update, and delete operations); wherein the message content such as the return result and status code of the interface can be extracted from the test environment configuration data of the test case; the base data corresponding to the file system component can be implemented in the form of Python flask component simulation; different business scenarios may involve different types of interfaces, such as RESTful interfaces, SOAP interfaces, etc. During simulation, a simulation interface can be constructed based on the specific interface type and the business scenarios specified in the test case (such as interfaces corresponding to query, update, and delete operations); wherein, the message content such as the return result and status code of the interface can be extracted from the test environment configuration data of the test case; The pyftplib component simulation implementation simulates actual functions such as file reading and writing, permission management, and directory operations based on parameters such as file path, file name, and type extracted from the test environment configuration data; the base data corresponding to the database table component can be the MySQL, SQL Server, and Oracle databases that have been installed and configured, and the database settings and library table configurations are performed through the Python sqlalchemy component.
[0056] Step 240: Generate an automated test script based on the test step data of the target test case.
[0057] The process of generating automated test scripts can refer to Figure 1 The relevant contents of the illustrated embodiment will not be repeated here.
[0058] Step 250: Run the automated test script in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case.
[0059] Since the test cases of this application can be divided into three directions: interface direction, file system direction, and database table direction, when performing automated testing, different automated test components can be called for different types of tested objects to assist in completing the test process. Schematically, the test of the interface component is implemented based on Python's Request component, and the interface access method of the component is called in its corresponding automated test script to send a request and obtain the corresponding return data; the test of the file system component is implemented based on Python's pyftplib component, and the file server link related methods of the component are called in its corresponding automated test script to perform operations such as reading and writing on the files provided by the file server. The test of the library table component is implemented based on Python's sqlalchemy component, and during the execution of its corresponding automated test script, the component is used to access the relevant data stored in the database in the test step data, so as to implement the corresponding test operations.
[0060] In the embodiment of the present application, the test case also includes an expected test result. After the test step is executed, the computer device can also determine whether the test has passed based on the expected test result in the test case. The method also includes: Compare the test results of each test case with the corresponding expected test results to obtain the comparison results of each test case; The test pass status of the tested object is comprehensively determined based on the comparison results of each test case.
[0061] If the comparison result of any test case indicates that the test result is inconsistent with the expected test result, it is determined that the tested object has failed the test; if the comparison results of all test cases indicate that the test results are consistent with the expected test results, it is determined that the tested object has passed the test.
[0062] Furthermore, the computer device can also determine the test pass status of the tested object in combination with the information in the simulation test service log generated by the simulation test service. In principle, when the comparison results of all test cases indicate that the test results are consistent with the expected test results, it is determined based on the simulation test service log whether the simulation data in the corresponding base data has been accessed. If the simulation test service log indicates that the simulation data has not been accessed, it means that the test has not been fully executed as expected and there are potential problems. Although the current test results are consistent with the corresponding expected test results, it is still necessary to further check the test process and the configuration of the simulation data. If the simulation test service log indicates that the simulation data has been accessed, it means that the current tested object has passed the test.
[0063] In a possible implementation, the method further includes: Generate a visual test report of the tested object based on the comparison results of each test case and the test pass status.
[0064] The visual report can display the comparison results of each test case, as well as the test pass status of the tested object determined by comprehensively comparing the comparison results of each test case. Furthermore, the visual report can also display the test process of each test case, the overall test pass rate, and improvement suggestions generated in the event of a test failure, etc.
[0065] Schematically, the summary statistics of test results and the generation of visual test reports can be implemented by computer devices based on the fixture firmware tag and hookimpl tag of the Pytest framework. The function decorated with @pytest.fixture is a shell function executed before and after the test function runs. Developers can define its code content to meet various operation requirements such as logging in and out, opening and closing applications, etc. In a possible implementation, the computer device can use the session-level fixture decorator to obtain information such as the test environment, testers, and test projects before the entire test starts, and summarize the results to generate a report after the test is completed. The function decorated with @pytest.hookimpl is similar to a callback function, which is used to obtain the execution results of the test case at different stages (such as setup, call, and teardown), and fill these execution results into the test report. In addition, when generating a visual test report, the fields of the test case results in the report can also be customized and optimized according to the object being tested. That is, the format of the visual test report corresponding to different objects being tested can be different.
[0066] After each test script is executed, the pytest framework automatically collects the corresponding test results and return values, and the computer device calls the test report generation component to generate a visual test report based on the automatically collected information. The report content can include summary information (such as report name, total number of test case success / failure / skip / errors, start time, end time, tester information, etc.) and detailed information for each test case execution (such as case ID, case name, case result, etc.).
[0067] Furthermore, in the test scenario of the data sharing and exchange platform, the test case sets corresponding to each functional component in the data sharing and exchange platform are obtained from the test case table, and the corresponding functional components are tested respectively based on the test cases in the respective test case sets to obtain the test pass status of each functional component, thereby determining the test pass status of the data sharing and exchange platform based on the test pass status of each functional component.
[0068] In a possible application scenario, the data sharing and exchange platform may be a government data sharing and exchange platform. Through the data sharing and exchange platform testing method provided in the embodiment of the present application, it is possible to test each functional component in the government data sharing and exchange platform.
[0069] In summary, the testing method of the data sharing and exchange platform provided in the embodiment of the present application pre-sets various test cases corresponding to the tested object. When the functional component in the data sharing and exchange platform has a test requirement as the tested object, the target test case corresponding to the tested object in the test case table is obtained, and the test environment is constructed based on the test environment topology identifier associated with the target test case and the test environment configuration data in the target test case to obtain the test environment corresponding to the target test case; an automated test script is generated based on the test step data of the target test case, and the automated test script is run in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case; through the above method, the test environment deployment and test step execution can be driven by the test case. In the scenario of accessing massive systems and data, the test case written based on the fixed template can be used as the support for automated testing, and there is no need to develop additional test scripts, thereby reducing the development and maintenance costs of automated testing and improving testing efficiency; in addition, by automating the test process, the configuration content of the tester during the test process can be reduced, thereby reducing the test errors caused by human configuration parameter errors and improving the test accuracy.
[0070] Figure 3 A schematic diagram showing a test process of a data sharing exchange platform provided by an exemplary embodiment of the present application is shown in FIG. Figure 3 As shown, the testing process of the data sharing and exchange platform includes four stages: test case analysis 310 , test environment deployment 320 , test execution 330 , and test result analysis 340 .
[0071] In the test case analysis phase, the computer device obtains the test case corresponding to the tested object, reads and analyzes the test case, and obtains the test step data and the test environment configuration data in the test case.
[0072] The test environment deployment phase includes platform automatic configuration and simulation test service automatic configuration to complete the construction of the test environment. The configuration items of platform automatic configuration include metadata configuration, data source configuration and resource management configuration. The simulation test service automatic configuration can be divided into interface base data configuration, file system base data configuration and library table base data configuration based on the different objects being tested.
[0073] During the test execution phase, an automated test script is generated based on the test step data, and the automated test components corresponding to the object under test are called in the constructed test environment to run the automated test script, thereby obtaining the test results of the object under test through the current test case.
[0074] After completing the test of the object under test based on the test cases corresponding to the object under test in the test case table, analyze and record the test results of each test case on the object under test. Furthermore, determine the test pass status of the object under test by combining the test results of each test case on the object under test and the simulation test service log, and generate a visual test report.
[0075] The execution process of the above stages can be referred to as follows: Figure 1 or Figure 2 The relevant contents of the illustrated embodiment will not be repeated here.
[0076] Figure 4 A block diagram of a test device for a data sharing exchange platform provided by an exemplary embodiment of the present application is shown. The device can be used in a computer device to perform the following steps: Figure 1 or Figure 2 All or part of the steps of the embodiment, such as Figure 4 As shown, the device comprises: The use case acquisition module 410 is used to acquire a target test case corresponding to the tested object in the test case table, wherein the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in the target test case set contained in the test case table, wherein the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case includes pre-set test environment configuration data and test step data; An environment construction module 420 is used to construct a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case to obtain a test environment corresponding to the target test case; A script generation module 430, configured to generate an automated test script based on the test step data of the target test case; The testing module 440 is used to run the automated testing script in the testing environment corresponding to the target testing case to obtain the testing result of the tested object corresponding to the target testing case.
[0077] In a possible implementation, the functional components in the data sharing and exchange platform include an interface component, a file system component, and a library table component; each functional component type has a corresponding test case set; the case acquisition module is used to: Obtaining the functional component type of the object under test; The target test case corresponding to the object under test in the test case table is obtained based on the functional component type of the object under test.
[0078] In a possible implementation, the environment construction module includes: A file acquisition submodule, used to acquire a test environment topology class file associated with the test environment topology identifier; the test environment topology class file includes a configuration method of the test environment; The environment construction submodule is used to construct the test environment based on the test environment topology class file and the test environment configuration data of the target test case to obtain the test environment corresponding to the target test case.
[0079] In a possible implementation, the test environment includes a data sharing and exchange platform and a simulation test service; the simulation test service is used to simulate the base data corresponding to the object under test; The environment construction submodule is used to configure the data sharing exchange platform based on the first configuration mode of the data sharing exchange platform indicated by the test environment topology class file and the test environment configuration data; and The simulation test service is configured based on the second configuration mode of the simulation test service indicated by the test environment topology class file and the test environment configuration data.
[0080] In a possible implementation, the test case also includes an expected test result, and the device further includes: A comparison module, used to compare the test results of each test case with the corresponding expected test results to obtain a comparison result of each test case; The pass status determination module is used to comprehensively determine the test pass status of the tested object based on the comparison results of each test case.
[0081] In a possible implementation manner, the device further includes: The report generation module is used to generate a visual test report of the tested object based on the comparison results of each test case and the test pass status.
[0082] In summary, the test device of the data sharing and exchange platform provided in the embodiment of the present application pre-sets various test cases corresponding to the tested object. When the functional component in the data sharing and exchange platform has a test requirement as the tested object, the target test case corresponding to the tested object in the test case table is obtained, and the test environment is constructed based on the test environment topology identifier associated with the target test case and the test environment configuration data in the target test case to obtain the test environment corresponding to the target test case; an automated test script is generated based on the test step data of the target test case, and the automated test script is run in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case; through the above-mentioned device, the test environment deployment and test step execution can be driven by the test case. In the scenario of accessing massive systems and data, the test case written based on the fixed template can be used as the support for automated testing, and there is no need to develop additional test scripts, thereby reducing the development and maintenance costs of automated testing and improving testing efficiency; in addition, by automating the test process, the configuration content of the tester during the test process can be reduced, thereby reducing the test errors caused by human configuration parameter errors and improving the test accuracy.
[0083] Figure 5 The structural block diagram of a computer device 500 shown in an exemplary embodiment of the present application is shown. The computer device can be implemented as the server in the above-mentioned solution of the present application. The computer device 500 includes a central processing unit (CPU) 501, a system memory 504 including a random access memory (RAM) 502 and a read-only memory (ROM) 503, and a system bus 505 connecting the system memory 504 and the central processing unit 501. The computer device 500 also includes a large-capacity storage device 506 for storing an operating system 509, an application program 510 and other program modules 511.
[0084] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented by any method or technology for storing information such as computer-readable instructions, data structures, program modules or other data. Computer storage media include RAM, ROM, Erasable Programmable Read Only Memory (EPROM), Electronically-Erasable Programmable Read-Only Memory (EEPROM) flash memory or other solid-state storage technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, tape cassettes, tapes, disk storage or other magnetic storage devices. Of course, those skilled in the art will know that the computer storage medium is not limited to the above. The above-mentioned system memory 504 and mass storage device 506 can be collectively referred to as memory.
[0085] According to various embodiments of the present disclosure, the computer device 500 can also be connected to a remote computer on the network through a network such as the Internet. That is, the computer device 500 can be connected to the network 508 through the network interface unit 507 connected to the system bus 505, or the network interface unit 507 can be used to connect to other types of networks or remote computer systems (not shown).
[0086] The memory also includes at least one instruction, at least one program, code set or instruction set, and the at least one instruction, at least one program, code set or instruction set is stored in the memory. The central processing unit 501 implements all or part of the steps in the test method of the data sharing and exchange platform shown in the above-mentioned embodiments by executing the at least one instruction, at least one program, code set or instruction set.
[0087] Figure 6 The following is a block diagram of a computer device 600 according to an exemplary embodiment of the present application. The computer device 600 may be implemented as the above-mentioned terminal device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, etc. The computer device 600 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal, etc.
[0088] Typically, the computer device 600 includes a processor 601 and a memory 602 .
[0089] In some embodiments, the computer device 600 may further optionally include: a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602 and the peripheral device interface 603 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 603 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a radio frequency circuit 604, a display screen 605, a camera assembly 606, an audio circuit 607 and a power supply 608.
[0090] In some embodiments, the computer device 600 further includes one or more sensors 609 , including but not limited to: an acceleration sensor 610 , a gyroscope sensor 611 , a pressure sensor 612 , an optical sensor 613 , and a proximity sensor 614 .
[0091] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the computer device 600, and the computer device 600 may include more or less components than shown in the figure, or combine some components, or adopt a different arrangement of components.
[0092] In an exemplary embodiment, a computer-readable storage medium is also provided, in which at least one computer program is stored, and the computer program is loaded and executed by a processor to implement the above-mentioned test method of the data sharing exchange platform, and / or all or part of the steps in the test method of the data sharing exchange platform. For example, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.
[0093] In an exemplary embodiment, a computer program product is also provided, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer is executed to implement the above Figure 1 or Figure 2 All or part of the steps of the method for testing the data sharing and exchange platform shown in the embodiment.
[0094] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the claims.
[0095] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A testing method for a data sharing and exchange platform, characterized in that: The method comprises: Obtain a target test case corresponding to the tested object in the test case table, wherein the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in a target test case set contained in the test case table, and the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case includes pre-set test environment configuration data and test step data; Constructing a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case to obtain a test environment corresponding to the target test case; Generate an automated test script based on the test step data of the target test case; In the test environment corresponding to the target test case, the automated test script is run to obtain the test result of the tested object corresponding to the target test case.
2. The method according to claim 1, characterized in that The functional components in the data sharing and exchange platform include interface components, file system components and library table components; each functional component type has a corresponding test case set; The step of obtaining the target test case in the test case table corresponding to the tested object includes: Obtaining the functional component type of the object under test; The target test case corresponding to the object under test in the test case table is obtained based on the functional component type of the object under test.
3. The method according to claim 1, characterized in that The step of constructing a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case to obtain a test environment corresponding to the target test case includes: Obtaining a test environment topology class file associated with the test environment topology identifier; the test environment topology class file includes a configuration method of the test environment; The test environment is constructed based on the test environment topology class file and the test environment configuration data of the target test case to obtain the test environment corresponding to the target test case.
4. The method according to claim 3, characterized in that: The test environment includes a data sharing and exchange platform and a simulation test service; the simulation test service is used to simulate the base data of the corresponding tested object; The step of constructing a test environment based on the test environment topology file and the test environment configuration data of the target test case to obtain a test environment corresponding to the target test case includes: Configure the data sharing exchange platform based on the first configuration mode of the data sharing exchange platform indicated by the test environment topology file and the test environment configuration data; and The simulation test service is configured based on the second configuration mode of the simulation test service indicated by the test environment topology class file and the test environment configuration data.
5. The method according to claim 1, characterized in that The test case also includes an expected test result, and the method further includes: Comparing the test results of each test case with the corresponding expected test results to obtain comparison results of each test case; The test pass status of the tested object is comprehensively determined based on the comparison results of each test case.
6. The method according to claim 1, characterized in that The method further comprises: A visual test report of the tested object is generated based on the comparison results of each test case and the test pass status.
7. A test device for a data sharing and exchange platform, characterized in that: The device comprises: A case acquisition module is used to acquire a target test case corresponding to a tested object in a test case table, wherein the tested object is a functional component in the data sharing and exchange platform; the target test case is any test case in a target test case set contained in the test case table, wherein the target test case set is a set of test cases corresponding to the tested object in the test case table; the test case includes pre-set test environment configuration data and test step data; An environment construction module, used to construct a test environment based on the test environment topology identifier associated with the target test case and the test environment configuration data of the target test case, to obtain a test environment corresponding to the target test case; A script generation module, used to generate an automated test script based on the test step data of the target test case; The test module is used to run the automated test script in the test environment corresponding to the target test case to obtain the test result of the tested object corresponding to the target test case.
8. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the testing method of the data sharing and exchange platform as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the computer program is loaded and executed by a processor to implement the testing method of the data sharing and exchange platform as described in any one of claims 1 to 6.
10. A computer program product, characterized in that The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer device, the computer device is caused to execute to implement a testing method for a data sharing and exchange platform as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Software testing method and device and computer readable storage medium
CN110874318A
System and method for testing network equipment
CN112671604A
Accurate test method and device, computer equipment and storage medium
CN113342685A
Automatic testing method and device for data processor and medium
CN115904852A
Automatic testing method for variable networking and related device
CN116719722A
Cited By
Automatic testing method and device, storage medium and electronic equipment
CN121664717A