Unit test method and device, electronic equipment and storage medium

CN114416552BActive Publication Date: 2026-10-23INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210051438.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-17
Publication Date
2026-10-23
Estimated Expiration
2042-01-17

AI Technical Summary

Technical Problem

[0003]在实现本公开发明构思的过程中,发明人发现相关技术中至少存在以下问题:相关技术的单元测试方法对公共数据库的依赖性较强,当测试用例所依赖的数据库数据被修改或删除时,容易出现单元测试无法通过的情况

Benefits of technology

[0045]根据本公开的实施例,通过接收包括待执行的测试用例的标识信息的测试任务,根据来自数据仓库系统中的测试热点数据生成与测试用例的标识信息对应的内存数据库;然后在测试热点数据中包括与测试用例对应的测试基础数据的情况下,根据测试用例和测试基础数据执行测试任务,得到测试结果;之后向数据仓库系统发送测试结果,以便数据仓库系统根据测试结果更新数据仓库系统中的测试热点数据,保证数据仓库系统中的测试热点数据和内存数据库中的测试热点数据保持一致。本公开提供的技术方案在内存数据库中存储测试热点数据,利用内存数据库中的热点数据执行测试用例,降低了对数据仓库系统的依赖性,当测试用例所依赖的数据仓库系统中的数据被修改或删除时,不会影响影响单元测试的正常进行。因此,本公开的技术方案至少部分解决了相关技术中单元测试方法对数据仓库系统依赖性较强的技术问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416552B_ABST
    Figure CN114416552B_ABST
Patent Text Reader

Abstract

The present disclosure provides a unit test method, which can be applied to the financial field or other fields. The unit test method comprises: receiving a test task, wherein the test task comprises identification information of a test case to be executed; generating a memory database corresponding to the identification information of the test case according to test hotspot data from a data warehouse system; in the case that the test hotspot data comprises test basic data corresponding to the test case, executing the test task according to the test case and the test basic data to obtain a test result; and sending the test result to the data warehouse system, so that the data warehouse system updates the test hotspot data in the data warehouse system according to the test result. The present disclosure also provides a unit test device, equipment and storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Unit testing is a targeted, comprehensive, and thorough systematic test performed on each module of software. Unit testing is crucial for discovering program vulnerabilities early in development and for improving program stability. In related technologies, unit testing methods using database statements such as `sal` require the use of test data from a public data warehouse to execute unit tests.

[0003] In the process of realizing the inventive concept disclosed herein, the inventors discovered that the related technologies have at least the following problems: the unit testing methods of the related technologies are highly dependent on public databases, and when the database data on which the test cases depend is modified or deleted, the unit tests are prone to fail. Summary of the Invention

[0004] In view of the above problems, this disclosure provides a unit testing method, apparatus, device, medium and program product.

[0005] According to a first aspect of this disclosure, a unit testing method is provided, comprising:

[0006] Receive test tasks, wherein the test tasks include identification information of test cases to be executed;

[0007] An in-memory database corresponding to the identification information of the above test cases is generated based on test hotspot data from the data warehouse system;

[0008] If the aforementioned test hotspot data includes test base data corresponding to the aforementioned test cases, then the aforementioned test tasks are executed based on the aforementioned test cases and the aforementioned test base data to obtain test results; and

[0009] The test results are sent to the aforementioned data warehouse system so that the data warehouse system can update the test hotspot data in the aforementioned data warehouse system based on the test results.

[0010] According to an embodiment of this disclosure, the above-mentioned test task includes M test subtasks, each of which corresponds to a test case, wherein M≥2;

[0011] The aforementioned in-memory database, generated based on test hotspot data from the data warehouse system and corresponding to the identification information of the aforementioned test cases, includes:

[0012] For each of the above M test subtasks, generate the above in-memory database corresponding to the above test subtask based on the test hotspot data from the above data warehouse system;

[0013] Where the aforementioned test hotspot data includes test base data corresponding to the aforementioned test cases, the aforementioned test tasks are executed based on the aforementioned test cases and the aforementioned test base data, and the test results obtained include:

[0014] For each of the above M test subtasks, if the above test hotspot data includes the test base data corresponding to the above test subtask, the above test subtask is executed according to the above test cases and the above test base data corresponding to the above test subtask, and the test results corresponding to the above test subtask are obtained.

[0015] Specifically, sending the test results to the data warehouse system so that the data warehouse system can update the test hotspot data based on the test results includes:

[0016] Send the M test results obtained from executing the M test sub-tasks to the data warehouse system so that the data warehouse system can update the test hotspot data in the data warehouse system according to the M test results and preset calculation rules.

[0017] According to embodiments of this disclosure, the unit testing method further includes:

[0018] Query the test results in the data warehouse system corresponding to the test tasks mentioned above to obtain the first query result;

[0019] For each of the M memory databases, query the test results in the memory database corresponding to the test subtasks to obtain the second query result;

[0020] The first query result is compared with the second query result to obtain the comparison result;

[0021] If the comparison results indicate that the first query result and the second query result meet the preset conditions, the test hotspot data in the memory database is updated using the first query result.

[0022] According to embodiments of this disclosure, the generation of an in-memory database corresponding to the identification information of the test cases based on test hotspot data from the data warehouse system includes:

[0023] Generate the aforementioned in-memory database corresponding to the identification information of the aforementioned test cases;

[0024] Using a pre-configured configuration file, an empty table of basic data is generated in the aforementioned in-memory database;

