A method, device and storage medium for generating a test script based on DSL statement parsing
By parsing DSL statements to generate test scripts, the problems of insufficient utilization of production failures and loss of experience due to personnel changes are solved. This enables the generation of automated test scripts and the supplementation of the test case library, thereby improving testing efficiency.
Patent Information
- Application Number
- CN202310031116.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-10
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-01-10
AI Technical Summary
In existing technologies, the feedback value of production failures and typical failures is not fully utilized, personnel changes lead to the loss of experience, and there is a lack of automated test script generation methods.
By parsing the DSL statements of the control system, corresponding conditional entities are generated, and test scripts that closely match the business scenario are automatically generated. Test cases are then generated using the test scripts and automatically added to the test case library.
It has achieved automated test script generation, reduced manual analysis and repetitive work, improved testing efficiency, and solved the problems of insufficient utilization of faults and loss of personnel experience.
Smart Images

Figure CN116028366B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of function test, and particularly relates to a method and device for generating a test script based on DSL statement analysis and a storage medium. BACKGROUND
[0002] A DSL (Domain-Specific Language) statement is a special language provided by Elasticsearch for defining queries based on JSON (JavaScript Object Notation). In the test of the provided SDK for adding, deleting, modifying and inquiring, the query class API scene is mainly tested by manually reading API documents, simulating query conditions and then splicing corresponding scenes.
[0003] Currently, the feedback value of production faults and typical defects is fed back to the improvement process of quality assurance through personnel analysis sharing and manual supplement of the use case library. However, the production faults or typical faults are not fully utilized, and the experience will be lost due to personnel changes. SUMMARY
[0004] Therefore, the application provides a method and device for generating a test script based on DSL statement analysis and a storage medium. The test script highly consistent with business scenes is automatically generated by automatically capturing and analyzing business DSL statements, which helps to automatically generate related use cases and supplement the use case library through analyzing fault or typical fault reports. The problem that the production faults or typical faults are not fully utilized and the experience is lost due to personnel changes is solved.
[0005] To achieve the above object, the application adopts the following technical solutions:
[0006] In a first aspect, the application provides a method for generating a test script based on DSL statement analysis, which comprises the following steps:
[0007] acquiring the DSL statement actually run by a control system; generating a corresponding condition entity according to different conditions of the DSL statement; generating a corresponding test script according to the condition entity; generating a test case by using the test script.
[0008] Further, the DSL statement comprises a filter query statement and a query statement.
[0009] Further, the step of generating a corresponding condition entity according to different conditions of the DSL statement comprises:
[0010] If the DSL sentence is a filter query sentence, the filter query sentence includes an exact match condition, a multi-item match condition and a range filter condition, and corresponding condition entities are generated according to different conditions of the filter query sentence; if the DSL sentence is a query sentence, the query sentence includes a complete match condition, a reverse match condition, at least one match query condition and a filter condition, and corresponding condition entities are generated according to different conditions of the query sentence.
[0011] Further, the generating of the corresponding condition entities according to different conditions of the filter query sentence includes:
[0012] If the condition is an exact match condition, an attribute of the exact match condition is generated in the condition entity; if the condition is a multi-item match condition, an attribute of the multi-item match condition is generated in the condition entity; if the condition is a range filter condition, an attribute of the range filter condition is generated in the condition entity.
[0013] Further, the generating of the corresponding condition entities according to different conditions of the query sentence includes:
[0014] If the condition is a complete match condition, an attribute of the complete match condition is generated in the condition entity; if the condition is a reverse match condition, an attribute of the reverse match condition is generated in the condition entity; if the condition is at least one match query condition, an attribute of the at least one match query condition is generated in the condition entity; if the condition is a filter condition, an attribute of the filter condition is generated in the condition entity.
[0015] Further, the method further includes:
[0016] uploading the test script generated from the test case to the control system.
[0017] In a second aspect, the application provides a device for generating a test script based on DSL sentence analysis, and the device includes:
[0018] a obtaining unit configured to obtain the DSL sentence actually run by a control system;
[0019] a generating unit configured to generate corresponding condition entities according to different conditions of the DSL sentence, and further configured to generate a corresponding test script based on the condition entities, and further configured to generate a test case by using the test script.
[0020] In a third aspect, the application provides a device for generating a test script based on DSL sentence analysis, and the device includes:
[0021] a processor; and a memory configured to store processor-executable instructions;
[0022] The processor is configured to execute the method in the first aspect or any one of the implementation manners of the first aspect.
[0023] In a fourth aspect, the present application provides a storage medium, wherein the storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of a device for generating a test script based on DSL statement parsing, the device for generating a test script based on DSL statement parsing can execute the method in the first aspect or any one of the implementation manners of the first aspect.
[0024] The present application has at least the following beneficial effects:
[0025] According to the present application, the DSL statement of the actual operation of the control system is obtained, the corresponding condition entity is generated according to different conditions of the DSL statement, the corresponding test script is generated according to the condition entity, and the test case is generated by using the test script. By automatically capturing the business DSL statement and automatically generating the test script highly consistent with the business scenario, it is helpful to automatically generate the related use case and supplement to the use case library by analyzing the fault or typical fault report, so as to help the quality assurance personnel to draw experience. The disadvantages of insufficient utilization of production faults or typical faults and loss of experience due to personnel changes are solved.
[0026] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiment or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor.
[0028] Figure 1 is a schematic diagram of a method for generating a test script based on DSL statement parsing provided by the present disclosure.
[0029] Figure 2 is a flowchart of a method for generating a test script based on DSL statement parsing according to an exemplary embodiment.
[0030] Figure 3 is a flowchart of a method for generating a test script based on DSL statement parsing according to an exemplary embodiment.
[0031] Figure 4 is a flowchart of a method for generating a test script based on DSL statement parsing according to an exemplary embodiment.
[0032] Figure 5is a flow chart of a method for generating a test script based on DSL statement parsing according to an exemplary embodiment.
[0033] Figure 6 is a block diagram of an apparatus for generating a test script based on DSL statement parsing according to an exemplary embodiment.
[0034] Figure 7 is a structural schematic diagram of an application embodiment of an electronic device of the present application.
[0035] Figure 8 is a structural schematic diagram of an embodiment of an electronic device of the present disclosure. DETAILED DESCRIPTION
[0036] In order to make the purposes, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described in detail below. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work belong to the scope of protection of the present application.
[0037] The embodiments provided by the present disclosure are applied to the scene of parsing fault or typical fault report, automatically generating related use cases and supplementing to the use case library, etc.
[0038] At present, the feedback value of production fault and typical defect is fed back to the improvement process of quality assurance in the form of personnel analysis sharing and manual supplement of use case library, but the disadvantage is that production fault or typical fault is not fully utilized and experience will be lost due to personnel change.
[0039] Figure 1 is a schematic diagram of a method for generating a test script based on DSL statement parsing provided by an embodiment of the present disclosure. As shown in Figure 1 , the DSL statement actually run by online business is obtained through a computer program, the corresponding entity is generated by matching different conditions, the corresponding test script is generated by reassembling according to the structure of the DSL statement, and the script is automatically uploaded to the version control system.
[0040] In the embodiments of the present disclosure, Elasticsearch provides a complete query DSL based on JSON to define queries. The query DSL is regarded as an Abstract Syntax Tree (AST) of a query, which is composed of two kinds of clauses, leaf query clauses and composite query clauses. A specific value is searched for in a leaf query clause in a certain field, such as a match, term or range query, which can be used by itself. A composite query clause wraps other leaf queries or composite queries and is used to combine multiple queries in a logical way, such as a bool or dis_max query, or to change its behavior, such as a constant_score query. The behavior of a query clause will be different depending on whether it is used in a query context or a filter context. The operations performed by a query are different in the Query query context and the Filter filter context.
[0041] Referring to Figure 2 , Figure 2 is a flowchart of a method for generating a test script based on a DSL statement according to an exemplary embodiment, and the method comprises the following steps:
[0042] In step S11, a DSL statement actually run by a control system is acquired.
[0043] In step S12, a corresponding condition entity is generated according to different conditions of the DSL statement.
[0044] In step S13, a corresponding test script is generated according to the condition entity.
[0045] In step S14, a test case is generated by using the test script.
[0046] In the embodiments of the present disclosure, the control system can be any industrial software control system, including a logistics management system and the like.
[0047] In the embodiments of the present disclosure, a Domain Specific Language (DSL) is a computer language specially designed to solve a certain type of task. The working process of a DSL is generally to parse a "DSL script" to obtain a "semantic model", and then to generate a simple text file, such as source code, a database script or the like, by using the "semantic model".
[0048] In the embodiments of the present disclosure, a corresponding condition entity is generated according to different conditions of the DSL statement. The conditions of the DSL statement include a filter query statement and a query statement, the filter query statement is a Filter DSL statement, and the query statement is a Query DSL statement.
[0049] Referring to Figure 3 ,Figure 3 is a flow chart of a method for generating a test script based on DSL statement parsing according to an exemplary embodiment, which comprises the following steps:
[0050] In step S21, different condition entities are generated according to different conditions of the DSL statement.
[0051] In the embodiment of the present disclosure, the DSL statement includes a filter query statement and a query statement, the filter query statement is a Filter DSL statement, and the query statement is a Query DSL statement. The query DSL is regarded as an abstract syntax tree (AST) of a query, which is composed of two kinds of clauses. Leaf query clause: the leaf query clause finds a specific value in a certain field, such as match, term or range query, and these queries can be used by themselves. Compound query clause: the compound query clause wraps other leaf queries or compound queries, and is used to combine multiple queries in a logical way, such as bool or dis_max query; or change its behavior, such as constant_score query. The behavior of the query clause will be different, depending on whether they are used in the query context or the filter context. The operations performed by the query in the Query query context and the Filter filter context are different.
[0052] In step S22a, if the DSL statement is a filter query statement, the filter query statement includes an exact match condition, a multi-item match condition and a range filter condition, and different condition entities are generated according to different conditions of the filter query statement.
[0053] In the embodiment of the present disclosure, the filter query statement, i.e., the Filter DSL statement, includes an exact match condition, a multi-item match condition and a range filter condition. The exact match condition is Term, the multi-item match condition is Terms, and the range filter condition is Range, and different condition entities are generated according to different conditions of the query statement.
[0054] In step S22b, if the DSL statement is a query statement, the query statement includes a complete match condition, a reverse match condition, at least one match query condition and a filter condition, and different condition entities are generated according to different conditions of the query statement.
[0055] In the embodiment of the present disclosure, the query statement, i.e., the Query DSL statement, includes a complete match condition, a reverse match condition, at least one match query condition and a filter condition. The complete match condition is Must, the reverse match condition is Mustnot, the at least one match query condition is Should, and the filter condition is Filter, and different condition entities are generated according to different conditions of the query statement.
[0056] Please refer to Figure 4 , Figure 4 is a flow chart of a method for generating a test script based on DSL statement analysis according to an exemplary embodiment, which comprises the following steps:
[0057] Step S31, generating a corresponding condition entity according to different conditions of the filter query statement;
[0058] In the embodiment of the present disclosure, the filter query statement, i.e. the Filter DSL statement, comprises an exact match condition, a multi-item match condition and a range filter condition. The exact match condition is Term, the multi-item match condition is Terms and the range filter condition is Range. The corresponding condition entity is generated according to different conditions of the query statement.
[0059] Step S32a, if the condition is the exact match condition, an attribute of the exact match condition is generated in the condition entity;
[0060] In the embodiment of the present disclosure, the exact match condition is the equal value query term, and the term is mainly used for the exact match of various values, such as numbers, dates, Boolean values or not_analyzed string, i.e. the text data type without analysis, such as query according to the mobile phone number.
[0061] In an embodiment, if the condition is the exact match condition Term, the attribute of the exact match condition is generated in the condition entity, i.e. the attribute of @Filter(queryType=QueryType.TERM,term=@Term) is generated in the condition entity.
[0062] Step S32b, if the condition is the multi-item match condition, an attribute of the multi-item match condition is generated in the condition entity;
[0063] In the embodiment of the present disclosure, the terms filter is similar to the term, but the terms allow to specify multiple match conditions. If multiple values are specified for a field, the document needs to be matched together.
[0064] In an embodiment, if the condition is the multi-item match condition Terms, the attribute of the multi-item match condition is generated in the condition entity, i.e. the attribute of @Filter(queryType=QueryType.TERMS,terms=@Terms) is generated in the condition entity.
[0065] Step S32c, if the condition is the range filter condition, an attribute of the range filter condition is generated in the condition entity.
[0066] In the embodiments of the present disclosure, the range filtering condition is a range query range, which can be understood as a > or < symbol in SQL, and the range operator includes gt, gte, lt and lte, where gt is greater than, lt is less than, gte is greater than or equal to, and lte is less than or equal to.
[0067] In an embodiment, if the filtering condition is a range Range, an attribute of the range filtering condition is generated in the condition entity, that is, an attribute of @Filter (range = @Range) is generated in the condition entity.
[0068] Referring to Figure 5 , Figure 5 is a flowchart of a method for generating a test script based on a DSL statement according to an exemplary embodiment, and the method includes the following steps:
[0069] In step S41, corresponding condition entities are generated according to different conditions of the query statement.
[0070] In the embodiments of the present disclosure, the query statement, that is, the Query DSL statement, includes a complete matching condition, a reverse matching condition, at least one matching query condition and a filtering condition. The complete matching condition is Must, the reverse matching condition is Mustnot, the at least one matching query condition is Should, and the filtering condition is Filter. Corresponding condition entities are generated according to different conditions of the query statement.
[0071] In step S42a, if the condition is a complete matching condition, an attribute of the complete matching condition is generated in the condition entity.
[0072] In the embodiments of the present disclosure, a combined query Bool can be used to combine the Boolean logic of the query results of multiple filtering conditions, and it includes the following operators: Must is the complete matching of multiple query conditions, which is equivalent to the logical "and". Mustnot is the opposite matching of multiple query conditions, which is equivalent to the logical "not". Should is at least one query condition matching, which is equivalent to the logical "or".
[0073] In an embodiment, if the condition is a complete matching condition Must, an attribute of the complete matching condition is generated in the condition entity, that is, an attribute of @Must is generated in the condition entity.
[0074] In step S42b, if the condition is a reverse matching condition, an attribute of the reverse matching condition is generated in the condition entity.
[0075] In an embodiment, if the condition is a reverse matching condition Must not, an attribute of the reverse matching condition is generated in the condition entity, that is, an attribute of @Must not is generated in the condition entity.
[0076] Step S42c, if at least one matching query condition, then generate the attribute of at least one matching query condition in the condition entity;
[0077] In an embodiment, if at least one matching query condition Should, then generate the attribute of at least one matching query condition in the condition entity, that is, generate the attribute of @Should in the condition entity.
[0078] Step S42d, if a filter condition, then generate the attribute of the filter condition in the condition entity.
[0079] In an embodiment, if a filter condition Filter, then generate the attribute of the filter condition in the condition entity, that is, generate the attribute of @Filter in the condition entity.
[0080] According to the scheme, the DSL statement actually run by the control system is obtained, the corresponding condition entity is generated according to different conditions of the DSL statement, the corresponding test script is generated according to the condition entity analysis, and the test case is generated by using the test script. By automatically capturing the business DSL statement and automatically generating the test script highly consistent with the business scenario, it is helpful to automatically generate the related use case and supplement to the use case library by analyzing the fault or typical fault report, and to remind the quality assurance personnel to absorb experience by message pushing. It can also solve the problem of insufficient utilization of production faults or typical faults, and the loss of experience due to personnel changes; reduce the repetitive work of manually analyzing the DSL statement and writing the script, thereby improving the test efficiency. At the same time, the high dependence of test analysis design on personnel knowledge reserve and practical experience is decoupled.
[0081] Figure 6 Fig. 100 is a device block diagram for generating a test script based on DSL statement analysis according to an exemplary embodiment. Referring to Figure 6 The device includes an acquisition unit 101 and a generation unit 102.
[0082] The acquisition unit 101 is configured to acquire the DSL statement actually run by the control system.
[0083] The generation unit 102 is configured to generate the corresponding condition entity according to different conditions of the DSL statement, to generate the corresponding test script according to the condition entity analysis, and to generate the test case by using the test script.
[0084] In an embodiment, the generation unit 102 generates the corresponding condition entity according to different conditions of the DSL statement in the following manner:
[0085] If the DSL statement is a filter query statement, the filter query statement includes an exact match condition, a multi-item match condition and a range filter condition, and corresponding condition entities are generated according to different conditions of the filter query statement; if the DSL statement is a query statement, the query statement includes a complete match condition, a reverse match condition, at least one match query condition and a filter condition, and corresponding condition entities are generated according to different conditions of the query statement.
[0086] In an embodiment, the generating unit 102 generates corresponding condition entities according to different conditions of the filter query statement in the following manner:
[0087] If it is an exact match condition, an attribute of the exact match condition is generated in the condition entity; if it is a multi-item match condition, an attribute of the multi-item match condition is generated in the condition entity; if it is a range filter condition, an attribute of the range filter condition is generated in the condition entity.
[0088] In an embodiment, the generating unit 102 generates corresponding condition entities according to different conditions of the query statement in the following manner:
[0089] If it is a complete match condition, an attribute of the complete match condition is generated in the condition entity; if it is a reverse match condition, an attribute of the reverse match condition is generated in the condition entity; if it is at least one match query condition, an attribute of the at least one match query condition is generated in the condition entity; if it is a filter condition, an attribute of the filter condition is generated in the condition entity.
[0090] In an embodiment, the apparatus further comprises an uploading unit 103:
[0091] The uploading unit 103 is configured to upload the test script generated test case to a control system.
[0092] Figure 7 Fig. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application. Hereinafter, the electronic device will be described with reference to Fig. 1. Figure 7 Fig. 1 is a structural schematic diagram of an electronic device according to an embodiment of the present application. Hereinafter, the electronic device will be described with reference to Fig. 1. Figure 7 As shown in Fig. 1, the electronic device includes a memory for storing a computer program and one or more processors for executing the computer program stored in the memory. In an example, the memory can be a read-only memory (ROM) and / or a random access memory (RAM).
[0093] In one example, one or more processors may be one or more central processing units (CPUs) and / or one or more graphics processing units (GPUs), etc. The processors can perform various appropriate actions and processes according to executable instructions stored in ROM or executable instructions loaded from storage into RAM. In one example, the electronic device may also include a communication unit, which may include, but is not limited to, a network interface card (NIC), which may include, but is not limited to, an Infiniband (IB) NIC. The processor can communicate with ROM and / or RAM to execute executable instructions, connect to the communication unit via a bus, and communicate with other target devices through the communication unit, thereby completing the operation corresponding to any method provided in the embodiments of this application.
[0094] In addition, the RAM can store various programs and data required for device operation. The CPU, ROM, and RAM are interconnected via a bus. With RAM present, the ROM is an optional module. The RAM stores executable instructions, or executable instructions are written to the ROM during runtime. These executable instructions cause the processor to perform operations corresponding to any of the methods described above. Input / output (I / O) interfaces are also connected to the bus. The communication unit can be integrated or configured with multiple sub-modules (e.g., multiple IB network cards) linked on the bus.
[0095] The following components are connected to the I / O interface: input sections including keyboards, mice, etc.; output sections including cathode ray tubes (CRTs), liquid crystal displays (LCDs), and speakers; storage sections including hard disks; and communication sections including network interface cards such as LAN cards and modems. The communication sections perform communication processing via networks such as the Internet. Drives are also connected to the I / O interface as needed. Removable media, such as disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive as needed so that computer programs read from them can be installed into the storage section as required.
[0096] It needs to be explained, such as Figure 7 The architecture shown is only one optional implementation. In practice, the above can be modified according to actual needs. Figure 7 The number and type of components can be selected, deleted, added, or replaced; different functional components can also be implemented by separate or integrated configurations. For example, the GPU and CPU can be set separately or the GPU can be integrated on the CPU; the communication unit can be set separately or integrated on the CPU or GPU, and so on. All these alternative implementation methods fall within the protection scope disclosed in this invention.
[0097] Figure 8 A schematic diagram of the structure of an embodiment of the electronic device of this disclosure is shown. Reference is made below. Figure 8Fig. 1 shows a schematic diagram of an electronic device suitable for implementing a terminal device or a server according to an embodiment of the present application. As shown in Fig. 1, the electronic device includes a processor and a memory. The electronic device can also include an input / output device. The memory and the input / output device are connected to the processor via a bus. The memory is configured to store instructions executed by the processor. The processor is configured to invoke the instructions stored in the memory and perform the method of generating a test script based on DSL statement parsing according to any of the possible implementation manners described above. Figure 8
[0098] In one or more optional implementation manners, the present disclosure also provides a computer-readable storage medium for storing computer-readable instructions, which, when executed, cause a computer to perform the method of generating a test script based on DSL statement parsing according to any of the possible implementation manners described above. In another optional example, the computer program product is embodied as a software product, such as a software development kit (SDK) and the like.
[0099] Although the operations are described in a particular, sequential order, it should be understood that the order of the operations can be changed, and that not all operations are necessary for all implementations. In certain circumstances, multitasking and parallel processing can be advantageous.
[0100] The methods and apparatus of the present disclosure can be implemented using standard programming techniques, which can include rule-based logic, or other logic that can be executed by a computer processor using a computer program product coupled to the computer processor. It should be noted that the words "component" and "module," as used herein and in the claims, can refer to one or more hardware or software elements.
[0101] Any of the steps, operations, or procedures described herein can be performed or implemented using one or more hardware or software modules, alone or in combination with other devices. In one implementation, a software module is implemented using a computer program product comprising a computer-readable medium containing computer program code, which can be executed by a computer processor for performing any or all of the steps, operations, or procedures described herein.
[0102] The foregoing description of the present disclosure has been presented for the purposes of illustration and description. It is not intended to be exhaustive or to limit the present disclosure to the precise form disclosed. Various modifications and variations are possible in light of the above teachings or can be acquired from practice of the present disclosure. Other embodiments can be apparent to those skilled in the art from consideration of the specification and practice of the present disclosure. It is intended that the specification and examples be considered as exemplary only, with a true scope of the disclosure being indicated by the following claims.
[0103] It can be understood that, in the present disclosure, "multiple" refers to two or more, and other quantifiers are similar. The association relationship of "and / or" describing the associated objects means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after it. The singular forms "a", "said" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise.
[0104] It can be further understood that the terms "first", "second", and the like are used to describe various information, but these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or importance. In fact, the expressions of "first", "second", and the like can be completely interchangeable. For example, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information without departing from the scope of the present disclosure.
[0105] It can be further understood that, unless otherwise specified, "connection" includes direct connection between the two without other components, and also includes indirect connection between the two with other elements.
[0106] It can be further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring all the operations to be performed to obtain the desired results. In a specific environment, multitasking and parallel processing can be advantageous.
[0107] Other embodiments of the present disclosure will be apparent to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present disclosure following the general principles thereof and including modifications and changes in the application previously disclosed in the present disclosure.
[0108] It should be understood that the present disclosure is not limited to the precise structures described above and shown in the drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is only limited by the appended claims.
[0109] It can be understood that the same or similar parts in the above embodiments can be mutually referred to, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0110] It should be noted that, in the description of the present application, the terms "first", "second", etc. are used only for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present application, the meaning of "a plurality of" or "multiple" is at least two, unless otherwise specified.
[0111] It should be understood that when an element is referred to as being "fixed to" or "set on" another element, it can be directly on the other element or a middle element can be present at the same time; when an element is referred to as "connected" to another element, it can be directly connected to the other element or a middle element can be present at the same time, in addition, "connected" used herein can include wireless connection; the phrase "and / or" used includes any unit and all combinations of the associated listed items.
[0112] Any process or method descriptions in flow charts or described elsewhere herein can be understood as representing one or more modules, segments, or portions of code that include executable instructions for performing specific logical functions or steps in the process, and the preferred embodiments of the present application include additional implementations in which the functions are performed in different orders, in substantially simultaneous fashion, or in reverse order, depending on the functionality involved, as will be understood by those skilled in the art.
[0113] It should be understood that parts of the present application can be implemented in hardware, software, firmware or a combination thereof. In the above-described embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one or a combination of the following technologies known in the art: discrete logic circuit with logic gate circuit for implementing logic functions on data signals, application specific integrated circuit with suitable combination logic gate circuit, programmable gate array (PGA), field programmable gate array (FPGA) and the like.
[0114] Those skilled in the art of the present technology can understand that all or part of the steps carried out by the above-mentioned embodiment method can be completed by program instructions to relevant hardware, and the program can be stored in a computer readable storage medium, which includes one or a combination of steps of the method embodiments when executed.
[0115] In addition, each of the function units in each embodiment of the present application can be integrated in one processing module, or each unit can be physically present separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware, or in the form of a software function module. When the integrated module is realized in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium.
[0116] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0117] In the description of the present specification, the description referring to the terms "one embodiment", "some embodiments", "an example", "a specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present application. In the present specification, the illustrative description of the above terms does not necessarily mean the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0118] Although the embodiments of the present application have been shown and described above, it should be understood that the above embodiments are exemplary and should not be construed as limiting the present application, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the present application.
Claims
1. A method for generating a test script based on DSL sentence parsing, characterized in that, The method comprises: acquiring the DSL sentence actually running in the control system; the DSL sentence comprises a filter query sentence and a query sentence; generating a corresponding condition entity according to different conditions of the DSL sentence, comprising: if the DSL sentence is a filter query sentence, the filter query sentence comprises an exact match condition, a multi-item match condition and a range filter condition, and a corresponding condition entity is generated according to different conditions of the filter query sentence; if the DSL sentence is a query sentence, the query sentence comprises a complete match condition, a reverse match condition, at least one match query condition and a filter condition, and a corresponding condition entity is generated according to different conditions of the query sentence; generating a corresponding test script according to the condition entity; generating a test case by using the test script.
2. The method of claim 1, wherein, The generating a corresponding condition entity according to different conditions of the filter query sentence comprises: if it is an exact match condition, generating an attribute of the exact match condition in the condition entity; if it is a multi-item match condition, generating an attribute of the multi-item match condition in the condition entity; if it is a range filter condition, generating an attribute of the range filter condition in the condition entity.
3. The method of claim 1, wherein, The generating a corresponding condition entity according to different conditions of the query sentence comprises: if it is a complete match condition, generating an attribute of the complete match condition in the condition entity; if it is a reverse match condition, generating an attribute of the reverse match condition in the condition entity; if it is at least one match query condition, generating an attribute of the at least one match query condition in the condition entity; if it is a filter condition, generating an attribute of the filter condition in the condition entity.
4. The method of claim 1, wherein, The method further comprises: uploading the test script to the control system to generate a test case.
5. An apparatus for generating a test script based on DSL sentence parsing, the apparatus comprising: The apparatus comprises: an acquisition unit configured to acquire the DSL sentence actually running in the control system; the DSL sentence comprises a filter query sentence and a query sentence; a generation unit configured to generate a corresponding condition entity according to different conditions of the DSL sentence, comprising: if the DSL sentence is a filter query sentence, the filter query sentence comprises an exact match condition, a multi-item match condition and a range filter condition, and a corresponding condition entity is generated according to different conditions of the filter query sentence; if the DSL sentence is a query sentence, the query sentence comprises a complete match condition, a reverse match condition, at least one match query condition and a filter condition, and a corresponding condition entity is generated according to different conditions of the query sentence; the generation unit is further configured to generate a corresponding test script according to the condition entity; and the generation unit is further configured to generate a test case by using the test script.
6. An apparatus for generating a test script based on DSL sentence parsing, the apparatus comprising: comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the method of any one of claims 1 to 4.
7. A storage medium, characterized by The storage medium has instructions stored therein, and when the instructions in the storage medium are executed by a processor of an apparatus for generating a test script based on a DSL sentence, the apparatus for generating a test script based on a DSL sentence can execute the method of any one of claims 1 to 4.
Citation Information
Patent Citations
Query statement conversion method and device, electronic equipment and storage medium
CN115827675A