Database test method and device, electronic equipment and storage medium
Through the automated database testing method, the problem of difficult to trace database test results in the existing technology is solved, and one-click automated database detection and convenient traceability of test results is realized.
Patent Information
- Application Number
- CN202510695032.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-28
- Publication Date
- 2025-06-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, it is difficult to trace the database test results easily and easily.
In response to the test setting operation, the database to be tested, the target text use case set and the file output path are determined; in response to the test start operation, the database to be tested based on the target text use case set, the test results are obtained, and the test file is generated and output.
It realizes one-click automated database detection and automatically outputs test files that record test results of text use case sets, so as to facilitate later traceability of test results.
Smart Images

Figure CN120216388A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technologies, and in particular, to a database testing method, apparatus, electronic device, and storage medium. Background Art
[0002] In order to ensure the correctness, reliability, performance, and security of a database system to meet business requirements and technical requirements, database testing is essential.
[0003] In related technologies, the method of writing test step scripts by testers according to the specifications of a framework for database testing has the problem that it is difficult to conveniently trace the test results later. Summary of the Invention
[0004] The present invention provides a database testing method, apparatus, electronic device, and storage medium to solve the technical problem that it is currently difficult to conveniently trace the test results later.
[0005] According to one aspect of the present invention, there is provided a database testing method, which includes:
[0006] In response to a test setting operation, determining a database to be tested, a target text test case set, and a file output path;
[0007] In response to a test start operation, testing the database to be tested based on the target text test case set to obtain a target test result, generating a target test file based on the target test result, and outputting the target test file based on the file output path.
[0008] According to another aspect of the present invention, there is provided a database testing apparatus, which includes:
[0009] A test setting module, configured to determine a database to be tested, a target text test case set, and a file output path in response to a test setting operation;
[0010] A database testing module, configured to test the database to be tested based on the target text test case set in response to a test start operation to obtain a target test result, generate a target test file based on the target test result, and output the target test file based on the file output path.
[0011] According to another aspect of the present invention, there is provided an electronic device, where the electronic device includes:
[0012] At least one processor; and
[0013] A memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program executable by the at least one processor. When executed by the at least one processor, the computer program enables the at least one processor to execute the database testing method according to any embodiment of the present invention.
[0015] According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement the database testing method according to any embodiment of the present invention when executed.
[0016] The technical solution of the embodiment of the present invention determines a database to be tested, a target text use case set, and a file output path in response to a test setting operation; in response to a test start operation, tests the database to be tested based on the target text use case set to obtain a target test result, generates a target test file based on the target test result, and outputs the target test file based on the file output path. The present invention achieves the effect of one-key automated database detection. This application can automatically output a test file recording the test results of the text use case set, facilitating the traceability of the test results in the later stage.
[0017] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. Description of the Drawings
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0019] Figure 1 is a flowchart of a database testing method according to Embodiment 1 of the present invention;
[0020] Figure 2 is a flowchart of a database testing method according to Embodiment 2 of the present invention;
[0021] Figure 3 is an overall flowchart of a database testing method according to an embodiment of the present invention;
[0022] Figure 4 is a structural schematic diagram of a database testing device according to Embodiment 3 of the present invention;
[0023] Figure 5It is a schematic structural diagram of an electronic device for implementing the database testing method of the embodiments of the present invention. Detailed implementation manners
[0024] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order different from those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0026] Embodiment 1
[0027] Figure 1 For Embodiment 1 of the present invention, a flowchart of a database testing method is provided. This embodiment is applicable to the situation of automated testing of a database. This method can be executed by a database testing device, which can be implemented in the form of hardware and / or software, and the database testing device can be configured in a computer. As Figure 1 shown, this method includes:
[0028] S110. In response to a test setting operation, determine a database to be tested, a target text use case set, and a file output path.
[0029] Among them, the test setting operation can be understood as an operation for setting test-related data. In the embodiments of the present invention, the test setting operation can be preset according to scenario requirements, and no specific limitation is made here. Optionally, the test setting operation may include a text selection operation, a database selection operation, an output path selection operation, etc. Among them, the text selection operation can be understood as an operation for selecting the target text use case set. Specifically, the text selection operation can be a selection operation for multiple text path selection items. One text path selection item can correspond to one text path, and one text path can correspond to a candidate text use case set. The text selection operation can also be an operation for inputting a text path. The input text path can correspond to a candidate text use case set. The database selection operation can be understood as an operation for selecting the database to be tested. Specifically, the database selection operation can be a selection operation for multiple database Internet Protocol (IP) address selection items. One database IP address selection item can correspond to a candidate database. The database selection operation can also be an operation for inputting a database IP address. The input database IP address can correspond to a candidate database. The output path selection operation can be understood as an operation for selecting the file output path. Specifically, the file output path can be a selection operation for multiple output path selection items. One output path selection item can correspond to one output path. One output path can correspond to a folder, and the folder can be used to store output files. The file output path can also be an operation for inputting an output path. The input output path can correspond to a folder.
[0030] The database to be tested can be understood as the database to be tested. In the embodiments of the present invention, the category of the database to be tested can be related to scenario requirements, and no specific limitation is made here. Preferably, the database to be tested can be a GBase8c database.
[0031] The target text use case set can be understood as a set of text use cases for testing the database to be tested. The target text use case set may include at least one test text use case. In the embodiments of the present invention, the set of text use cases can be pre-constructed by developers based on actual requirements, and no specific limitation is made here.
[0032] The file output path can be understood as the output path of the test file. Among them, the test file can be used to record the test results of the test text use cases, and the test results can be execution statements, and the execution statements can be code.
[0033] S120. In response to a test start operation, test the database to be tested based on the target text use case set to obtain a target test result, generate a target test file based on the target test result, and output the target test file based on the file output path.
[0034] Among them, the test start operation can be understood as an operation to start database testing. In the embodiments of the present invention, the test start operation can be preset according to scenario requirements and will not be specifically limited here. Optionally, the test start operation can be a trigger operation for a test start control or a trigger operation for a carriage return key. The test start control can be a button on the display screen.
[0035] The target test result can be understood as the database test result under the target text use case set. Optionally, the target test result may include sub-test results corresponding to each test text use case in the target text use case set.
[0036] The target test file can be used to record the target test result. The target test file can be a table file. The table file may include multiple sub-test data, and each sub-test data includes a test text use case and a corresponding test image. The test image can be a screenshot corresponding to the sub-test result.
[0037] The technical solution of the embodiments of the present invention determines the database to be tested, the target text use case set, and the file output path by responding to a test setting operation; in response to a test start operation, tests the database to be tested based on the target text use case set to obtain a target test result, generates a target test file based on the target test result, and outputs the target test file based on the file output path. The present invention achieves the effect of one-key automatic database detection and output of test files. This application can automatically output a test file recording the test results of the text use case set, facilitating the later traceability of the test results.
[0038] Embodiment Two
[0039] Figure 2 It is a flowchart of a database testing method provided by Embodiment Two of the present invention. This embodiment refines the step of testing the database to be tested based on the target text use case set to obtain a target test result in the above embodiment. As Figure 2 shown, the method includes:
[0040] S210. In response to a test setting operation, determine the database to be tested, the target text use case set, and the file output path.
[0041] Among them, the target text case set may include at least one test text case. The test text case can be understood as a text case for testing a database. In the embodiments of the present invention, the test text case may be pre-constructed by developers based on actual requirements, and no specific limitation is made here. Optionally, the test text case may include a test statement and an annotation for the test statement.
[0042] S220. In response to a test start operation, for each of the above, parse the test text case to determine the test statement corresponding to the test text case, and determine a statement sequence based on at least one of the test statements.
[0043] Among them, the test statement may be an SQL statement in the test text case. This SQL statement can be run in a test window. Specifically, parse the test text case to extract the SQL statement in the test text case as the test statement.
[0044] The statement sequence can be understood as a sequence of the test statements. Generally speaking, the statement sequence can represent the execution order among at least one of the test statements.
[0045] S230. For the test statements in the statement sequence, sequentially perform the operations of testing the database to be tested based on the test statements to obtain sub-test results, and taking a screenshot of the sub-test results to obtain a test image.
[0046] Among them, the sub-test result can be understood as the execution result of the test statement. This execution result may be code. The test image can be understood as a screenshot of the sub-test result.
[0047] Optionally, testing the database to be tested with the test statement to obtain sub-test results includes:
[0048] Determine the statement input focus in the test window, copy the test statement to the test window based on the statement input focus, perform a carriage return operation, and determine the sub-test result of the test statement.
[0049] Among them, the test window can be understood as the input window of the test statement. The statement input focus can be understood as the input focus of the test statement. Specifically, after performing the carriage return operation, the test statement is executed through the test window, and a sub-test result is returned. In the embodiment of the present invention, the returned sub-test result can be the execution statement returned based on the test statement in the test window. The execution statement can include a process statement and a result statement. Among them, the process statement can characterize the test process of performing a database test based on the test statement. The result statement can characterize whether the database test based on the test statement is successful.
[0050] Based on the above embodiment solution, after the present invention starts the database test with one key, it can simulate the process of manually performing a database test, that is, automatically locate the test window, focus on the statement input focus, copy the test statement into the test window, and perform a series of operations such as carriage return. Simulating the manual execution of a database test by humans can be more convenient for visual traceability, so as to facilitate the verification of the effectiveness of the sub-test results in the later stage. That is, when performing a database test based on an automated test step script written by a staff member, there is no intuitive evidence when the automated script runs, such as screenshots, only code logs. If the test fails, it is difficult to quickly determine whether the script is written wrong or there is a problem with the database. However, the present application can effectively solve the above problems and achieve the provability of the effectiveness of the test results. When performing a database test based on an automated test step script written by a staff member, when the database table structure changes, all related scripts need to be manually modified, which is difficult to maintain after long-term accumulation. However, in the solution of the present invention, even if the database is upgraded, as long as the manual operation method remains unchanged, the test script does not need to be modified, improving the applicability.
[0051] Optionally, determining the sub-test result of the test statement includes:
[0052] Detecting the statement execution status of the test window based on a preset status detection period; where the statement execution status includes execution end or statement execution not ended;
[0053] In the case where the statement execution status is detected as the execution end before the number of cycle detections reaches the detection number threshold, the execution statement in the test window is used as the sub-test result corresponding to the test statement; otherwise, the preset abnormal prompt data is used as the sub-test result of the test statement.
[0054] Among them, the status detection period can be understood as the period for detecting the status of the test window. In the embodiment of the present invention, the status detection period can be preset according to scenario requirements and will not be specifically limited here. Exemplarily, the status detection period can be 1 second, 2 seconds, 3 seconds, etc.
[0055] The execution status of the statement can indicate whether the test statement in the detection window has been executed. The execution status of the statement can include execution completed or statement execution not completed. Among them, the execution completed can indicate that the test statement has been executed. The execution not completed can indicate that the test statement has not been executed.
[0056] The periodic detection times can be understood as the number of times of detecting the execution status of the statements in the test window based on the status detection period. Exemplarily, the periodic detection times can be 1 time, 5 times or 10 times, etc. The detection times threshold can be understood as the threshold preset for the periodic detection times. In the embodiments of the present invention, the detection times threshold can be preset according to the scenario requirements and will not be specifically limited here. Exemplarily, the detection times threshold can be 10 times, 30 times or 60 times.
[0057] Specifically, when the status detection period is 1 second and the detection times threshold is 60 times, it is equivalent that the maximum execution time of each test statement is 1 minute. If it exceeds one minute, it is considered that the test is abnormal, and the abnormal prompt data is used as the sub-test result of the test statement.
[0058] The abnormal prompt data can be understood as the prompt data indicating test abnormality. The abnormal prompt data can be the execution statements that have not been completed corresponding to the test statements in the test window. The abnormal prompt data can also be an abnormal prompt text preset in advance. Exemplarily, the abnormal prompt text can be "test timeout", "test abnormality" or "statement abnormality", etc.
[0059] Based on the above embodiment solution, the limitation of the execution time of each test statement is realized, avoiding the situation that the entire test process is affected when an abnormal situation occurs in a certain test statement, and ensuring the smooth progress of the entire test process.
[0060] Among them, the test image can be understood as the screenshot corresponding to the sub-test result. The test image can be in png format.
[0061] Optionally, the method of taking a screenshot of the sub-test result to obtain a test image includes:
[0062] Detecting the identifier of the execution statement in the test window, and when the first identifier is detected and the second identifier is not detected, taking a screenshot of the execution statement based on the first identifier to obtain a test image.
[0063] Among them, the first identifier can be understood as an identifier representing the end of the execution of the test statement. In an actual application scenario, the first identifier can be "gbase=#". The second identifier can be understood as an identifier representing that the execution statement is not fully displayed in the test window. In an actual application scenario, the second identifier can be "More".
[0064] Specifically, identify the last two "gbase=#" in the test window, and take a screenshot of the execution statement between the two "gbase=#" to obtain a test image.
[0065] Based on the above embodiment solution, accurate and comprehensive screenshot of the sub-test result is realized. The execution statements in the test image obtained by the screenshot of the present invention include process statements and result statements, which can facilitate the later traceability of the sub-test result and prove the effectiveness of the sub-test result based on the process statements and result statements.
[0066] Optionally, the taking a screenshot of the sub-test result to obtain a test image includes:
[0067] Perform identifier detection on the execution statement in the test window. When the first identifier and the second identifier are detected, take a screenshot of the execution statement based on the first identifier and the second identifier to obtain a test image; wherein, the first identifier represents the end of the execution of the test statement; the second identifier represents that the execution statement is not fully displayed in the test window.
[0068] Specifically, when "gbase=#" and "More" are detected in the test window, take a screenshot of the execution statement between "gbase=#" and "More" to obtain a first image; trigger the second identifier, and continue to perform identifier detection on the test window. When only "More" is detected, take a screenshot of all the execution statements displayed in the test window to obtain a second image; return to execute the operation of triggering the second identifier, and continue to perform identifier detection on the test window. When only "More" is detected, take a screenshot of all the execution statements displayed in the test window to obtain a second image; until "gbase=#" is detected in the test window, take a screenshot of the execution statement running before "gbase=#" to obtain a third image; use the first image, the second image, and the third image obtained by the above screenshots as the test image. Triggering the second identifier can display the hidden execution statements that cannot be currently displayed in the test window. Generally speaking, when the number of lines of the execution statement is too large and the test window cannot display all of them, it is hidden based on "More".
[0069] Based on the above embodiment solution, comprehensive screenshot of the sub-test result is realized.
[0070] S240. Use at least one of the test images as the target test result.
[0071] S250. Generate a target test file based on the target test result and output the target test file based on the file output path.
[0072] Optionally, generating a target test file based on the target test result includes:
[0073] For each test text case, use the test text case and the corresponding test image as sub-test data, and fill the sub-test data into a table file based on a target template.
[0074] Use the table file with filled data as the target test file.
[0075] Among them, the sub-test data can be understood as a test data pair. The test data pair includes the test text case and the corresponding test image.
[0076] The target template can be understood as a general template for data filling to ensure the standardization of data filling. In the embodiments of the present invention, the target template can be preset according to scenario requirements, and no specific limitation is made here. The table file can be an Excel file or a Word file with a constructed table.
[0077] Based on the above embodiment solutions, automatic and standardized filling of test data is achieved, that is, automatic generation of a standardized target test file is achieved.
[0078] The technical solution of the embodiments of the present invention includes: for each test text case, parse the test text case to determine the test statement corresponding to the test text case, and determine a statement sequence based on at least one of the test statements; for the test statements in the statement sequence, sequentially execute the operation of testing the database to be tested based on the test statements to obtain sub-test results, and take screenshots of the sub-test results to obtain test images; use at least one of the test images as the target test result. The present invention realizes the retention of sub-test results by taking screenshots of the database test results under each test text case, which is convenient for later traceability.
[0079] Figure 3 is the overall flowchart of a database testing method provided according to the embodiments of the present invention. The following combines Figure 3 , and specifically elaborates an optional overall process of the database testing method in a step-by-step manner. The following described gsql window represents the test serial port, and the sql statement represents the test statement.
[0080] 1. Start the visualization interface component. Specifically, the visualization interface component is the window of all components, and starting the visualization interface component is the prerequisite for all operations. The visualization interface component can be used to select the text test case set to be executed, input the node information of the database to be tested, such as the IP address, and determine the output path of the test file. Among them, the above selection of the text test case set to be executed can be achieved by specifying the system path where the text test case set is located. The above input of the node information of the database to be tested can be achieved by specifying the IP address of the cluster of the database where all test case sets will be executed, and this IP address can be the main node address of the database.
[0081] 2. Click the button in the visualization interface component to execute the database test. Specifically, after starting the execution, through the text test case parsing component, the specified text test case set is parsed in sequence, and the text content such as step descriptions or comments in the test cases is distinguished from the SQL statements. Based on the distinguished SQL statements, a list of SQL statements is generated. After obtaining the parsed list, the system mouse will automatically move to the gsql window of the main node of the database cluster. Make this window gain focus, and then, in the order of the list, input the SQL statements corresponding to the test cases one by one. When inputting test cases, the Chinese part is spelled by multiple characters, and in the present invention, it is input into the gsql window by means of copy and paste. The non-Chinese part is input character by character to ensure the accuracy of character input. After a SQL statement is input, the enter operation is automatically executed. Since different SQL statements consume different times when executed, based on this, the present invention will detect whether the execution of the window is completed, set to check once every 1 second, and check a total of 60 times, that is, it represents that the longest execution time of each SQL statement is 1 minute. If the number of checks is exceeded, the ctrl+c combination key will be automatically executed to cancel the execution of this SQL statement. If the execution is not cancelled, further screenshots will be taken. If the number of rows returned by the execution of the SQL statement is too large, the space key will be automatically executed to print the complete return execution statement. The execution process of each SQL statement is screenshot by the test process screenshot component. By specifying the starting position of this SQL statement and the ending position of the return result, it is ensured that the execution process screenshots correspond one by one to the SQL test cases. When all test cases are executed, through the test report output component, according to the description in the text test cases, in the form of a standard table in Word or Excel, record the test purpose, test steps, test time, and test environment and other test-related information of each test case, and at the same time attach the process screenshots under each test step so that testers can perform backtracking through the test screenshots later. Further, according to the window print information, check the test case results. For the failed results, use the review function in Word to mark them, and at the same time summarize them in tabular form in the test report.
[0082] 3. Wait for the execution result of the visualization interface. Specifically, after all executions are completed, a window will pop up to prompt the end, and the output test report will be automatically opened for the staff to view the test results.
[0083] The present invention can be based on the Python language and integrate functions such as automatic parsing of text test cases, automatic input of SQL statements, and automatic judgment of execution results. The main functional components of the present invention can include a text test case parsing component, a test case simulation manual input component, a test process screenshot component, a test report output component, and a visualization interface component. The visualization interface component can be used to select any text test case set, specify the IP address of the database cluster, and specify the output path of the test report. The visualization interface component is the execution window of other functional components, and other functional components are the executors of each specific task. Among them, the test case simulation manual input component can include a simulated character input component, a simulated mouse movement and click component, and a simulated combination key input component, etc.
[0084] The technical solution of the present invention only needs text test cases to automatically execute database tests. By simulating manual input of SQL statements in the database operation interface and then using a screenshot tool to record all execution processes by taking screenshots, the simplicity of the test process is improved; the test results can be retained by taking screenshots for later traceability to verify the effectiveness of the test results.
[0085] Embodiment III
[0086] Figure 4 It is a schematic structural diagram of a database test device provided in Embodiment III of the present invention. As Figure 4 shown, the device includes: a test setting module 310 and a database test module 320.
[0087] Among them, the test setting module 310 is used to determine the database to be tested, the target text test case set, and the file output path in response to a test setting operation; the database test module 320 is used to test the database to be tested based on the target text test case set in response to a test start operation, obtain a target test result, generate a target test file based on the target test result, and output the target test file based on the file output path.
[0088] The technical solution of the embodiment of the present invention determines a database to be tested, a target text test case set, and a file output path in response to a test setting operation; in response to a test start operation, tests the database to be tested based on the target text test case set to obtain a target test result, generates a target test file based on the target test result, and outputs the target test file based on the file output path. The present invention realizes the effect of one-key automated database detection. This application can automatically output a test file recording the test results of the text test case set, so as to facilitate the traceability of the test results in the later stage.
[0089] Optionally, the text test case set includes at least one test text case; the database test module 320 includes: a test statement determination unit, a test image determination unit, and a test result determination unit;
[0090] Among them, the test statement determination unit is used to parse each test text case to determine the test statement corresponding to the test text case, and determine a statement sequence based on at least one of the test statements;
[0091] The test image determination unit is used to perform operations of testing the database to be tested based on the test statement in the statement sequence in sequence to obtain a sub-test result, and taking a screenshot of the sub-test result to obtain a test image;
[0092] The test result determination unit is used to use at least one of the test images as the target test result.
[0093] Optionally, the test image determination unit includes: a test execution subunit, which is used to determine the statement input focus in the test window, copy the test statement to the test window based on the statement input focus, perform a carriage return operation, and determine the sub-test result of the test statement.
[0094] Optionally, the test execution subunit is specifically used for:
[0095] Detecting the statement execution status of the test window based on a status detection period; wherein, the statement execution status includes execution end or statement execution not ended;
[0096] In the case where the statement execution status is detected as the execution end before the number of cycle detections reaches the detection number threshold, using the execution statement in the test window as the sub-test result corresponding to the test statement; otherwise, using the preset abnormal prompt data as the sub-test result of the test statement.
[0097] Optionally, the test image determination unit includes: a first image determination subunit, configured to perform identifier detection on the execution statement in the test window, and when the first identifier and the second identifier are detected, take a screenshot of the execution statement based on the first identifier and the second identifier to obtain a test image; wherein, the first identifier indicates the end of the execution of the test statement; the second identifier indicates that the execution statement is not fully displayed in the test window.
[0098] Optionally, the test image determination unit includes: a second image determination subunit, configured to perform identifier detection on the execution statement in the test window, and when the first identifier is detected and the second identifier is not detected, take a screenshot of the execution statement based on the first identifier to obtain a test image.
[0099] Optionally, the database test module 320 includes: a data filling unit and a file generation unit;
[0100] Wherein, the data filling unit is configured to, for each test text case, use the test text case and the corresponding test image as sub-test data, and fill the sub-test data into a table file based on a target template;
[0101] The file generation unit is configured to use the table file with data filling completed as the target test file.
[0102] The database test device provided by the embodiments of the present invention can execute the database test method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.
[0103] Embodiment 4
[0104] Figure 5 FIG. shows a schematic structural diagram of an electronic device 10 that can be used to implement the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described herein and / or claimed.
[0105] As Figure 5As shown, the electronic device 10 includes at least one processor 11 and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. Among them, the memory stores a computer program executable by the at least one processor. The processor 11 can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0106] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0107] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include but are not limited to a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the database testing method.
[0108] In some embodiments, the database testing method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the database testing method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the database testing method in any other appropriate manner (e.g., by means of firmware).
[0109] The various embodiments of the systems and techniques described above in this document can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0110] The computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs can be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
[0111] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the foregoing.
[0112] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0113] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data server), or a computing system including middleware components (e.g., an application server), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0114] A computing system can include a client and a server. The client and the server are generally far from each other and usually interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0115] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.
[0116] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A database testing method, characterized in that, Including: In response to a test setting operation, determine the database to be tested, the target text test case set, and the file output path; In response to a test start operation, test the database to be tested based on the target text test case set to obtain a target test result, generate a target test file based on the target test result, and output the target test file based on the file output path; Among them, the target text test case set includes at least one test text case; the testing the database to be tested based on the target text test case set to obtain a target test result includes: For each of the test text cases, parse the test text case to determine the test statement corresponding to the test text case, and determine a statement sequence based on at least one of the test statements; For the test statements in the statement sequence, sequentially perform operations of testing the database to be tested based on the test statements to obtain sub-test results, and taking screenshots of the sub-test results to obtain test images; Use at least one of the test images as the target test result.
2. The method according to claim 1, wherein The testing the database to be tested based on the test statement to obtain a sub-test result includes: Determine the statement input focus in the test window, copy the test statement to the test window based on the statement input focus, perform a carriage return operation, and determine the sub-test result of the test statement.
3. The method according to claim 2, characterized in that, The determining the sub-test result of the test statement includes: Detect the statement execution status of the test window based on a status detection period; where the statement execution status includes execution end or statement execution not ended; In the case where the statement execution status is detected as the execution end before the number of cycle detections reaches the detection number threshold, use the execution statement in the test window as the sub-test result corresponding to the test statement; otherwise, use the preset exception prompt data as the sub-test result of the test statement.
4. The method according to claim 3, characterized in that, The taking screenshots of the sub-test result to obtain a test image includes: Perform identifier detection on the execution statement in the test window, and in the case of detecting a first identifier and a second identifier, take a screenshot of the execution statement based on the first identifier and the second identifier to obtain a test image; where the first identifier represents the end of the execution of the test statement; the second identifier represents that the execution statement is not fully displayed in the test window.
5. The method according to claim 3, wherein The taking screenshots of the sub-test result to obtain a test image includes: Perform identifier detection on the execution statement in the test window, and in the case of detecting the first identifier and not detecting the second identifier, take a screenshot of the execution statement based on the first identifier to obtain a test image.
6. The method according to claim 1, wherein The generating a target test file based on the target test result includes: For each of the test text cases, use the test text case and the corresponding test image as sub-test data, and fill the sub-test data into a table file based on a target template; Use the table file with data filling completed as the target test file.
7. A database testing device, characterized in that, Including: A test setting module, configured to determine a database to be tested, a target text test case set, and a file output path in response to a test setting operation; A database test module, configured to test the database to be tested based on the target text test case set in response to a test start operation, obtain a target test result, generate a target test file based on the target test result, and output the target test file based on the file output path; Wherein, the target text test case set includes at least one test text case; the database test module includes: a test statement determination unit, a test image determination unit, and a test result determination unit; Wherein, the test statement determination unit is configured to parse each test text case, determine a test statement corresponding to the test text case, and determine a statement sequence based on at least one of the test statements; The test image determination unit is configured to, for the test statements in the statement sequence, sequentially perform operations of testing the database to be tested based on the test statements to obtain sub-test results, and taking screenshots of the sub-test results to obtain test images; The test result determination unit is configured to use at least one of the test images as the target test result.
8. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the database test method according to any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the database test method according to any one of claims 1-6 when executed by a processor.
Citation Information
Patent Citations
SQL online method and system and electronic equipment
CN114077536A
Automatic test tool construction method, automatic test method and related equipment thereof
CN116974929A
Test report generation method and device, equipment and storage medium
CN117724981A
Method and device for generating test script
CN118606205A