[0025] Obtain the aforementioned test hotspot data from the data warehouse system;

[0026] The aforementioned test hotspot data is stored in the aforementioned empty basic data table in the aforementioned memory database.

[0027] According to embodiments of this disclosure, the unit testing method further includes:

[0028] Generate an initialization table file based on preset fields;

[0029] Generate a sample data file corresponding to the preset fields mentioned above;

[0030] The above configuration file is generated based on the above initialization table file and the above example data file.

[0031] According to embodiments of this disclosure, generating an empty basic data table in the memory database using a pre-set configuration file includes:

[0032] An initialization table is generated in the memory database based on the initialization table file described above.

[0033] The example data from the above example data file is stored in the above initialization table to obtain the above basic data empty table.

[0034] According to embodiments of this disclosure, the aforementioned test hotspot data includes basic test data in the aforementioned data warehouse system whose call frequency meets preset values.

[0035] According to embodiments of this disclosure, the unit testing method further includes:

[0036] If the test hotspot data does not include the test base data corresponding to the test cases mentioned above, obtain the test base data corresponding to the test cases mentioned above from the data warehouse system mentioned above.

[0037] A second aspect of this disclosure provides a unit test apparatus, comprising:

[0038] The receiving module is used to receive test tasks, wherein the test tasks include identification information of test cases to be executed;

[0039] The first generation module is used to generate an in-memory database corresponding to the identification information of the above test cases based on the test hotspot data from the data warehouse system.

[0040] The execution module is used to execute the test tasks and obtain test results based on the test cases and the test base data, provided that the test hotspot data includes test base data corresponding to the test cases.

[0041] The sending module is used to send the test results to the data warehouse system so that the data warehouse system can update the test hotspot data in the data warehouse system based on the test results.

[0042] A third aspect of this disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors perform the unit test method described above.

[0043] A fourth aspect of this disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the unit test method described above.

[0044] The fifth aspect of this disclosure also provides a computer program product, including a computer program that, when executed by a processor, implements the unit test method described above.

[0045] According to embodiments of this disclosure, a test task including identification information of test cases to be executed is received. An in-memory database corresponding to the identification information of the test cases is generated based on test hotspot data from a data warehouse system. Then, with the test hotspot data including test base data corresponding to the test cases, the test task is executed based on the test cases and the test base data to obtain test results. The test results are then sent to the data warehouse system so that the data warehouse system updates its test hotspot data based on the test results, ensuring consistency between the test hotspot data in the data warehouse system and the test hotspot data in the in-memory database. The technical solution provided by this disclosure stores test hotspot data in an in-memory database and uses this data to execute test cases, reducing dependence on the data warehouse system. When data in the data warehouse system on which the test cases depend is modified or deleted, it will not affect the normal execution of unit tests. Therefore, the technical solution of this disclosure at least partially solves the technical problem of strong dependence on data warehouse systems in related technologies for unit testing methods. Attached Figure Description

[0046] The foregoing contents, as well as other objects, features, and advantages of this disclosure, will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0047] Figure 1The illustrations depict application scenarios of unit testing methods, apparatus, devices, media, and program products according to embodiments of the present disclosure.

[0048] Figure 2 A flowchart illustrating a unit testing method according to an embodiment of the present disclosure is shown schematically.

[0049] Figure 3 A flowchart illustrating a unit testing method according to another embodiment of this disclosure is shown schematically;

[0050] Figure 4 A flowchart illustrating a memory database update method according to an embodiment of the present disclosure is shown schematically;

[0051] Figure 5 A flowchart illustrating a unit testing method according to another embodiment of this disclosure is shown schematically;

[0052] Figure 6 A schematic block diagram of a unit testing apparatus according to an embodiment of the present disclosure is shown.

[0053] Figure 7 A schematic block diagram of a unit testing apparatus according to another embodiment of the present disclosure is shown; and

[0054] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a unit testing method according to an embodiment of the present disclosure. Detailed Implementation

[0055] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0056] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0057] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0058] When using expressions such as "at least one of A, B, and C", they should generally be interpreted in accordance with the meaning that is commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B, and C, etc.).

[0059] In the software development process, the test-driven development (TWD) paradigm has gradually gained acceptance and praise from software developers. Unit testing, a core component of TWD, involves targeted, comprehensive, and thorough systematic testing of each software module. Unit testing is crucial for identifying program vulnerabilities early in development and for improving program stability.

[0060] In related technologies, when writing unit tests for database statements such as SQL, all unit test statements rely on a common database, and the execution of unit tests is based on this common database. However, these technologies have at least the following problems: the unit testing methods of these technologies are highly dependent on the common database. When the data in the database on which the test cases depend is modified or deleted, or when the database does not exist in a new environment, the unit tests are prone to failing.

[0061] In view of this, this disclosure addresses the above-mentioned technical problems by automatically generating an in-memory database corresponding to the test cases based on test hotspot data from the data warehouse system upon receiving a test task. During testing, the test cases are executed using the test hotspot data in the in-memory database. After the test task is completed, the changed test hotspot data in the in-memory database is automatically synchronized to the data warehouse system to ensure the reliability of the test hotspot data. The technical solution provided by this disclosure stores test hotspot data in an in-memory database and executes test cases using the test hotspot data in the in-memory database. By using the in-memory database to simulate the data warehouse system environment, each unit test case uses a separate in-memory database for test execution, reducing the dependence on the data warehouse system and making it well applicable to scenarios with massive data and complex data models. Therefore, the technical solution of this disclosure at least partially solves the technical problem of the strong dependence of unit testing methods on data warehouse systems in related technologies.

