Shell function set testing platform, method, device and storage medium
By building a Shell function set test platform, the test case calls and result analysis are automatically completed, and the problem of low testing efficiency of Shell function sets is solved, improving the testing efficiency and effectiveness.
Patent Information
- Application Number
- CN202211145071.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-09-20
AI Technical Summary
In the prior art, the testing efficiency and effectiveness of the Shell function set are poor, especially when code modification, frequent regression testing is required, resulting in large workload and low efficiency.
Build a Shell function set test platform, including control management components, test case analysis components, automated test components and result analysis components, and automatically complete test case calls, result comparison and analysis. Testers only need to pay attention to the final result report.
It improves the testing efficiency and effectiveness of the Shell function set, reduces labor costs, and realizes the rapid operation of automated testing, regression testing and unit testing.
Smart Images

Figure CN115525546B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing technology, and in particular to a Shell function set testing platform, method, device, and storage medium. Background Art
[0002] A shell function is a reusable script code. This code is pre-written and placed in a designated location, allowing it to be directly called upon use. At any stage of shell function library development, the code is subject to modification. These modifications can introduce new issues or even impact existing functionality. Regression testing or unit testing is necessary to verify the correctness and impact of these modifications. Currently, testing accounts for a significant portion of the development workload, and in extreme cases, regression testing may be required several times daily.
[0003] In the prior art, testers develop scripts to implement partial automated testing of Shell function sets. However, the existing testing methods have poor testing efficiency and effectiveness when testing Shell function sets. Summary of the Invention
[0004] The present application provides a Shell function set testing platform, method, device and storage medium to solve the problem of poor testing efficiency and effectiveness when testing Shell function sets in existing testing methods in the prior art.
[0005] In a first aspect, the present application provides a Shell function set testing platform, the platform comprising: a control management component, a test case parsing component, an automated testing component, and a result analysis component;
[0006] The control management component is used to obtain the function to be tested from the Shell function set and assign the function to be tested to the corresponding test case parsing component;
[0007] The test case parsing component is used to parse the test case description of the function to be tested to obtain a parsing result, and return the parsing result to the control management component; wherein the parsing result includes the test case name and assertion expectation;
[0008] The control management component is used to access the test case library, call the test case that matches the test case name from the test case library according to the test case name, and send the test case to the automated testing component; if the test case library does not contain the test case, add the test case to the test case library;
[0009] An automated testing component is configured to execute the test case, test the function to be tested, obtain a function return value, and return the function return value to the control management component;
[0010] The control management component is used to input the function return value and the assertion expected value into the result analysis component;
[0011] The result analysis component is used to check whether the function return value meets the assertion expected value, generate and output a test result report.
[0012] In a second aspect, the present application provides a Shell function set testing method, which is applied to a Shell function set testing platform. The method includes:
[0013] Get the function to be tested from the Shell function set;
[0014] Parsing the test case description of the function to be tested to obtain a parsing result, wherein the parsing result includes the test case name and assertion expectation;
[0015] Accessing a test case library, and calling a test case that matches the test case name from the test case library according to the test case name;
[0016] Execute the test case, test the function to be tested, and obtain the function return value;
[0017] Check whether the function return value meets the expected assertion value, generate and output a test result report.
[0018] In a third aspect, the present application provides a Shell function set testing device, comprising: a processor, and a memory communicatively connected to the processor;
[0019] The memory stores computer-executable instructions;
[0020] The processor executes the computer-executable instructions stored in the memory to implement the Shell function set testing method as described in the second aspect above.
[0021] Another aspect of the present application is to provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the Shell function set testing method as described in the second aspect above.
[0022] Another aspect of the present application is to provide a computer program product, including a computer program, which, when executed by a processor, implements the Shell function set testing method as described in the second aspect above.
[0023] The Shell function set testing platform, method, device, and storage medium provided in this application can analyze and execute all the functions to be tested in a function set file by obtaining the functions to be tested from the Shell function set. By calling and supplementing the test case library, the test case reuse rate is increased, thereby improving testing efficiency and effectiveness. In addition, the Shell function set testing platform automatically completes steps such as calling and completing test cases, comparing and analyzing test results, etc., so testers only need to pay attention to the final test result report. Automated testing avoids unknown test coverage points in the code, and tests can be quickly run anytime and anywhere, including automated testing, regression testing, and unit testing, thereby further improving testing efficiency and effectiveness. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0025] Figure 1 This is a diagram showing the structure of a Shell function set test platform according to an exemplary embodiment of the present application;
[0026] Figure 2 This is a structural diagram of a Shell function set test platform shown in another exemplary embodiment of the present application;
[0027] Figure 3 This is a flowchart of a Shell function set testing method shown in an exemplary embodiment of the present application;
[0028] Figure 4 This is a flowchart of a Shell function set testing method shown in another exemplary embodiment of the present application;
[0029] Figure 5 This is a structural diagram of a Shell function set testing device shown in an exemplary embodiment of the present application.
[0030] The above drawings illustrate specific embodiments of the present application, which will be described in more detail below. These drawings and the textual description are not intended to limit the scope of the present application in any way, but rather to illustrate the concepts of the present application to those skilled in the art by reference to specific embodiments. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0032] The following first explains the terms involved in this application:
[0033] Automatic testing refers to the use of electronic computers to control the measurement process and process data until the results are given.
[0034] Unit testing involves checking and verifying the smallest testable unit in software. The meaning of "unit" in unit testing is often determined based on the specific situation. For example, in the context of a Shell function, "unit" refers to a single function. A unit is the smallest functional module to be tested, and unit testing is the lowest level of testing performed during software development. Independent units of software are tested in isolation from the rest of the program.
[0035] Regression testing involves retesting the code after a code modification to confirm that the modification has not introduced new errors or caused errors in other code. Regression testing can significantly reduce the costs of system testing, maintenance, and upgrades.
[0036] A test case is a description of a test task for a specific software product, reflecting the test plan, method, technique and strategy.
[0037] An assertion is a type of first-order logic in a program, such as a logical statement that determines whether the result is true or false. The purpose of an assertion is to express and verify the results expected by the software developer.
[0038] Comments are explanations and descriptions of code, intended to make it easier for people to understand the code. When writing a program, a programmer adds explanations or hints to a statement, program section, function, etc., improving the readability of the code. Comments are intended solely for readability and are not interpreted by the computer.
[0039] In the prior art, the code may be modified at any stage of shell function set file development. Code modification may be due to the discovery of errors and subsequent modifications, or it may be due to the addition of new functional requirements. In either case, new problems may arise and even affect the original functions. Therefore, whenever the program changes, the existing functions must be retested to determine whether the modifications have achieved the intended purpose and to check whether the modifications have damaged the original normal functions. At the same time, new test cases need to be added to test the new or modified functions. Testing is required to verify the correctness of the modifications and their impact. Testing includes automated testing, regression testing, and unit testing. Currently, testing accounts for a large proportion of the workload in the entire development process. In extreme cases, regression testing is required several times a day.
[0040] In the prior art, testers develop scripts to implement partial automated testing of shell function sets. However, the existing testing methods have poor testing efficiency and effectiveness when testing shell function sets.
[0041] In response to the above technical problems, this application proposes the following technical ideas: by constructing a Shell function set testing platform, setting up control management components, test case parsing components, automated testing components and result analysis components in the platform, the platform automatically completes the steps of calling and improving test cases, comparing and analyzing test results, etc., and testers only need to pay attention to the final test result report. In addition, automatic testing avoids unknown test coverage points in the code, and tests can be run quickly anytime and anywhere, including automated testing, regression testing and unit testing, thereby improving testing efficiency and effectiveness.
[0042] The following specific embodiments describe in detail the technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0043] Figure 1 This is a diagram showing the structure of the Shell function set test platform according to an exemplary embodiment of the present application. Figure 1 As shown, the Shell function set test platform 10 is provided with a control management component 101 , a test case parsing component 102 , an automated test component 103 and a result analysis component 104 .
[0044] The control management component 101 is used to obtain the function to be tested from the Shell function set and allocate the function to be tested to the corresponding test case parsing component 102.
[0045] In this embodiment, the test cases of the unit test are written in the comments of the Shell function set.
[0046] The test case parsing component 102 is used to parse the test case description of the function to be tested to obtain a parsing result, and return the parsing result to the control management component 101; wherein the parsing result includes the test case name and the assertion expected value;
[0047] In this embodiment, the test case description gives a description of the test task for a specific software product, reflecting the test plan, method, technology and strategy. The test case name is the name of the test case. The purpose of naming the test case is to distinguish the use case verification points and the use case functions. A good use case name allows people to clearly understand the function of the use case at a glance. The assertion expected value is the result expected by the tester. An assertion is a first-order logic in a program, such as a logical judgment expression with a true or false result. The purpose is to express and verify the result expected by the software developer - when the program executes to the assertion position, the corresponding assertion should be true. If the assertion is not true, the program will terminate execution and give an error message.
[0048] In one embodiment of the present application, the test case parsing component is specifically used to:
[0049] According to the preset parsing template, the test case description is sequentially subjected to syntax and parameter compliance checks, value validity checks, and value conversions to obtain the parsing results, which are then returned to the control management component. The parsing template includes the syntax specifications and parameter value ranges of the test case description.
[0050] In this embodiment, syntax and parameter compliance checking refers to checking the syntax and parameter compliance of user-entered data. Value validity checking is a check of the validity of user-entered data to prevent incorrect and illegal data from entering the database, which is a common requirement of business systems. Value conversion refers to converting user-entered data.
[0051] In this embodiment, the syntax specifications and parameter value ranges of the test case description can be set according to actual test requirements and are not specifically limited in this application.
[0052] The control management component 101 is used to access the test case library, call the test case with the test case name from the test case library according to the test case name, and send the test case to the automated testing component 103; if the test case library does not contain the test case, the test case is added to the test case library.
[0053] In this embodiment, the test case library is used to store test cases, and calling test cases from the test case library can simplify the test case calling process.
[0054] The automated testing component 103 is used to execute test cases, test the function to be tested, obtain test results, and return the test results to the control management component 101.
[0055] In one embodiment of the present application, the test case parsing component 102 parses the test case description of the function to be tested to obtain a parsed result that further includes: a test function calling method.
[0056] The automated testing component 103 executes the test case, tests the function to be tested according to the test function calling method, obtains the function return value, and returns the function return value to the control management component 101.
[0057] In this embodiment, the test function calling method provides a way to call a function. For example, the three methods of calling a function in JavaScript include: calling a function directly, calling a function with the call() method, and calling a function with the apply() method.
[0058] The control management component 101 is used to input the function return value and the assertion expected value into the result analysis component 104 .
[0059] The result analysis component 104 is used to check whether the function return value meets the assertion expected value, generate and output a test result report.
[0060] In this embodiment, the result analysis component 104 compares the function return value with the assertion expected value, generates and outputs a test result report. The function return value is the execution result obtained after testing the function to be tested, and the assertion expected value is the result expected by the tester. The test result is the result of the program's logical judgment on whether the function return value meets the assertion expected value, and is also the final conclusion of the test. The test result includes three states: success, failure, and exception. Among them, success means that the logical judgment is true, failure means that the logical judgment is false, and exception means that the function has a fatal error, resulting in it not being able to run normally. The function return value and assertion expected value are an explanation of the test results, the purpose of which is to allow the tester to more intuitively understand the problems existing in the function.
[0061] In summary, the Shell function set testing platform provided in this embodiment can analyze and execute all the functions to be tested in a function set file by obtaining the functions to be tested from the Shell function set. By calling and supplementing the test case library, the test case reuse rate is increased, thereby improving testing efficiency and effectiveness. Furthermore, the Shell function set testing platform automatically completes steps such as calling and completing test cases, and comparing and analyzing test results. Testers only need to focus on the final test result report. Automated testing avoids unknown test coverage points in the code, allowing for rapid execution of tests anytime, anywhere, including automated testing, regression testing, and unit testing, further enhancing testing efficiency and effectiveness.
[0062] Figure 2 This is a structural diagram of a Shell function set test platform shown in yet another exemplary embodiment of the present application. Figure 2 The Shell function set test platform shown is in Figure 1 Other components are added on the basis of Figure 2 As shown, the Shell function set test platform 20 is provided with a control management component 101 , a test case parsing component 102 , an automated testing component 103 , a result analysis component 104 and an auxiliary program component 105 .
[0063] Figure 1 In the Shell function set test platform shown, the test case parsing component 102 parses the test case description of the function to be tested to obtain a parsing result which also includes: prerequisites. The prerequisites specify what environment initializations need to be performed before testing the function to be tested.
[0064] In this embodiment, the auxiliary program component 105 is used to initialize the test environment according to the prerequisites and send the result of the initialization completion to the control management component;
[0065] After the control management component 101 receives the initialization completion result sent by the auxiliary program component 105, it accesses the test case library according to the initialization completion result, calls the test case that matches the test case name from the test case library according to the test case name, and sends the test case to the automated test component 103.
[0066] In one embodiment of the present application, the auxiliary program component 105 includes a main program, a mapping file, and multiple auxiliary programs. The auxiliary program component 105 is specifically used to:
[0067] The main program receives the prerequisites passed in by the control management component 101 , parses the mapping file according to the prerequisites, confirms the auxiliary program to be called according to the parsing result, completes the test environment initialization, and sends the initialization completion result to the control management group 101 .
[0068] Among them, the mapping file maintains multiple key-value pairs (key is the globally unique ID of the auxiliary program, and value is the name of the auxiliary program), which simplifies the calling logic of the auxiliary program and enables hot plugging of the auxiliary program.
[0069] In this embodiment, the main program is where the program starts running, and the auxiliary program refers to the program needed to assist the main program in completing a certain operation. It is a collection of a series of common function functions. During the testing process, these auxiliary programs mainly complete the test environment preparation and file analysis, etc.
[0070] Exemplarily, the auxiliary programs include: a file and directory preparation auxiliary program, a process and thread preparation auxiliary program, a network and connection preparation auxiliary program, a random log file preparation auxiliary program, and a random data file preparation auxiliary program.
[0071] In one embodiment of the present application, the automated testing component 103 is further configured to feed back to the control management component 101 any exceptions that occur during the testing of the function to be tested.
[0072] In one embodiment of the present application, after the automated testing component 103 feeds back the exception to the control management component 101, the control management component 101 is further specifically used to: determine the type of the exception, and when the exception is determined to be an environmental exception, start the auxiliary program component 105 to initialize the test environment according to the prerequisites.
[0073] When an environment exception occurs during the testing of the function to be tested, it means that the test environment at this time does not meet the test conditions and needs to be initialized according to the information given by the prerequisites.
[0074] In summary, the Shell function set testing platform provided in this embodiment automatically completes the initialization of the test environment through the auxiliary program component, so that the test environment meets the test requirements of the function and effectively reduces the labor cost of the test.
[0075] Figure 3 The flowchart of the Shell function set testing method shown in an exemplary embodiment of the present application. Figure 3 As shown, the Shell function set test method is applied to Figure 1 The Shell function set test platform shown includes the following steps:
[0076] S301, obtaining a function to be tested from a Shell function set;
[0077] S302: Parse the test case description of the function to be tested to obtain a parsing result, wherein the parsing result includes the test case name and assertion expectation;
[0078] S303, access the test case library, and call the test case that matches the test case name from the test case library according to the test case name;
[0079] S304: Execute the test case to test the function to be tested and obtain the function return value;
[0080] S305: Check whether the function return value meets the assertion expected value, generate and output a test result report.
[0081] Figure 4 FIG. 1 is a flowchart of a Shell function set testing method shown in another exemplary embodiment of the present application. Figure 4 As shown, the Shell function set testing method provided by this application is applied to Figure 2 The Shell function set test platform shown includes:
[0082] S401. Obtain a function to be tested from a Shell function set.
[0083] S402. According to the preset parsing template, the test case description of the test function is sequentially subjected to syntax and parameter compliance checks, value validity checks, and value conversions to obtain a parsing result, wherein the parsing template includes the syntax specifications and parameter value ranges of the test case description, and the parsing result includes prerequisites, test case names, test function calling methods, and assertion expectations.
[0084] S403: receiving prerequisites through the main program, parsing the mapping file according to the prerequisites, confirming the auxiliary program to be called according to the parsing result, completing the test environment initialization, and obtaining a result of initialization completion.
[0085] S404: Access the test case library and call the test case that matches the test case name from the test case library according to the test case name. If the test case is not included in the test case library, add the test case to the test case library.
[0086] S405: Execute the test case, test the function to be tested according to the test function calling method, and obtain the function return value.
[0087] S406: Feedback the exceptions that occur during the test of the function to be tested, and determine the type of the exception. If the exception is an environmental exception, initialize the test environment according to the prerequisites. If no exception occurs, directly execute S407.
[0088] S407: Check whether the function return value meets the assertion expected value, generate and output a test result report.
[0089] Figure 5This is a structural diagram of a Shell function set testing device shown in an exemplary embodiment of the present application.
[0090] like Figure 5 As shown, the Shell function set testing device provided in this embodiment includes:
[0091] Memory 51;
[0092] processor 52; and
[0093] computer programs;
[0094] The computer program is stored in the memory 51 and is configured to be executed by the processor 52 to implement any of the above Shell function set testing methods.
[0095] This embodiment also provides a computer-readable storage medium having a computer program stored thereon.
[0096] The computer program is executed by a processor to implement any one of the Shell function set testing methods described above.
[0097] This embodiment further provides a computer program, including a computer program, which implements the Shell function set testing method as described in any one of the above items when executed by a processor.
[0098] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0099] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0100] It should be understood that the present application is not limited to the exact structure described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A Shell function set testing platform, characterized in that: The platform includes: a control management component, a test case parsing component, an automated testing component and a result analysis component; The control management component is used to obtain the function to be tested from the Shell function set and assign the function to be tested to the corresponding test case parsing component; The test case parsing component is used to parse the test case description of the function to be tested to obtain a parsing result, and return the parsing result to the control management component; wherein the parsing result includes the test case name and the assertion expected value; The control management component is used to access the test case library, call the test case that matches the test case name from the test case library according to the test case name, and send the test case to the automated testing component; if the test case library does not contain the test case, add the test case to the test case library; An automated testing component is configured to execute the test case, test the function to be tested, obtain a function return value, and return the function return value to the control management component; The control management component is used to input the function return value and the assertion expected value into the result analysis component; A result analysis component is used to check whether the function return value meets the assertion expected value, generate and output a test result report; The platform further includes: an auxiliary program component, the auxiliary program component including a main program, a mapping file and a plurality of auxiliary programs; the parsing result further includes: prerequisites; The auxiliary program component is specifically used to: The main program receives the prerequisites passed in by the control management component, parses the mapping file according to the prerequisites, confirms the auxiliary program to be called according to the parsing result, and the auxiliary program completes the test environment initialization and sends the initialization completion result to the control management group.
2. The Shell function set test platform according to claim 1, characterized in that: The test case parsing component is specifically used to: Performing syntax and parameter compliance checks, value validity checks, and value conversion on the test case description in sequence according to a preset parsing template to obtain a parsing result, and returning the parsing result to the control management component; The parsing template includes the syntax specification and parameter value range of the test case description.
3. The Shell function set test platform according to claim 1, characterized in that: The analysis results also include: a test function calling method; The automated testing component is specifically used for: Execute the test case, test the function to be tested according to the test function calling method, obtain the function return value, and return the function return value to the control management component.
4. The Shell function set testing platform according to any one of claims 1 to 3, characterized in that: The control management component is specifically used to access the test case library according to the result of initialization completion, call the test case that meets the test case name from the test case library according to the test case name, and send the test case to the automated testing component.
5. The Shell function set test platform according to claim 4, characterized in that: The automated testing component is also used to: Feedback the abnormalities that occur during the testing of the function to be tested to the control management component.
6. The Shell function set test platform according to claim 5, characterized in that: The control management component is further specifically configured to: The type of the exception is determined, and when it is determined that the exception is an environmental exception, the auxiliary program component is started to initialize the test environment according to the prerequisites.
7. A Shell function set testing method, characterized in that: The Shell function set test platform applied to any one of claims 1 to 6 comprises: Get the function to be tested from the Shell function set; Parsing the test case description of the function to be tested to obtain a parsing result, wherein the parsing result includes the test case name and assertion expectation; Accessing a test case library, and calling a test case that matches the test case name from the test case library according to the test case name; Execute the test case, test the function to be tested, and obtain the function return value; Check whether the function return value meets the expected assertion value, generate and output a test result report; Wherein, the parsing result further includes: a prerequisite; before accessing the test case library and calling a test case that matches the test case name from the test case library according to the test case name, the method further includes: The prerequisite is received by the main program, a mapping file is parsed according to the prerequisite, the auxiliary program to be called is confirmed according to the parsing result, the auxiliary program completes the initialization of the test environment, and obtains a result of initialization completion.
8. The method according to claim 7, characterized in that The parsing of the test case description of the function to be tested to obtain the parsing result includes: According to the preset parsing template, the test case description is sequentially subjected to syntax and parameter compliance checks, value legitimacy checks and value conversions to obtain a parsing result, wherein the parsing template includes the syntax specifications and parameter value ranges of the test case description.
9. The method according to claim 7, characterized in that The analysis results also include: a test function calling method; The executing the test case, testing the function to be tested, and obtaining a function return value includes: Execute the test case, test the function to be tested according to the test function calling method, and obtain the function return value.
10. The method according to claim 7, characterized in that The accessing of the test case library and calling a test case that matches the test case name from the test case library according to the test case name includes: The test case library is accessed according to the result of the initialization completion, and the test case that matches the test case name is called from the test case library according to the test case name.
11. The method according to claim 10, characterized in that After executing the test case and testing the function to be tested, the method further includes: Feedback is provided for exceptions that occur during the testing of the function to be tested, and the type of the exception is determined. When it is determined that the exception is an environmental exception, the test environment is initialized according to the prerequisites.
12. A Shell function set testing device, characterized in that: include: a processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 7 to 11.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 7 to 11 when executed by a processor.
14. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 7 to 11 when being executed by a processor.
Citation Information
Patent Citations
Test case generation method and device, server and storage medium
CN112286784A
Test case generation and test method and system and medium
CN115061912A