Automatic database application testing method and device based on Bash / Shell under Linux and medium
By using the BASH command to record functions and analyzes the program to generate automated test cases under Linux, the existing tools cannot completely record the operation steps of the command line interface, and achieve a more complete and flexible test case code, which improves the accuracy of the test. And efficiency.
Patent Information
- Application Number
- CN202411486331.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-23
- Publication Date
- 2025-01-21
AI Technical Summary
Existing recording tools cannot fully record the user's operation steps in the command line interface, resulting in the generated test case code being incomplete and flexible enough, affecting the accuracy, reliability, efficiency and effectiveness of the test.
By calling the BASH command under the linux command recording function, the recording and manual testing of the use case, and the test case code generated by the analysis of the program generated by analyzing the program generated, dynamically generates the automated test cases that can be executed.
The generated test case code is more complete and flexible, which improves the accuracy, reliability, efficiency and effect of the test, and can comprehensively cover the operation steps of the command line interface.
Smart Images

Figure CN119336643A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device and medium for automated testing of database applications based on Bash / Shell under Linux. Background Art
[0002] Existing recording tools can only record the user's operation steps, but cannot record the user's input and output, resulting in incomplete generated test case code, affecting the accuracy and reliability of the test. In addition, existing recording tools can only generate fixed test case code, and cannot dynamically generate test case code based on user input and output, resulting in inflexible generated test case code, affecting the efficiency and effectiveness of the test.
[0003] Existing recording tools can only record the user's operation steps in the graphical user interface, but cannot record the user's operation steps in the command line interface, resulting in the generated test case code being incomplete, affecting the test coverage and depth.
[0004] Testing under Liunx usually requires manual test case execution first, and then manually writing automated test cases based on the system's response results and expected results. Summary of the invention
[0005] The embodiments of the present application provide a method, device and medium for automated testing of database applications based on Bash / Shell under Linux, which are used to realize the recording and manual testing of use cases by calling the bash command recording function under Linux, and to generate executable automated test cases by parsing the test case code generated by the program.
[0006] The present application embodiment provides a database application automation testing method based on Bash / Shell under Linux, including:
[0007] Enter a first instruction of a set target use case in a Bash command, and obtain a system response result, wherein the first instruction has no practical meaning and no response result for the Linux system, and is used to indicate basic information of the target use case;
[0008] Obtaining a second instruction input by a user in a Bash command, parsing a use case instruction to be executed according to the input second instruction, and recording a response result or no result of the system, wherein the second instruction is an operation instruction for clarifying the target use case;
[0009] According to the response result or no result of the system, the assertion description information input by the user is obtained, wherein the assertion description information has no practical meaning and influence on the operating system and can be parsed into the assertion processing part of the result in the parsing stage; and
[0010] After the use case is executed, record the relevant operation records;
[0011] Utilize the parser to generate executable scripts for automated test cases based on the recorded relevant operation records.
[0012] Optionally, the first instruction of the set target use case is input in the Bash command so that the first instruction can be parsed into the start information of the target use case in the parsing stage, wherein the start information includes the use case name, the start step, and the use case description.
[0013] Optionally, after the user submits the second instruction, the response time of the system is recorded to generate a timeout parameter of the automation use case according to the response time.
[0014] Optionally, after the use case execution is completed, recording the relevant operation records includes storing the relevant operation records as a record file.
[0015] Optionally, using a parsing program, generating an executable script for an automated test case according to the recorded relevant operation records includes:
[0016] Using a parsing program, reading the record file;
[0017] From the record file, the associated instruction information is filtered out to generate an executable script for the automated test case.
[0018] Optionally, parsing the log file to generate an executable script for an automated test case includes:
[0019] When the log file is parsed and the start instruction of the use case is determined, it is regarded as a new use case;
[0020] When the log file is parsed and it is determined that it is not the start instruction of the use case, it is taken as the execution step of the current use case.
[0021] Optionally, parsing the log file to generate an executable script for an automated test case further includes:
[0022] The recorded response time of the system is read and the timeout parameters of the use case are generated based on the response time.
[0023] An embodiment of the present application also proposes a Bash / Shell-based database application automation testing device under Linux, comprising a processor and a memory, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the steps of the aforementioned Bash / Shell-based database application automation testing method under Linux are implemented.
[0024] The embodiment of the present application further proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned Bash / Shell-based database application automation testing method under Linux are implemented.
[0025] The embodiment of the present application realizes the recording and manual testing of use cases by calling the bash command recording function under Linux, and generates executable automated test cases by parsing the test case code generated by the program.
[0026] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present application. Also, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0028] Figure 1 The following is a basic flow diagram of a Bash / Shell-based database application automation testing method under Linux according to an embodiment of the present application;
[0029] Figure 2 The present invention is a schematic diagram of the process of parsing and generating executable scripts for the automated testing method for database applications based on Bash / Shell under Linux according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0031] The present application embodiment provides a database application automation testing method based on Bash / Shell under Linux, such as Figure 1 As shown, the following steps are included:
[0032] In step S001, the first instruction of the set target use case is input in the Bash command to obtain the system response result, wherein the first instruction has no practical meaning and no response result for the Linux system, and is used to indicate the basic information of the target use case. Before executing the operable use case command in step S001, the name, step sequence and other description information of the target use case are input into the bash command together to ensure that the command has no practical meaning for the operating system, but can be recognized by the parsing program and parsed into the corresponding use case step description and use case name and other information in the automated test case.
[0033] In step S002, the second instruction input by the user in the Bash command is obtained, and the use case instruction to be executed is parsed according to the input second instruction, and the response result or no result of the system is recorded in step S003, wherein the second instruction is an operation instruction to clarify the target use case, and the operation steps have practical significance. The response time of the system can also be further obtained in step S003, so as to generate a timeout parameter based on the response time of the system in subsequent embodiments.
[0034] In some embodiments, the response result of the recording system can be the operation steps of recording the user's bash command to completely record the user's input and output, thereby generating a more complete and accurate test case code.
[0035] In step S004, according to the response result or no result of the system, the assertion description information input by the user is obtained, and the assertion description information has no practical meaning and influence on the operating system, and can be parsed into the assertion processing part of the result in the parsing stage. The specific user can write the description information of the assertion according to the response result or no result of the system, and the assertion description information ensures that it has no practical meaning and influence on the operating system, and the system may prompt an error message without relevant instructions. However, in the parsing stage, the program can parse it into the assertion processing part of the result. For example: resutl=None except=””desc=““. The relevant fields of the assertion information are used to record the assertion value expected by the user. By using commands with no substantial effect to describe the assertion and the part of the operation steps, the corresponding step description and assertion judgment instructions can be generated in the parsing stage, so that the test case code is clearer and easier to read. This can improve the maintainability and readability of the test, making the test case code easier to understand and maintain.
[0036] In step S005, after the use case execution is completed, relevant operation records are recorded.
[0037] In step S006, the parsing program is used to generate an executable script of the automated test case based on the recorded relevant operation records. In step S007, the user can execute the script to replay the test case and put it into other servers or environments to be tested to execute the case script.
[0038] The embodiment of the present application realizes the recording and manual testing of use cases by calling the bash command recording function under Linux, and generates executable automated test cases by parsing the test case code generated by the program.
[0039] In some embodiments, a first instruction of a set target use case is input in a Bash command so that the first instruction can be parsed into start information of the target use case during the parsing phase, wherein the start information includes a use case name, a start step, and a use case description.
[0040] For example, directly inputting a first instruction with a specific description information in the Bash command of Linux, such as: step1casename=initenv desc=initialize environment, the first instruction has no actual meaning and response result for the Linux system, and may prompt an error message such as no relevant instructions. However, the first instruction can be parsed as the start information of the use case in the parsing stage, with the starting step being "step1", the name of the use case being "initenv", and the description of the use case being "initialize environment".
[0041] In some embodiments, after the user submits the second instruction, the response time of the system is recorded to generate a timeout parameter of the automation use case according to the response time.
[0042] When executing the same instruction on different systems (or different configurations of the same system), the response time of the instruction may be different. When executing the use case, the system reads the environment variables of the execution use case to increase or decrease the timeout parameters to adapt to the passability of the use case in different system environments.
[0043] In some embodiments, after the use case execution is completed, recording the relevant operation records includes storing the relevant operation records as a record file.
[0044] In some embodiments, using a parsing program to generate an executable script for an automated test case based on the recorded related operation records includes:
[0045] Using a parsing program, reading the record file;
[0046] From the record file, the associated instruction information is filtered out to generate an executable script for the automated test case. For example, a specific instruction "casename = test_001desc = Initialize environment" is filtered out as the use case name "test_001" of the generated use case, and the use case description is "Initialize environment"; the instruction: "step = "02parallel test datainsertion" expected = "None"" is filtered out as the use case execution step: "02parallel test datainsertion" use case is expected to be "None".
[0047] Specifically, the first instruction in step S001, the second instruction in step S002, assertion information, etc. can be extracted to generate an executable script for the automated test case. By generating test case code through program analysis, the test case code can be dynamically generated according to the user's input and output, so that the generated test case code is more flexible and more adaptable. This can improve the efficiency and effect of the test, making the test more flexible and efficient.
[0048] In some embodiments, Figure 2 As shown, parsing the log file to generate an executable script for automated test cases includes:
[0049] When the log file is parsed and the start instruction of the use case is determined, it is regarded as a new use case;
[0050] When the log file is parsed and it is determined that it is not the start instruction of the use case, it is taken as the execution step of the current use case.
[0051] In some embodiments, Figure 2 As shown, parsing the log file to generate an executable script for automated test cases also includes: reading the recorded system response time, and generating a timeout parameter for the test case based on the response time. When executing the same instruction on different systems (or the same system with different configurations), the response time of the instruction may be different. When executing the test case, the system reads the environment variable of the execution case to increase or decrease the timeout parameter to adapt to the passability of the test case in different system environments.
[0052] The solution of the present application can record not only the user's operation steps, but also the user's input and output by recording the operation steps of bash commands, thereby generating more complete and accurate test case codes. This can greatly improve the accuracy and reliability of the test and avoid test errors caused by incomplete test case codes.
[0053] The method of the present application can not only record the user's operation steps in the graphical user interface, but also record the user's operation steps in the command line interface, so that the generated test case code is more comprehensive and covers a wider range, which can improve the coverage and depth of the test, making the test more comprehensive and thorough.
[0054] This application can greatly reduce the workload of manual testing, improve the efficiency and accuracy of testing, and reduce the cost and risk of testing by generating automated test cases. This has important practical application value for large-scale software development and testing.
[0055] An embodiment of the present application also proposes a Bash / Shell-based database application automation testing device under Linux, comprising a processor and a memory, wherein a computer program is stored on the memory, and when the computer program is executed by the processor, the steps of the aforementioned Bash / Shell-based database application automation testing method under Linux are implemented.
[0056] The embodiment of the present application further proposes a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the aforementioned Bash / Shell-based database application automation testing method under Linux are implemented.
[0057] It should be noted that in the various embodiments of the present application, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0058] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0059] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0060] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A database application automation testing method based on Bash / Shell under Linux, characterized in that: include: Enter a first instruction of a set target use case in a Bash command, and obtain a system response result, wherein the first instruction has no practical meaning and no response result for the Linux system, and is used to indicate basic information of the target use case; Obtaining a second instruction input by a user in a Bash command, parsing a use case instruction to be executed according to the input second instruction, and recording a response result or no result of the system, wherein the second instruction is an operation instruction for clarifying the target use case; According to the response result or no result of the system, the assertion description information input by the user is obtained, wherein the assertion description information has no practical meaning and influence on the operating system and can be parsed into the assertion processing part of the result in the parsing stage; as well as, After the use case is executed, record the relevant operation records; Utilize the parser to generate executable scripts for automated test cases based on the recorded relevant operation records.
2. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 1, characterized in that: The first instruction of the set target use case is input in the Bash command so that the first instruction can be parsed into the start information of the target use case in the parsing stage, wherein the start information includes the use case name, the start step, and the use case description.
3. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 1, characterized in that: After the user submits the second instruction, the response time of the system is recorded to generate a timeout parameter of the automation use case according to the response time.
4. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 3, characterized in that: After the use case execution is completed, recording the relevant operation records includes storing the relevant operation records as a record file.
5. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 4, characterized in that: Using the parser, the executable scripts for generating automated test cases based on the recorded relevant operation records include: Using a parsing program, reading the record file; From the record file, the associated instruction information is filtered out to generate an executable script for the automated test case.
6. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 4, characterized in that: Parsing the log file to generate an executable script for automated test cases includes: When the log file is parsed and the start instruction of the use case is determined, it is regarded as a new use case; When the log file is parsed and it is determined that it is not the start instruction of the use case, it is taken as the execution step of the current use case.
7. The automated testing method for database applications based on Bash / Shell under Linux as claimed in claim 6, characterized in that: Parsing the log file to generate an executable script for automated test cases also includes: The recorded response time of the system is read and the timeout parameters of the use case are generated based on the response time.
8. A database application automation testing device based on Bash / Shell under Linux, characterized in that: The invention comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the steps of the Bash / Shell-based database application automation testing method under Linux as described in any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the Bash / Shell-based database application automation testing method under Linux according to any one of claims 1 to 7 are implemented.