[0062] Specifically, embodiments of this disclosure provide a unit testing method, comprising: receiving a test task, wherein the test task includes identification information of test cases to be executed; generating an in-memory database corresponding to the identification information of the test cases based on test hotspot data from a data warehouse system; if the test hotspot data includes test base data corresponding to the test cases, executing the test task based on the test cases and the test base data to obtain test results; and sending the test results to the data warehouse system so that the data warehouse system updates the test hotspot data in the data warehouse system based on the test results.

[0063] It should be noted that the unit testing method and apparatus provided in this disclosure can be used in the computer field or the financial field. The unit testing method and apparatus provided in this disclosure can also be used in any field other than the computer field and the financial field. The application fields of the unit testing method and apparatus provided in this disclosure are not limited.

[0064] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.

[0065] In the technical solution disclosed herein, the acquisition, collection, storage, use, processing, transmission, provision, disclosure, and application of data all comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and they do not violate public order and good morals.

[0066] Figure 1 The illustration schematically depicts application scenarios of unit testing methods, apparatus, devices, media, and program products according to embodiments of the present disclosure.

[0067] like Figure 1 As shown, application scenario 100 according to this embodiment may include a network, terminal devices, and a server. Network 104 serves as a medium for providing a communication link between terminal devices 101, 102, and 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.

[0068] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, and 103, such as testing applications, shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0069] Terminal devices 101, 102, and 103 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0070] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using terminal devices 101, 102, and 103 (for example only). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0071] It should be noted that the unit testing method provided in this disclosure embodiment can generally be executed by server 105. Correspondingly, the unit testing device provided in this disclosure embodiment can generally be located in server 105. The unit testing method provided in this disclosure embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the unit testing device provided in this disclosure embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Alternatively, the unit testing method provided in this disclosure embodiment can also be executed by terminal devices 101, 102, or 103, or by other terminal devices different from terminal devices 101, 102, or 103. Correspondingly, the unit testing device provided in this disclosure embodiment can also be located in terminal devices 101, 102, or 103, or in other terminal devices different from terminal devices 101, 102, or 103.

[0072] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0073] The following will be based on Figure 1 The described scene, through Figures 2-5 The unit testing method of the disclosed embodiments is described in detail.

[0074] Figure 2 A flowchart illustrating a unit testing method according to an embodiment of the present disclosure is shown schematically.

[0075] like Figure 2 As shown, the unit testing method of this embodiment includes operations S210 to S240, and the unit testing method can be executed by a server.

[0076] In operation S210, a test task is received, wherein the test task includes identification information of the test cases to be executed.

[0077] According to embodiments of this disclosure, the identification information of the test case to be executed may include information capable of identifying the test case to be executed. For example, the identification information of the test case to be executed may include the test case number, the test case name, etc.

[0078] According to embodiments of this disclosure, a test task may include one test case to be executed, or it may include multiple test cases to be executed. The specific number of test cases may be determined according to the specific test task. Embodiments of this disclosure do not limit the number of test cases to be executed included in a test task.

[0079] In operation S220, an in-memory database corresponding to the identification information of test cases is generated based on test hotspot data from the data warehouse system.

[0080] According to embodiments of this disclosure, a data warehouse system is a public database that stores basic test data, test cases, and other data. An in-memory database is a database that stores data in memory for direct manipulation.

[0081] According to embodiments of this disclosure, test hotspot data may include pre-determined test baseline data. For example, the pre-determined test baseline data may be tagged, and the tagged test baseline data may be stored in an in-memory database.

[0082] According to embodiments of this disclosure, the aforementioned test hotspot data includes basic test data in the aforementioned data warehouse system whose call frequency meets preset values.

[0083] According to embodiments of this disclosure, test hotspot data may include, for example, test base data from a data warehouse system that is called more than 1,000 times.

[0084] According to embodiments of this disclosure, test basic data that is called frequently in the data warehouse system and meets a preset value is stored in an in-memory database. When executing test tasks, the in-memory database can be called, which reduces the dependence on the data warehouse system.

[0085] When operating S230, if the test hotspot data includes test base data corresponding to the test cases, the test task is executed based on the test cases and test base data to obtain the test results.

[0086] According to embodiments of this disclosure, the unit testing method further includes: when the test hotspot data does not include the test base data corresponding to the test cases, obtaining the test base data corresponding to the test cases from the data warehouse system.

[0087] According to embodiments of this disclosure, when the in-memory database includes test base data for executing test cases, the test cases execute test tasks based on the test base data to obtain test results. When the in-memory database does not include test base data for executing test cases, the test base data corresponding to the test cases is obtained from the data warehouse system, and then the test tasks are executed based on the test base data to obtain test results.

[0088] According to embodiments of this disclosure, since the test hotspot data in this disclosure is test base data whose call frequency meets preset values, the test hotspot data includes commonly used test base data, and generally there is no need to obtain test base data from the data warehouse system. This helps to reduce dependence on the data warehouse system, reduce the number of calls to the data warehouse system, and improve system performance.

[0089] In operation S240, test results are sent to the data warehouse system so that the data warehouse system can update the test hotspot data in the data warehouse system based on the test results.

[0090] According to embodiments of this disclosure, test results from the in-memory database are sent to the data warehouse system to update the test hotspot data in the data warehouse system. This ensures that the test hotspot data in the data warehouse system and the test hotspot data in the in-memory database change synchronously, thereby guaranteeing the consistency of the test hotspot data and improving data reliability.

