A unit testing method and device
Through unit testing common components and simulated interfaces, the problem that unit tests rely on external interfaces and services in the existing technology is solved, and unit testing is completed within local resources to ensure the consistency of test results and data sharing.
Patent Information
- Application Number
- CN202110144226.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-02
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2041-02-02
AI Technical Summary
Existing unit testing methods rely too much on external interfaces and services, resulting in unstable testing environments and poor isolation of shared data, resulting in inconsistent test results and even inability to perform unit testing.
By providing a unit testing method and device, using unit testing common components, referring to test base classes or annotating external interfaces, loading all services or mock interfaces associated with the test base classes, converting unit test instructions for remote services into unit test instructions for local services, and obtaining dependent data from local services to perform unit tests.
It realizes isolation of external dependencies and only completes unit tests through local resources. Users do not need to care about the deployment environment and test data preparation. They can execute in any environment, and the multiple execution results are consistent, realizing data sharing.
Smart Images

Figure CN113760733B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a unit testing method and device. Background Art
[0002] Under normal circumstances, existing unit tests require the construction of a complete test environment before they can be implemented, including: test data and interfaces of other dependent business services, dependent public basic services (database, cache service, mail service, etc.) and public test data.
[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:
[0004] 1. Over-reliance on external interfaces and services requires cooperation from multiple parties, which is time-consuming, labor-intensive, costly, and inefficient. There are consistency issues between data from different external services, which makes subsequent processing difficult, and the data quality may not meet actual needs.
[0005] 2. When multiple tests need to use the same data, due to the instability of the test environment and the poor isolation of shared data, the results of different tests may be different, and even unit tests may not be able to be executed. Summary of the invention
[0006] In view of this, an embodiment of the present invention provides a unit testing method and device, which can at least solve the problem that the prior art is too dependent on external service interfaces and has poor isolation of shared data.
[0007] To achieve the above object, according to one aspect of an embodiment of the present invention, a unit testing method is provided, comprising:
[0008] In response to a start operation on a unit test common component, a test base class is referenced or an external interface is annotated;
[0009] Loading all services associated with the test base class or simulation interfaces corresponding to the external interface to convert unit test instructions for calling remote services into unit test instructions for calling local services;
[0010] When a unit test instruction for a remote service is received, dependency data corresponding to the remote service is obtained from the local service to perform a unit test operation based on the dependency data to obtain a test result.
[0011] Optionally, all the services include local database services;
[0012] The reference test base class includes:
[0013] Through the local database management program, call the third-party plug-in to create and start a local database locally;
[0014] Create a database connection pool in the unit test common component and connect to the local database;
[0015] Obtaining a database link from the database connection pool through the service of the unit test common component to establish a communication link between the database test framework and the local database;
[0016] The database test framework is initialized and encapsulated as a first test base class.
[0017] Optionally, all the services include local ES services;
[0018] The reference test base class includes:
[0019] Through the local public service program, call the third-party plug-in to create and start an ES local service locally;
[0020] Load an ES client instance through the annotation program and connect to the ES local service;
[0021] The ES local service is initialized and encapsulated as a second test base class.
[0022] Optionally, the marking of the external interface includes:
[0023] Annotate the external interface by annotation, and scan the annotated external interface to replace the external interface with a simulated interface without return value;
[0024] The loading of the analog interface corresponding to the external interface comprises:
[0025] The written simulation program is loaded, and when a call request to the simulation interface is received, a simulation return value is generated.
[0026] To achieve the above object, according to another aspect of an embodiment of the present invention, a unit testing device is provided, comprising:
[0027] A startup module, used to respond to the startup operation of the unit test common component, reference the test base class or mark the external interface;
[0028] A conversion module, used to load all services associated with the test base class or simulation interfaces corresponding to the external interface, so as to convert a unit test instruction for calling a remote service into a unit test instruction for calling a local service;
[0029] The test module is used to obtain dependency data corresponding to a remote service from a local service when receiving a unit test instruction for the remote service, so as to perform a unit test operation based on the dependency data and obtain a test result.
[0030] Optionally, all the services include local database services;
[0031] The startup module is used to:
[0032] Through the local database management program, call the third-party plug-in to create and start a local database locally;
[0033] Create a database connection pool in the unit test common component and connect to the local database;
[0034] Obtaining a database link from the database connection pool through the service of the unit test common component to establish a communication link between the database test framework and the local database;
[0035] The database test framework is initialized and encapsulated as a first test base class.
[0036] Optionally, all the services include local ES services;
[0037] The startup module is used to:
[0038] Through the local public service program, call the third-party plug-in to create and start an ES local service locally;
[0039] Load an ES client instance through the annotation program and connect to the ES local service;
[0040] The ES local service is initialized and encapsulated as a second test base class.
[0041] Optionally, the startup module is used to:
[0042] Annotate the external interface by annotation, and scan the annotated external interface to replace the external interface with a simulated interface without return value;
[0043] The conversion module is used for:
[0044] The written simulation program is loaded, and when a call request to the simulation interface is received, a simulation return value is generated.
[0045] To achieve the above objective, according to another aspect of an embodiment of the present invention, a unit test electronic device is provided.
[0046] The electronic device of the embodiment of the present invention includes: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement any of the unit testing methods described above.
[0047] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned unit testing methods is implemented.
[0048] According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: it provides a unit testing common component that isolates external dependencies and completes unit testing only through local resources. Users do not need to worry about the program deployment environment and the preparation of test data, and can use local resources to complete closed-loop unit testing. It can be executed in any deployment environment, and the results of multiple executions are consistent, thereby realizing data sharing.
[0049] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0051] Figure 1 is a schematic diagram of the main flow of a unit testing method according to an embodiment of the present invention;
[0052] Figure 2 It is the schematic diagram of the common components of the unit test;
[0053] Figure 3 is a schematic diagram of main modules of a unit testing device according to an embodiment of the present invention;
[0054] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0055] Figure 5 It is a schematic diagram of the structure of a computer system of a mobile device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0057] See also Figure 1 , which shows a main flow chart of a unit testing method provided by an embodiment of the present invention, comprising the following steps:
[0058] S101: In response to a start operation on a unit test common component, reference a test base class or annotate an external interface;
[0059] S102: Load all services associated with the test base class or simulation interfaces corresponding to the external interface to convert a unit test instruction that calls a remote service into a unit test instruction that calls a local service;
[0060] S103: upon receiving a unit test instruction for a remote service, obtaining dependency data corresponding to the remote service from a local service, so as to perform a unit test operation based on the dependency data and obtain a test result.
[0061] In the above implementation, for steps S101 and S102, this solution abstracts the common components of unit testing to isolate external dependent services and data. Figure 2 As shown, users only need to reference the common components of unit testing and obtain all external dependency capabilities by inheriting the common parent class. They can complete the writing of unit tests by adding configuration files and writing mock objects.
[0062] The public test parent class references the public startup configuration. Users only need to inherit the public test parent class to write unit tests without worrying about configuration details.
[0063] BaseTest is the basic test base class, providing basic testing capabilities. BaseTestNoDepend is an external service API that does not contain dependencies, providing basic local program testing capabilities, based on which various transformations can be performed. For example:
[0064] 1) BaseTestNoDependDb does not contain dependent external service APIs, but includes local database services, providing enhanced local program testing capabilities. Users can quickly perform unit testing by inheriting this class, such as TestApplicationNoDependDb.
[0065] 2) BaseTestNoDependDbEs does not contain dependent external service APIs, but includes the local database and local ES services, providing enhanced local program testing capabilities. Users can quickly perform unit testing by inheriting this class, such as TestApplicationNoDependDbEs.
[0066] This solution is divided into three instances, one uses the DbUnit+MariaDB4j third-party framework to simulate the remote test database, one uses the embedded-elasticsearch third-party framework to simulate the test environment ES, and the other uses the Mockito third-party framework to simulate the remote external interface call. All three are referenced or annotated when the unit test common component is started. The following are the specific instructions:
[0067] Example 1: Using DbUnit+MariaDB4j third-party framework to simulate remote test database
[0068] 1. Use the LocalDbManager.startLocalDb() local database manager to call a third-party plug-in to create and start a local MariaDB database locally. The third-party plug-in can be MariaDB4j. MariaDB database is a branch of MySQL and provides full support for MySQL syntax, so it has better compatibility than in-memory databases. By using MariaDB4j, you can quickly build a database environment similar to local MySQL.
[0069] 2. Inject a DataSource instance into the spring container (i.e., the unit test common component) through the @Bean annotation program. This instance is a database connection pool object and depends on the local MariaDB database created in the previous step.
[0070] 3. Through the @Bean annotation program, an IDatabaseConnection instance is injected into the spring container. This instance is used by the DbUnit framework to interact with the database and depends on (uses the relationship) the DataSource instance created in the previous step. Among them, DbUnit is a database testing framework that uses user-defined data sets to put the database in a certain state, thereby ensuring the effectiveness of unit testing.
[0071] 4. Complete the initialization process of the DbUnit framework by writing a program and encapsulate it into the first test base class BaseTestNoDependDb.
[0072] When users use it later, they can save the table creation statement to the table creation statement folder under the local test folder, such as test / resources / mysql / schema, to complete the automatic creation of the data table. You can also save the data file to the data folder under the local test folder, such as test / resources / mysql / data, and load it through the @DatabaseSetup annotation on the unit test class to complete all preparations before the unit test. In subsequent tests, you can extract data from the local table creation statement folder / data folder, and perform data layer unit testing or integration testing just like connecting to a remote test database. The data in the shared test database can be modified at will, and it cannot provide a stable and long-term data source for unit testing.
[0073] Example 2: Using the embedded-elasticsearch third-party framework to simulate the test environment ES
[0074] 1. Through LocalEsManager.startLocalEs() local ES public service program, call the third-party plug-in to create and start a local ES service locally; the third-party plug-in can be MariaDB4j.
[0075] 2. Through the @Bean annotation program, inject an ES client Client instance into the spring container (that is, the unit test common component). This instance depends on the local ES service created in the previous step, and the two are connected.
[0076] 3. Complete the initialization of the local ES service by writing a program and encapsulate it into the second test base class BaseTestNoDependDbEs.
[0077] When users use it later, they can save the index file in the table creation statement folder under the local test folder, such as the test / resources / es / index directory, and save the data file in the data folder under the local test folder, such as the test / resources / es / data directory, and load the data by calling the test base class method to complete all preparations before unit testing. In subsequent tests, data can be extracted from the local table creation statement folder / data folder, and data layer unit tests or integration tests can be performed just like connecting to a remote ES. The entire implementation process can quickly build a local ES environment, and the startup program written based on embedded-elasticsearch can automatically create indexes and insert test data.
[0078] Example 3: Use the Mockito third-party framework to simulate remote external interface calls, encapsulate and abstract the extension points provided by the Mockito framework, expose the BaseMock base class to users, and hide the implementation details
[0079] 1. Annotate external interfaces using @Bean annotation;
[0080] 2. When the unit test common component is started, the marked external interfaces are scanned to replace the external interfaces with simulated interfaces. At this time, the simulated interfaces do not have return values;
[0081] 3. The unit test public component service loads the simulation program written by the user, calls the simulation interface, and obtains the simulation return value;
[0082] 4. When the unit test instruction calls the external interface, it will automatically return the simulation data.
[0083] Subsequent users can complete interface behavior simulation by inheriting the BaseMock base class and defining the external interface behavior that needs to be simulated. Using this simulation object in unit testing can simulate real remote interface calls through local calls. The entire implementation process Mockito framework provides comprehensive interface behavior simulation extensions with good scalability.
[0084] For step S103, through the above operation, when a unit test instruction of any remote service is subsequently received, the dependent data corresponding to the remote service can be obtained from the local service, such as the data in the local table creation statement folder / data folder. The unit test operation of the remote service is performed based on the extracted dependent data to obtain the final test result.
[0085] The following is a specific example to describe the implementation process of this solution:
[0086] Existing technology: User A's financial data is obtained from system X and user A's personal information is obtained from system Y. Only after obtaining these data can the credit rating of user A be determined. Before launching this requirement, the staff needs to verify whether the program runs correctly.
[0087] This solution: There is no need to obtain real data from system X and system Y. Test data can be directly simulated in the local test environment to reduce the dependence on the external interface to provide the test environment. The credit rating business logic test can be completed in the test environment, which saves time and effort overall.
[0088] The method provided in the above embodiment provides a unit testing common component that isolates external dependencies and completes unit testing only through local resources (the test environment built by the staff and the simulated test data). Users do not need to worry about the program deployment environment and the preparation of test data, and can use local resources to complete closed-loop (i.e., full-process testing, there is no situation where testing cannot be done) unit testing work, and it can be executed in any deployment environment, and the results of multiple executions are consistent, thereby realizing data sharing.
[0089] See also Figure 3 , shows a schematic diagram of main modules of a unit testing device 300 provided in an embodiment of the present invention, including:
[0090] A startup module 301, used to reference a test base class or mark an external interface in response to a startup operation on a unit test common component;
[0091] A conversion module 302, used to load all services associated with the test base class or simulation interfaces corresponding to the external interface, so as to convert a unit test instruction for calling a remote service into a unit test instruction for calling a local service;
[0092] The testing module 303 is used to, upon receiving a unit test instruction for a remote service, obtain dependency data corresponding to the remote service from the local service, so as to perform a unit test operation based on the dependency data and obtain a test result.
[0093] In the implementation device of the present invention, all the services include local database services;
[0094] The startup module 301 is used to:
[0095] Through the local database management program, call the third-party plug-in to create and start a local database locally;
[0096] Create a database connection pool in the unit test common component and connect to the local database;
[0097] Obtaining a database link from the database connection pool through the service of the unit test common component to establish a communication link between the database test framework and the local database;
[0098] The database test framework is initialized and encapsulated as a first test base class.
[0099] In the implementation device of the present invention, all services include local ES services;
[0100] The startup module 301 is used to:
[0101] Through the local public service program, call the third-party plug-in to create and start an ES local service locally;
[0102] Load an ES client instance through the annotation program and connect to the ES local service;
[0103] The ES local service is initialized and encapsulated as a second test base class.
[0104] In the implementation device of the present invention, the startup module 301 is used to: mark the external interface by annotation, scan the marked external interface, and replace the external interface with a simulation interface without return value;
[0105] The conversion module 302 is used to load the written simulation program and generate a simulation return value when receiving a call request to the simulation interface.
[0106] In addition, the specific implementation content of the device described in the embodiment of the present invention has been described in detail in the method described above, so the repeated content will not be described again here.
[0107] Figure 4 An exemplary system architecture 400 is shown in which embodiments of the present invention may be applied.
[0108] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405 (just an example). Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0109] The user can use the terminal devices 401, 402, 403 to interact with the server 405 through the network 404 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 401, 402, 403.
[0110] The terminal devices 401 , 402 , and 403 may be various electronic devices having display screens and supporting web browsing, and the server 405 may be a server providing various services.
[0111] It should be noted that the method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the device is generally set in the server 405 .
[0112] It should be understood that Figure 4 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0113] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system 500 of a terminal device suitable for implementing an embodiment of the present invention. Figure 5 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0114] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0115] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0116] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0117] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media 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 or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0118] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0119] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a startup module, a conversion module, and a test module. The names of these modules do not constitute a limitation on the modules themselves in some cases. For example, a test module may also be described as a "unit test module".
[0120] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes:
[0121] In response to a start operation on a unit test common component, a test base class is referenced or an external interface is annotated;
[0122] Loading all services associated with the test base class or simulation interfaces corresponding to the external interface to convert unit test instructions for calling remote services into unit test instructions for calling local services;
[0123] When a unit test instruction for a remote service is received, dependency data corresponding to the remote service is obtained from the local service to perform a unit test operation based on the dependency data to obtain a test result.
[0124] According to the technical solution of the embodiments of the present invention, a unit testing common component is provided which isolates external dependencies and completes unit testing only through local resources. Users do not need to worry about the program deployment environment and the preparation of test data, and can use local resources to complete closed-loop unit testing. It can be executed in any deployment environment, and the results of multiple executions are consistent, thereby realizing data sharing.
[0125] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A unit testing method, characterized in that: include: In response to the start operation of the unit test common component, the test base class is referenced or the external interface is marked; wherein the marking of the external interface includes: marking the external interface by annotation, scanning the marked external interface to replace the external interface with a simulation interface without return value; Loading all services associated with the test base class or the simulation interface corresponding to the external interface to convert the unit test instruction of calling the remote service into the unit test instruction of calling the local service; wherein all services include one or more of the local database service and the local ES service; the loading of the simulation interface corresponding to the external interface includes: loading the written simulation program, and generating a simulation return value when receiving a call request to the simulation interface; When a unit test instruction for a remote service is received, dependency data corresponding to the remote service is obtained from the local service to perform a unit test operation based on the dependency data to obtain a test result.
2. The method according to claim 1, characterized in that All of the services mentioned include local database services; The reference test base class includes: Through the local database management program, call the third-party plug-in to create and start a local database locally; Create a database connection pool in the unit test common component and connect to the local database; Obtaining a database link from the database connection pool through the service of the unit test common component to establish a communication link between the database test framework and the local database; The database test framework is initialized and encapsulated as a first test base class.
3. The method according to claim 1, characterized in that All the services mentioned include local ES services; The reference test base class includes: Through the local public service program, call the third-party plug-in to create and start an ES local service locally; Load an ES client instance through the annotation program and connect to the ES local service; The ES local service is initialized and encapsulated as a second test base class.
4. A unit testing device, characterized in that: include: A startup module, used for referencing a test base class or marking an external interface in response to a startup operation on a unit test common component; wherein the marking of the external interface comprises: marking the external interface by annotation, scanning the marked external interface, and replacing the external interface with a simulation interface without a return value; A conversion module is used to load all services associated with the test base class or the simulation interface corresponding to the external interface, so as to convert the unit test instruction of calling the remote service into the unit test instruction of calling the local service; wherein all services include one or more of the local database service and the local ES service; the loading of the simulation interface corresponding to the external interface includes: loading the written simulation program, and generating a simulation return value when receiving a call request to the simulation interface; The test module is used to obtain dependency data corresponding to a remote service from a local service when receiving a unit test instruction for the remote service, so as to perform a unit test operation based on the dependency data and obtain a test result.
5. The device according to claim 4, characterized in that All of the services mentioned include local database services; The startup module is used to: Through the local database management program, call the third-party plug-in to create and start a local database locally; Create a database connection pool in the unit test common component and connect to the local database; Obtaining a database link from the database connection pool through the service of the unit test common component to establish a communication link between the database test framework and the local database; The database test framework is initialized and encapsulated as a first test base class.
6. The device according to claim 4, characterized in that All the services mentioned include local ES services; The startup module is used to: Through the local public service program, call the third-party plug-in to create and start an ES local service locally; Load an ES client instance through the annotation program and connect to the ES local service; The ES local service is initialized and encapsulated as a second test base class.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 3.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Interface testing method and device
CN102096631A
Application service platform system and implementation method thereof
CN103283209A