[0091] According to embodiments of this disclosure, a test task including identification information of test cases to be executed is received. An in-memory database corresponding to the identification information of the test cases is generated based on test hotspot data from a data warehouse system. Then, with the test hotspot data including test base data corresponding to the test cases, the test task is executed based on the test cases and the test base data to obtain test results. The test results are then sent to the data warehouse system so that the data warehouse system updates its test hotspot data based on the test results, ensuring consistency between the test hotspot data in the data warehouse system and the test hotspot data in the in-memory database. The technical solution provided by this disclosure stores test hotspot data in an in-memory database and uses this data to execute test cases, reducing dependence on the data warehouse system. When data in the data warehouse system on which the test cases depend is modified or deleted, it will not affect the normal execution of unit tests. Therefore, the technical solution of this disclosure at least partially solves the technical problem of strong dependence on data warehouse systems in related technologies for unit testing methods.

[0092] According to embodiments of this disclosure, test case data is typically stored in a data warehouse system. Due to the massive volume of data in data warehouse systems, reaching hundreds of millions, the systems suffer from poor flexibility and long processing times for adding, deleting, modifying, and querying data. The technical solution of this disclosure stores frequently used data from actual test cases, i.e., test hotspot data, in an in-memory database. Since the volume of test hotspot data is relatively small, typically tens or hundreds of data points, executing test cases using an in-memory database improves execution efficiency. Furthermore, the smaller data volume in the in-memory database also helps to shorten the time required for adding, deleting, modifying, and querying data.

[0093] According to embodiments of this disclosure, the test task includes M test subtasks, each test subtask corresponding to a test case, where M ≥ 2; wherein, generating the memory database corresponding to the identification information of the test cases based on test hotspot data from the data warehouse system includes: for each of the M test subtasks, generating the memory database corresponding to the test subtask based on test hotspot data from the data warehouse system; wherein, when the test hotspot data includes test base data corresponding to the test cases, executing the test task based on the test cases and the test base data to obtain test results includes: for the M test subtasks... Each of the aforementioned test subtasks, provided that the test hotspot data includes the test base data corresponding to the aforementioned test subtask, executes the aforementioned test subtask based on the aforementioned test cases and the aforementioned test base data to obtain the test result corresponding to the aforementioned test subtask; wherein, the aforementioned sending the aforementioned test results to the aforementioned data warehouse system so that the aforementioned data warehouse system updates the test hotspot data in the aforementioned data warehouse system based on the aforementioned test results includes: sending the M test results obtained by executing the aforementioned M test subtasks to the aforementioned data warehouse system so that the aforementioned data warehouse system updates the test hotspot data in the aforementioned data warehouse system based on the aforementioned M test results and preset calculation rules.

[0094] According to embodiments of this disclosure, when a test task includes multiple test subtasks, each test subtask corresponds to a test case and each test subtask corresponds to an in-memory database, so that each test subtask uses an independent in-memory database for test execution, which can be well applied to scenarios with massive data and complex data models.

[0095] According to embodiments of this disclosure, multiple test subtasks generate multiple test results, which are then sequentially sent to a data warehouse system. The data warehouse system determines the final test result corresponding to the test task based on the sent test results and preset calculation rules, and uses the final test result to update the test hotspot data in the data warehouse system.

[0096] In one embodiment of this disclosure, for example, in the test task of quoting, since the quotation result is affected by multiple factors, each factor is a test subtask. The test result obtained after each test subtask is executed alone is the test result obtained under the influence of that factor. Then, the test results of multiple test subtasks are sent to the data warehouse system. The data warehouse system determines the final test result based on the test results under multiple factors, that is, the final test result of the quotation.

[0097] More specifically, the quotation testing task includes three test subtasks: the first test subtask, the second test subtask, and the third test subtask. The first test subtask corresponds to the first test case, the second test subtask corresponds to the second test case, and the third test subtask corresponds to the third test case. The first test subtask calls the first in-memory database, executes the test using the first test case, and obtains the first test result, which is then stored in the first in-memory database. The second test subtask calls the second in-memory database, executes the test using the second test case, and obtains the second test result, which is also stored in the second in-memory database. The third test subtask calls the third in-memory database, executes the test using the third test case, and obtains the third test result, which is then stored in the third in-memory database. The first, second, and third test results are then sequentially sent to the data warehouse system. The data warehouse system determines the final test result of the test task based on the first, second, and third test results and preset calculation rules, and uses the final test result to update the test hotspot data.

[0098] According to embodiments of this disclosure, the unit testing method further includes storing each of the M test subtasks into a corresponding queue; sequentially determining whether the test subtasks in each queue have been completed; and sending the test results corresponding to the test subtasks to the data warehouse system after the test subtasks have been completed.

[0099] Figure 3 A flowchart illustrating a unit testing method according to another embodiment of the present disclosure is shown.

[0100] like Figure 3 As shown, taking a test task that includes three test sub-tasks as an example, this unit test method includes operations S301 to S319.

[0101] In operation S301, a test task is received, which includes a first test subtask, a second test subtask, and a third test subtask; the first test subtask corresponds to the first test case, the second test subtask corresponds to the second test case, and the third test subtask corresponds to the third test case.

[0102] The first test subtask, the second test subtask, and the third test subtask are executed respectively.

[0103] The first test subtask executes operations S302 to S306; the second test subtask executes operations S307 to S311; the first test subtask executes operations S312 to S316.

[0104] In operation S302, a first in-memory database corresponding to the first test case is generated based on test hotspot data from the data warehouse system.

[0105] In operation S303, determine whether the test hotspot data includes the first test basic data. If the test hotspot data does not include the first test basic data, execute operation S304; if the test hotspot data includes the first test basic data, execute operation S305.

[0106] In operation S304, the first test base data is obtained from the data warehouse system.

[0107] In operation S305, the first test subtask is executed based on the first test case and the first test base data to obtain the first test result.

[0108] In operation S306, the first test result is sent to the data warehouse system.

[0109] In operation S307, a second in-memory database corresponding to the second test case is generated based on test hotspot data from the data warehouse system.

[0110] In operation S308, determine whether the test hotspot data includes the second test basic data. If the test hotspot data does not include the second test basic data, execute operation S309; ​​if the test hotspot data includes the second test basic data, execute operation S310.

[0111] In operation S309, the second test base data is obtained from the data warehouse system.

[0112] In operation S310, the second test subtask is executed based on the second test case and the second test base data to obtain the second test result.

[0113] In operation S311, the second test result is sent to the data warehouse system.

[0114] In operation S312, a third in-memory database corresponding to the third test case is generated based on test hotspot data from the data warehouse system.

[0115] In operation S313, determine whether the test hotspot data includes the third test basic data. If the test hotspot data does not include the third test basic data, execute operation S314; if the test hotspot data includes the third test basic data, execute operation S315.

[0116] In operation S314, third test base data is obtained from the data warehouse system.

[0117] In operation S315, the third test subtask is executed based on the third test case and the third test base data to obtain the third test result.

[0118] In operation S316, the third test result is sent to the data warehouse system.

[0119] During operation S317, the data warehouse system obtains the first test result, the second test result, and the third test result.

[0120] In operation S318, the data warehouse system determines the final test result corresponding to the test task based on the first test result, the second test result, the third test result, and the preset calculation rules.

[0121] In operation S319, the test hotspot data in the data warehouse system is updated using the final test results.

[0122] According to embodiments of this disclosure, the unit testing method further includes: querying test results corresponding to the test task in the data warehouse system to obtain a first query result; querying test results corresponding to the test subtask in each of the M memory databases to obtain a second query result; comparing the first query result with the second query result to obtain a comparison result; and updating the test hotspot data in the memory database using the first query result if the comparison result indicates that the first query result and the second query result meet preset conditions.

[0123] According to embodiments of this disclosure, the first query result may include the final test result corresponding to the test task and the test results of all test subtasks. The second query result includes the test results corresponding to the test subtasks in the memory database. Preset conditions may include, for example, that the first query result contains the second query result, and whether the test results corresponding to the test subtasks in the second query result are consistent with the final test results corresponding to the test task in the first query result.

[0124] According to an embodiment of this disclosure, if the first query result includes the second query result, and the test result corresponding to the test subtask in the second query result is inconsistent with the final test result corresponding to the test task in the first query result, the test hotspot data in the memory database is updated using the final test result corresponding to the test task in the first query result, so as to ensure that the test hotspot data in the memory database is consistent with the test hotspot data in the data warehouse system.

[0125] According to an embodiment of this disclosure, if the first query result does not include the second query result, the test result corresponding to the test subtask is sent to the data warehouse system.

[0126] In one embodiment of this disclosure, such as a pricing test task, there are first test subtasks and second test subtasks. A first query result may include a final test result corresponding to the test task, a first test result corresponding to the first test subtask, and a second test result corresponding to the second test subtask. For the first test subtask, the second query result may include the first test result in a first memory database; then, the first query result and the second query result are compared to obtain a first comparison result; if the first comparison result indicates that the first query result contains the second query result, and the final test result in the first query result is inconsistent with the first test result in the second query result, the test hotspot data in the first memory database is updated using the final test result. For the second test subtask, the second query result may include the second test result in a second memory database; then, the first query result and the second query result are compared to obtain a second comparison result; if the second comparison result indicates that the first query result contains the second query result, and the final test result in the first query result is inconsistent with the second test result in the second query result, the test hotspot data in the second memory database is updated using the final test result.

[0127] Figure 4 A flowchart illustrating a memory database update method according to an embodiment of the present disclosure is shown schematically.

[0128] According to embodiments of this disclosure, the test task includes multiple test subtasks, and each test subtask corresponds to an in-memory database. Each in-memory database needs to perform the same operation to update the test hotspot data in the in-memory database. Figure 4 The following explanation uses updating test hotspot data in the first memory database as an example.

[0129] like Figure 4 As shown, the method includes operations S401 to S407.

[0130] In operation S401, the first in-memory database corresponding to the first test subtask sends a query request to the data warehouse system. The query request is used to query the final test result corresponding to the test task in the data warehouse system.

[0131] In operation S402, the data warehouse system responds to the query request, queries the final test result corresponding to the test task, and obtains the first query result.

[0132] In operation S403, the first test result corresponding to the first test subtask in the first memory database is queried to obtain the second query result.

[0133] In operation S404, the first query result is compared with the second query result to obtain the comparison result.

[0134] In operation S405, determine whether the first query result and the second query result are consistent in the comparison results. If it is determined that the first query result and the second query result are inconsistent, execute operation S406; if it is determined that the first query result and the second query result are consistent, execute operation S407.

[0135] In operation S406, the test hotspot data in the first memory database is updated using the final test results from the first query result.

[0136] When operating S407, there is no need to update the test hotspot data in the first memory database.

[0137] According to an embodiment of this disclosure, generating an in-memory database corresponding to the identification information of the test cases based on test hotspot data from the data warehouse system includes: generating the in-memory database corresponding to the identification information of the test cases; generating a basic data empty table in the in-memory database using a pre-set configuration file; obtaining the test hotspot data from the data warehouse system; and storing the test hotspot data in the basic data empty table in the in-memory database.

[0138] According to embodiments of this disclosure, the basic data empty table may include, for example, a table for storing test hotspot data.

[0139] According to embodiments of this disclosure, the unit testing method further includes: generating an initialization table file based on preset fields; generating an example data file corresponding to the preset fields; and generating the configuration file based on the initialization table file and the example data file.

[0140] According to embodiments of this disclosure, preset fields may include, for example, information fields that need to be filled in during the initialization of the table. For instance, preset fields may include information such as data name, data type, and data size.

[0141] According to embodiments of this disclosure, the preset field file may include, for example, the init-table.sql file; the example data file may include, for example, the data.sql file. The preset field file init-table.sql is added to the sql directory of resources, and the example data file data.sql is added to the application-test.yml file to generate the configuration file.

[0142] According to an embodiment of this disclosure, generating a basic data empty table in the memory database using a pre-set configuration file includes: generating an initialization table in the memory database according to the initialization table file; storing example data from the example data file into the initialization table to obtain the basic data empty table.

[0143] According to embodiments of this disclosure, configuring an in-memory database on the server includes adding a dependency on the in-memory database to the dependency module of POM.xml, then adding a test environment configuration file, adding application-test.yml to the resources directory, adding the in-memory database connection configuration, and adding a dependency on the in-memory database to the MyBatis XML configuration.

[0144] Figure 5 A flowchart illustrating a unit testing method according to another embodiment of the present disclosure is shown.

[0145] like Figure 5 As shown, the unit test method includes operations S501 to S511.

[0146] In operation S501, an initialization table file is generated based on preset fields.

[0147] In operation S502, a sample data file corresponding to the preset fields is generated.

[0148] When operating S503, a configuration file is generated based on the initialization table file and the sample data file.

[0149] In operation S504, a test task is received, which includes identification information of the test cases to be executed.

[0150] When operating S505, an in-memory database corresponding to the identification information of the test cases is generated.

[0151] When operating S506, an initialization table is generated in the memory database based on the initialization table file.

[0152] In operation S507, the sample data from the sample data file is stored in the initialization table, resulting in an empty basic data table.

[0153] When operating S508, test hotspot data is retrieved from the data warehouse system.

[0154] When operating S509, test hotspot data is stored in the basic empty table of the memory database.

[0155] When operating S510, if the test hotspot data includes test base data corresponding to the test cases, test tasks are executed based on the test cases and test base data to obtain test results.

[0156] When operating S511, test results are sent to the data warehouse system so that the data warehouse system can update the test hotspot data in the data warehouse system based on the test results.

[0157] According to embodiments of this disclosure, this disclosure provides a unit testing method for optimizing database statements such as SQL using an in-memory database. By installing and deploying an in-memory database on a server, test hotspot data from the data warehouse system is cached in the in-memory database, and a corresponding data synchronization method is configured to automatically synchronize changed test hotspot data in the in-memory database to the data warehouse system, thereby ensuring data reliability. By utilizing in-memory database technology, this method solves the technical problem of excessive reliance on public databases for unit testing of SQL statements, and improves system performance.

[0158] According to embodiments of this disclosure, this disclosure employs in-memory database technology to cache unit tests of database languages ​​such as SQL statements in memory, thereby achieving loose coupling between the in-memory database and the server database.

[0159] According to embodiments of this disclosure, this disclosure provides a data synchronization method for in-memory databases, which automatically synchronizes the test hotspot data that changes after the execution of unit tests of SQL statements to the data warehouse system database, enabling flexible creation and management of in-memory databases.

[0160] According to embodiments of this disclosure, this disclosure focuses on the unit test execution of database languages ​​such as SQL statements, thereby improving execution performance.

[0161] It should be noted that, unless it is explicitly stated that there is a sequential order of execution between different operations, or that there is a sequential order of execution between different operations in terms of technical implementation, the execution order between multiple operations may not be significant, and multiple operations may be executed simultaneously.

[0162] Based on the above unit testing method, this disclosure also provides a unit testing apparatus. The following will be combined with... Figure 6 The device is described in detail.

[0163] Figure 6A schematic block diagram of a unit test apparatus according to an embodiment of the present disclosure is shown.

[0164] like Figure 6 As shown, the unit test apparatus 600 of this embodiment includes a receiving module 610, a first generation module 620, an execution module 630, and a sending module 640.

[0165] The receiving module 610 is used to receive test tasks, wherein the test tasks include identification information of test cases to be executed. In one embodiment, the receiving module 610 can be used to perform the operation S210 described above, which will not be repeated here.

[0166] The first generation module 620 is used to generate an in-memory database corresponding to the identification information of the aforementioned test cases based on test hotspot data from the data warehouse system. In one embodiment, the first generation module 620 can be used to perform the operation S220 described above, which will not be repeated here.

[0167] The execution module 630 is used to execute the test tasks according to the test cases and the test base data, and obtain test results, when the test hotspot data includes test base data corresponding to the test cases. In one embodiment, the execution module 630 can be used to execute the operation S230 described above, which will not be repeated here.

[0168] The sending module 640 is used to send the test results to the data warehouse system, so that the data warehouse system can update the test hotspot data in the data warehouse system according to the test results. In one embodiment, the sending module 640 can be used to perform the operation S240 described above, which will not be repeated here.

[0169] According to an embodiment of this disclosure, the test task includes M test subtasks, each of which corresponds to a test case, where M ≥ 2.

[0170] According to an embodiment of this disclosure, the first generation module is further configured to generate, for each of the M test subtasks, the memory database corresponding to the test subtask based on test hotspot data from the data warehouse system.

[0171] According to an embodiment of this disclosure, the execution module is further configured to, for each of the M test subtasks, if the test hotspot data includes test base data corresponding to the test subtask, execute the test subtask according to the test cases and the test base data corresponding to the test subtask, and obtain the test result corresponding to the test subtask.

[0172] According to an embodiment of this disclosure, the sending module is further configured to send M test results obtained from executing the M test sub-tasks to the data warehouse system, so that the data warehouse system updates the test hotspot data in the data warehouse system according to the M test results and preset calculation rules.

[0173] According to embodiments of this disclosure, the unit testing apparatus further includes a first query module, a second query module, a comparison module, and an update module.

[0174] The first query module is used to query the test results corresponding to the test tasks in the data warehouse system and obtain the first query result.

[0175] The second query module is used to query the test results corresponding to the test subtasks in each of the M memory databases to obtain the second query result.

[0176] The comparison module is used to compare the first query result with the second query result to obtain the comparison result.

[0177] The update module is used to update the test hotspot data in the memory database using the first query result when the comparison results indicate that the first query result and the second query result meet the preset conditions.

[0178] According to embodiments of this disclosure, the first generation module includes a first generation unit, a second generation unit, an acquisition unit, and a storage unit.

[0179] The first generation unit is used to generate the aforementioned memory database corresponding to the identification information of the aforementioned test cases.

[0180] The second generation unit is used to generate an empty table of basic data in the aforementioned memory database using a pre-set configuration file.

[0181] The acquisition unit is used to acquire the aforementioned test hotspot data from the aforementioned data warehouse system.

[0182] The storage unit is used to store the aforementioned test hotspot data into the aforementioned basic data empty table in the aforementioned memory database.

[0183] According to embodiments of this disclosure, the unit testing apparatus further includes a second generation module, a third generation module, and a fourth generation module.

[0184] The second generation module is used to generate an initialization table file based on preset fields.

[0185] The third generation module is used to generate sample data files corresponding to the aforementioned predefined fields;

[0186] The fourth generation module is used to generate the configuration file based on the initialization table file and the example data file.

[0187] According to embodiments of this disclosure, the second generation unit includes a generation subunit and a storage subunit.

[0188] The generation sub-unit is used to generate an initialization table in the memory database based on the initialization table file described above.

[0189] The storage sub-unit is used to store the example data from the example data file into the initialization table to obtain the basic data empty table.

[0190] According to embodiments of this disclosure, the aforementioned test hotspot data includes basic test data in the aforementioned data warehouse system whose call frequency meets preset values.

[0191] According to embodiments of this disclosure, the unit testing apparatus further includes an acquisition module.

[0192] The acquisition module is used to acquire the test basic data corresponding to the test cases from the data warehouse system when the test hotspot data does not include the test basic data corresponding to the test cases.

[0193] Figure 7 A schematic block diagram of a unit test apparatus according to another embodiment of the present disclosure is shown.

[0194] like Figure 7 As shown, the unit testing device 700 of this embodiment includes an environment configuration module 710, a data preparation module 720, a code writing and execution module 730, and a result output module 740.

[0195] The environment configuration module 710 is used to integrate the in-memory database and configure related files in the test environment. For example, the environment configuration module 710 can be used to implement the functions of the second, third, and fourth generation modules described above.

[0196] The data preparation module 720 is used to prepare the initialization data for the test base class. The data preparation module 720 can, for example, implement the functions of the aforementioned generation sub-unit, acquisition unit, storage unit, and storage sub-unit.

[0197] The code writing and execution module 730 is used for writing and executing SQL unit tests that call the in-memory database. For example, the code writing and execution module 730 can be used to implement the functionality of the execution module described above.

[0198] The results output module 740 is used to collect the execution status of SQL unit tests, including execution status, execution time and resource consumption, as well as subsequent rating feedback from testers on issues found in the SQL unit tests.

[0199] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as Field Programmable Gate Arrays (FPGAs), Programmable Logic Arrays (PLAs), Systems-on-Chip, Systems-on-Substrate, Systems-on-Package, Application-Specific Integrated Circuits (ASICs), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.

[0200] According to embodiments of this disclosure, any plurality of modules among the receiving module 610, the first generating module 620, the execution module 630, and the transmitting module 640 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules may be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of this disclosure, at least one of the receiving module 610, the first generating module 620, the execution module 630, and the transmitting module 640 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in a suitable combination of any of these. Alternatively, at least one of the receiving module 610, the first generating module 620, the executing module 630, and the sending module 640 may be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.

[0201] It should be noted that the unit testing device part in the embodiments of this disclosure corresponds to the unit testing method part in the embodiments of this disclosure. The specific description of the unit testing device part is referred to in the unit testing method part, and will not be repeated here.

[0202] Figure 8 A block diagram schematically illustrates an electronic device suitable for implementing a unit testing method according to an embodiment of the present disclosure.

[0203] like Figure 8 As shown, an electronic device 800 according to an embodiment of this disclosure includes a processor 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this disclosure.

[0204] RAM 803 stores various programs and data required for the operation of electronic device 800. Processor 801, ROM 802, and RAM 803 are interconnected via bus 804. Processor 801 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 802 and / or RAM 803. It should be noted that the programs may also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.

[0205] According to embodiments of this disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to a bus 804. The electronic device 800 may also include one or more of the following components connected to the I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 810 as needed so that computer programs read from it can be installed into the storage section 808 as needed.

[0206] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.

[0207] According to embodiments of this disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this disclosure, the computer-readable storage medium may include ROM 802 and / or RAM 803 and / or one or more memories other than ROM 802 and RAM 803 described above.

[0208] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the unit testing methods provided in the embodiments of this disclosure.

[0209] When the computer program is executed by the processor 801, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0210] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and may be downloaded and installed via the communication section 809, and / or installed from a removable medium 811. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0211] In such an embodiment, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by processor 801, it performs the functions defined in the system of this disclosure embodiment. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0212] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0213] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0214] Those skilled in the art will understand that the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways, even if such combinations or combinations are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure can be combined or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.

[0215] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A unit testing method, comprising: Receive a test task, wherein the test task includes identification information of test cases to be executed, the test task includes M test subtasks, each test subtask corresponds to a test case, wherein M≥2; For each of the M test subtasks, an in-memory database corresponding to the test subtask is generated based on test hotspot data from the data warehouse system. The test hotspot data includes basic test data in the data warehouse system whose call frequency meets a preset value. The in-memory database is used to store the test hotspot data so as to execute test cases using the test hotspot data in the in-memory database. For each of the M test subtasks, if the test hotspot data includes the test base data corresponding to the test subtask, the test subtask is executed according to the test cases and the test hotspot data corresponding to the test subtask, resulting in a test result corresponding to the test subtask, and the test result is stored in the memory database corresponding to the test subtask; and The data warehouse system sends M test results obtained from executing the M test sub-tasks to the data warehouse system, so that the data warehouse system can determine the final test result corresponding to the test task based on the M test results and preset calculation rules, and update the test hotspot data in the data warehouse system based on the final test results; Query the test results in the data warehouse system corresponding to the test task to obtain the first query result; For each of the M memory databases, query the test results in the memory database corresponding to the test subtask to obtain a second query result; The first query result is compared with the second query result to obtain the comparison result; If the comparison results indicate that the first query result and the second query result meet the preset conditions, the test hotspot data in the memory database is updated using the first query result.

2. The method according to claim 1, wherein, The step of generating an in-memory database corresponding to the test subtask based on test hotspot data from the data warehouse system includes: Generate an in-memory database corresponding to the identification information of the test cases corresponding to the test subtasks; Using a pre-configured configuration file, an empty table of basic data is generated in the memory database; Obtain the test hotspot data from the data warehouse system; The test hotspot data is stored in the basic data empty table in the memory database.

3. The method according to claim 2, further comprising: Generate an initialization table file based on preset fields; Generate a sample data file corresponding to the preset fields; The configuration file is generated based on the initialization table file and the example data file.

4. The method according to claim 3, wherein, The step of generating a basic empty table in the memory database using a pre-set configuration file includes: An initialization table is generated in the memory database according to the initialization table file; The example data from the example data file is stored in the initialization table to obtain the basic data empty table.

5. The method according to claim 1, further comprising: If the test hotspot data does not include the test base data corresponding to the test case, the test base data corresponding to the test case is obtained from the data warehouse system; and the test sub-task is executed according to the test case corresponding to the test sub-task and the test base data corresponding to the test case obtained from the data warehouse system to obtain the test result.

6. A unit testing apparatus, comprising: A receiving module is used to receive test tasks, wherein the test task includes identification information of test cases to be executed, and the test task includes M test subtasks, each of the test subtasks corresponding to a test case, wherein M≥2; The first generation module is used to generate an in-memory database corresponding to each of the M test subtasks based on test hotspot data from the data warehouse system. The test hotspot data includes test basic data in the data warehouse system whose call frequency meets a preset value. The in-memory database is used to store the test hotspot data so that test cases can be executed using the test hotspot data in the in-memory database. The execution module is configured to, for each of the M test subtasks, execute the test subtask according to the test cases and the test hotspot data corresponding to the test subtask, when the test hotspot data includes test base data corresponding to the test subtask, obtain the test results corresponding to the test subtask, and store the test results corresponding to the test subtask in the memory database corresponding to the test subtask; and The sending module is used to send M test results obtained from executing the M test sub-tasks to the data warehouse system, so that the data warehouse system can determine the final test result corresponding to the test task based on the M test results and preset calculation rules, and update the test hotspot data in the data warehouse system based on the final test results; The first query module is used to query the test results corresponding to the test task in the data warehouse system to obtain the first query result; The second query module is used to query the test results corresponding to the test subtask in each of the M memory databases to obtain the second query result. The comparison module is used to compare the first query result with the second query result to obtain the comparison result; An update module is used to update the test hotspot data in the memory database using the first query result when the comparison result indicates that the first query result and the second query result meet preset conditions.

7. An electronic device, comprising: One or more processors; Storage device for storing one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors perform the method of any one of claims 1 to 5.

8. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 5.

9. A computer program product comprising a computer program that, when executed by a processor, implements the method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for testing product

    CN106326116A

  • Automatic unit test method and device based on memory database

    CN110750457A