CN111143228A - Test code generation method and device based on decision table method - Google Patents

Test code generation method and device based on decision table method Download PDF

Info

Publication number
CN111143228A
CN111143228A CN201911417334.8A CN201911417334A CN111143228A CN 111143228 A CN111143228 A CN 111143228A CN 201911417334 A CN201911417334 A CN 201911417334A CN 111143228 A CN111143228 A CN 111143228A
Authority
CN
China
Prior art keywords
test
service
constraint value
service attribute
decision table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911417334.8A
Other languages
Chinese (zh)
Other versions
CN111143228B (en
Inventor
杜天文
王敏
陈智胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN201911417334.8A priority Critical patent/CN111143228B/en
Publication of CN111143228A publication Critical patent/CN111143228A/en
Application granted granted Critical
Publication of CN111143228B publication Critical patent/CN111143228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/34Graphical or visual programming

Abstract

The invention discloses a test code generation method and a test code generation device based on a decision table method, wherein the method comprises the following steps: obtaining the value range of one or more service attribute objects in the service model; based on a decision table method, generating a constraint value relation table according to the value range of each service attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene; generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations; and generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects. The invention generates the test case codes in a visual mode based on a decision table method, reduces the code compiling amount, lowers the test threshold and can realize the full coverage of the business logic scene.

Description

Test code generation method and device based on decision table method
Technical Field
The invention relates to the field of software development and testing, in particular to a test code generation method and device based on a decision table method.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
The Test-Driven Development (TDD) principle is to write unit Test cases before developing functional codes, and determine what business logic codes need to be written by the Test codes, i.e. drive the progress of the whole software Development through testing.
At present, in the existing test drive development, a developer directly writes codes (for example, writes junit test codes) to realize test cases, namely the test cases exist in a code form, and the test cases in the code form have the following defects that ① testers cannot easily understand the test cases in the code form and cannot easily participate in the writing of the test cases, so that sufficient tests are difficult to realize, and even some service scenes can be missed, ② the developers usually design the test codes according to their own experiences when writing the test case codes, so that the test cases can not be guaranteed to cover all service logics, ③ the developers manually write the test codes, so that the test efficiency is low, ④ complex service scenes can cause that the code quantity of the test cases is large, so that a great amount of time is spent on the writing of the test codes, and the test cases in the code form of ⑤ have the defect of inconvenient management.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a test code generation method based on a decision table method, which is used for solving the technical problems of poor readability, easy error, inconvenient management and low test efficiency of a test case in a code form in the conventional test drive development, and comprises the following steps: obtaining the value range of one or more service attribute objects in the service model; based on a decision table method, generating a constraint value relation table according to the value range of each service attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene; generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations; and generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects.
The embodiment of the invention also provides a test code generation device based on a decision table method, which is used for solving the technical problems of poor readability, easy error, inconvenient management and low test efficiency of a test case in a code form in the conventional test drive development, and comprises the following steps: the module analysis module is used for acquiring the value ranges of one or more service attribute objects in the service model; and the constraint value relation generating module is used for generating a constraint value relation table according to the value range of each service attribute object based on a decision table method, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene; the test case generation module is used for generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations; and the test code generation module is used for generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects.
The embodiment of the invention also provides computer equipment for solving the technical problems of poor readability, easy error, inconvenient management and low testing efficiency of a test case in a code form in the conventional test drive development.
The embodiment of the invention also provides a computer readable storage medium, which is used for solving the technical problems of poor readability, easy error, inconvenient management and low testing efficiency of the test case in the code form in the existing test driver development.
In the embodiment of the invention, after the value ranges of one or more service attribute objects in a service model are obtained, a constraint value relation table containing the constraint value relation among the service attribute objects under different service scenes is generated according to the value ranges of the service attribute objects based on a decision table method, then test cases corresponding to the service attribute objects to the different service scenes are generated according to the constraint value relation among the service attribute objects contained in the constraint value relation table, and finally, test codes corresponding to each test case are generated according to the value ranges of the service attribute objects in each test case and the constraint value relation among the service attribute objects.
By the embodiment of the invention, the executable test case codes are generated in a visual mode based on the decision table method, so that the code coding amount is greatly reduced, the threshold of unit test is reduced, testers without code compiling experience can participate in the unit test, the quality of the test case of the unit test is ensured in a multi-dimension mode, and in addition, the generated test case can realize the full coverage of a business logic scene based on the constraint value relation generated by the decision table method.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
FIG. 1 is a flowchart of a test code generation method based on a decision table method according to an embodiment of the present invention;
fig. 2 is a schematic view of a service attribute object presentation interface for module analysis according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an operation interface for generating a constraint value relationship table according to an embodiment of the present invention;
FIG. 4 is a constraint value relationship representation provided in an embodiment of the present invention;
fig. 5 is a schematic view of an operation interface for generating test case codes according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a module analysis parameter configuration interface according to an embodiment of the present disclosure;
fig. 7 is a flowchart of an optional method for converting a test case generated by a visual test decision table method into Java test code according to an embodiment of the present invention;
fig. 8 is a schematic diagram of a test code generation apparatus based on a decision table method according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are used in an open-ended fashion, i.e., to mean including, but not limited to. Reference to the description of the terms "one embodiment," "a particular embodiment," "some embodiments," "for example," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The sequence of steps involved in the embodiments is for illustrative purposes to illustrate the implementation of the present application, and the sequence of steps is not limited and can be adjusted as needed.
The test-driven development is a core practice technology in agile development and is also a design methodology, and the principle is that before functional codes are developed, test case codes of unit tests are written to determine what product codes need to be written. Unit testing refers to analyzing the change of a small enough code during the code writing process, firstly considering all the input and output conditions (expectation) in the small code segment, and only testing the part of the written code until the code passes all case testing.
Currently, unit testing is constrained by the following points:
① the unit test case can only be understood by the developer, because the present unit test case is realized by the developer through writing JUNIT test code directly, and is embodied in the form of code level, the tester can not understand the test case written by the code directly, and can not participate in the writing of the unit test case, thus the insufficient case test can be caused, and the business scene can be omitted;
② the test coverage is low, all cases are compiled by experience, because the developers can only use the code to compile the cases, the developers can only understand the cases, and the compiled cases can design the test by relying on the experience of the developers, thus, the personnel with insufficient development and test experience and insufficient understanding can not ensure the full coverage of the business logic of the test cases;
③, testing the error code of the code, because the Junit testing code is manually written by the developer, there may be errors in writing the testing case code itself, most of the efforts may be to ensure the correctness of the testing code itself when finding the problem, which affects the testing efficiency;
④, the test code amount is large, if the related business scenes are more, the amount of the code for writing the test case is large, and the code for writing the test case is often several times larger than the product code, so that a great deal of time is spent on writing the test code;
⑤, the existing test cases are searched with poor ergodicity, for the cases only written in the code, when the existing cases are searched, the cases must know which service cases exist at present and some keywords to search for, and the method may not be difficult for the people familiar with the test codes, but the method is time-consuming and laborious for the new members to find the cases and also requires inquiring the familiar colleagues to find the cases.
It can be seen from the above contents that, in the current unit test, only developers write test cases through own experience, and there is a risk that the business logic is not completely covered; and the test case can only be understood by developers, so that the review of the test case is limited (the test personnel or service experts can not participate in the review). In addition, the test case error can be caused by the non-specification of the test code writing itself, and the code amount of the test code is often several times of the product code, so that a developer can spend a lot of time when writing the test code.
In order to solve the above problem, an embodiment of the present invention provides a test code generation method based on a decision table method, and fig. 1 is a flowchart of the test code generation method based on the decision table method provided in the embodiment of the present invention, and as shown in fig. 1, the method may include the following steps:
s101, obtaining the value range of one or more service attribute objects in the service model.
It should be noted that, the business model refers to describing objects and elements involved in the business in a software model manner, and their attributes, behaviors and relationships between each other. The business model in the embodiment of the invention is a model which is modeled in a table form according to the attributes, behaviors and the relations in the field of the field with independent business meanings.
It should be noted that, a service model usually includes many service attribute objects, and each service attribute object obtained through the above-mentioned S101 in the embodiment of the present invention may be a service attribute object having a certain service association relationship, so as to generate test cases (test cases) of the service attribute objects in different service scenarios, thereby testing modules formed by the service attribute objects in different service scenarios.
Optionally, in the embodiment of the present invention, when the value range of each service attribute object is obtained in S101, the system may provide an online edit form, and obtain one or more service attribute objects edited online by the user and the value range of each service attribute object; or, a document (e.g., an excel document) containing a value range of one or more service attribute objects, which is created in advance by a user, may be directly imported by the system to obtain the value range of each service attribute object. Thus, the above S101 can be implemented by, but not limited to, the following two ways:
in a first optional implementation manner, a preconfigured service model is obtained (the service model includes value ranges of preconfigured service attribute objects); grouping each service attribute object contained in the service model by adopting a module analysis mode; and acquiring the value range of one or more service attribute objects contained in each group.
In a second optional implementation manner, an externally imported module analysis document is received, where the module analysis document includes a value range of one or more service attribute objects in a service model configured in advance.
Fig. 2 is a schematic view of a service attribute object display interface for module analysis, which is provided in an embodiment of the present invention, and shows a value range of each service attribute object in a service model in a table form as shown in fig. 2. Optionally, the value range of each service attribute object shown in fig. 2 may be written in the excel form by the user in advance and imported to the platform, or may be directly edited in the platform page on line with the same template content as the excel form and stored in the platform.
The embodiment of the invention lists all possible value ranges of each business attribute under the business service, and the correct value, the error value and the boundary value of the business attribute are all required to be displayed in a table in a visualized mode.
Furthermore, each service attribute object in the service model can be grouped according to the service rule, so that the service attribute objects with the service rule are grouped into one group, and by grouping each service attribute object of the service model, the service logic can be simplified, but the service scene can not be lost, the test case is convenient to write, the possible combination scene is simple as much as possible, and the complexity of Cartesian products is reduced.
S102, based on a decision table method, generating a constraint value relation table according to the value range of each service attribute object, wherein the constraint value relation table comprises: and multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all the service attribute objects under one service scene.
It should be noted that, in the above S102, the business attribute objects are arranged and combined, and the combination mode includes, but is not limited to: cartesian product combinations (for analyzing the mutual influence of correct value data items), hash combinations (for analyzing the expected error reporting of erroneous values), and based on a decision table method, the expression of a relationship of constraint values in the form of a table is realized.
The decision table method supports the combination of all the business attribute objects in the form of excel tables to realize the full coverage of business logic, so that the personnel with insufficient development and test experience can compile test cases in a visual mode. The embodiment of the invention carries out module grouping on each service attribute object in the service model, refines the service rule and generates a constraint value relation model which can be compiled, and because the constraint value relation analysis takes the service attributes as permutation and combination and provides an observation item and an expected value of each combination, a group of constraint value relations in the constraint value relation table are a test case, and the test model corresponding to the test case can simulate the test scenes of data table storage, interface data and class attributes in a product.
Specifically, S102 may be implemented by the following steps: acquiring a pre-configured decision table template; generating a decision table containing the relation of constraint values among all service attribute objects under a plurality of service scenes according to a pre-configured decision table template; receiving observation items and expected values configured for each service scene; and generating a constraint value relation table according to the constraint value relation among the service attribute objects under each service scene, and the observation items and the expected values of each service scene. It should be noted that the observation item and the expected value of each service scenario are expected test result data corresponding to each service scenario input by the user. Optionally, after generating a decision table of the constraint value relationship between the service attribute objects in different service scenarios, the embodiment of the present invention configures the observation items and the expected values configured for each service scenario in the decision table in a visualization manner.
Optionally, the decision table template provided in the embodiment of the present invention may be a decision table template generated by any one of the following decision table methods: equivalence class method, boundary value method, error inference method.
Fig. 3 is a schematic view of an operation interface for generating a constraint value relationship table according to an embodiment of the present invention, and as shown in fig. 3, in an embodiment of the present invention, a plurality of decision table templates are configured in a platform in advance, so that a user can generate a decision table using different decision table templates by one key. For example, a decision table of a correct value cartesian product of an equivalence class method or a hash permutation combination of a boundary value method and an error inference method is automatically generated according to the value range of each attribute object, and the decision table includes a constraint value relationship between each attribute object under a service logic full coverage scene. By internally arranging some decision table templates, the test case of Cartesian product or hash can be automatically generated according to the value range of each business attribute object.
Since the corresponding expected test result data should be obtained for the test data in each service scenario, after a decision table containing the constraint value relationship between the attribute objects in different service scenarios is generated, the corresponding observation items and the corresponding expected values in different service scenarios can be input by the user, so as to obtain the constraint value relationship table shown in fig. 4.
It should be noted that, in the test case code generation method provided in the embodiment of the present invention, the semantic conversion function may be supported for the management of the observation items, so that developers or testers can configure the observation items corresponding to different service scenarios using a common language in the service field. After the module analysis of the service model is completed, developers or testers can uniformly maintain the expected value observed by the service module and the observation method to the platform observation item module, and the form of the platform observation item module is equivalent to that the observation method and the expected value are mapped into natural language which can be understood by all users. If the observation items are maintained in the platform after the module analysis is completed, only the observation names with natural semantic identifiers to be observed need to be placed in the corresponding combined relation cases when the constraint relation cases are compiled by using a decision table method. The platform can automatically generate corresponding Java assertion program statements according to semantic conversion of the observation items.
Therefore, according to the embodiment of the invention, the test cases under different service scenes are obtained by combining and compiling different decision table methods according to the value range of each attribute object in advance, and the compiled service scene test cases are arranged in the platform and used as a decision table template, so that the aim of automatically generating the test cases is fulfilled.
S103, generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations.
It should be noted that the constraint value relationship table generated in the embodiment of the present invention includes the constraint value relationship corresponding to each service attribute object in different service scenarios and the expected test result data corresponding to different constraint value relationships, and by performing semantic processing on the expected test result data configured by the user (an association relationship between a natural language observation item and a code may be established in advance), test cases corresponding to different constraint value relationships can be generated, where each test case corresponding to a service scenario corresponds to a test case of a constraint value relationship.
As can be seen from the constraint value relationship table shown in fig. 4, a group of service attribute objects (i.e., each service attribute object obtained in S101) in each constraint value relationship table corresponds to a plurality of test cases, and each test case corresponds to one service scene.
It should be noted that when each constraint value relationship in the constraint value relationship table is converted into a corresponding test case, the content in the constraint value relationship table in the excel format needs to be analyzed, and a test case capable of being converted into an executable junit test code is generated by combining with the module analysis of the service model, and meanwhile, the test case can be used as a visual case to be understood by service experts, testers and developers. The data of the test case can simulate data sheet storage, interface data and class attributes, and generate corresponding test codes through different data simulation, so that the platform can read what data a user needs to simulate for testing.
And S104, generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects.
It should be noted that, for each test case, a Java class is used to automatically generate a test case code (unit test code), one test case corresponds to a class method under the class, the prepared data is assigned to each service attribute object by using Java reflection characteristics, and a service method is executed, and finally, an assertion statement is used to check the correctness of an expected value in an observation item. And continuously using the generated test case codes (Junit test codes) for verification while writing the product codes until all platform-generated Junit codes run successfully.
Fig. 5 is a schematic view of an operation interface for generating test case codes, which is provided in an embodiment of the present invention, and as shown in fig. 5, the embodiment of the present invention can convert a visual test case generated based on a decision table method into corresponding test codes by one key.
In the test code generation method based on the decision table method provided in the embodiment of the present invention, after the value ranges of one or more service attribute objects in a service model are obtained, a constraint value relationship table including the constraint value relationships between the service attribute objects in different service scenes is generated based on the decision table method according to the value ranges of the service attribute objects, a test case corresponding to each service attribute object in different service scenes is generated according to the constraint value relationships between the service attribute objects included in the constraint value relationship table, and finally, a test code corresponding to each test case is generated according to the value ranges of the service attribute objects in each test case and the constraint value relationships between the service attribute objects.
By the test code generation method based on the decision table method, the executable test case codes can be generated by adopting a visual mode based on the decision table method, the code coding amount is greatly reduced, so that testers without code compiling experience can participate in unit testing, the quality of the test cases of the unit testing is ensured in a multi-dimension mode, and in addition, the constraint value relation is generated based on the decision table method, so that the generated test cases can realize full-service logic coverage.
In an optional embodiment, the test code generation method based on the decision table method provided in the embodiment of the present invention may further include the following steps: and receiving a code downloading instruction, wherein the code downloading instruction is used for downloading the test codes corresponding to the test cases. Still taking fig. 5 as an example, the test code for each test case under analysis of each module can be downloaded via a download button.
In an optional embodiment, the test code generation method based on the decision table method provided in the embodiment of the present invention may further include the following steps: and receiving a parameter configuration instruction, wherein the parameter configuration instruction is used for configuring the value range of each service attribute object. The value ranges of all the business attribute objects are configured, so that all the business attribute objects for generating the test cases have the advantage of multiplexing, and more test cases can be generated quickly and efficiently.
Fig. 6 is a schematic diagram of a module analysis parameter configuration interface provided in an embodiment of the present invention, and as shown in fig. 6, each service attribute object after being analyzed and grouped by a service model module may be edited and modified, and the modified part may simultaneously update the test case content generated by the constraint relationship. Therefore, the execution of the old case can not be influenced by the modified or newly added content, and the reuse and reconstruction of the module are more convenient. A new user story would most often be the addition of an action or the addition of multiple data elements to form a new scene. In most cases, the service model analysis and test data selection for analyzing the corresponding service scene are reusable. The platform provides a function of adding data elements to the original business model, and new behaviors (services or methods) can be added under the analysis of the original business model. Therefore, the new story can reuse the results of the original business model analysis (test data) and scene analysis (test data combination and observation method). The test case of the new story can be formed only by changing the expected result corresponding to the new story.
It should be noted that, by using the test code generation method based on the decision table method provided by the embodiment of the present invention, a software platform that converts the test cases generated by the visual test decision table method into executable test codes can be developed, and the software platform can also store the test cases in the form of a sub-table in a platform database in which module analysis is performed as a parent key table, and visually display the data content in a platform browser, so as to facilitate browsing and viewing by the user. Preferably, the software platform can also provide an efficient use case indexing mechanism, and can execute a test code program according to a plurality of module analysis documents and scene analysis documents of the hierarchical dimension query service model, such as products, components, constraint value relation groups, and the like, and automatically generated test cases.
Fig. 7 is a flowchart of an optional method for converting a test case generated by a visual test decision table method into a Java test code according to an embodiment of the present invention, and as shown in fig. 7, the test data may be uploaded to a platform in the form of an excel table or data in the form of a table newly added to an online edit page provided by the platform according to a test model analyzed by a test data determination module of a boundary value method, an equivalence class method, or an error deduction algorithm with a service model as a reference. And grouping each service attribute object in the service model according to the service rule, selecting different combination strategies in a table form by adopting a decision table method according to grouped data, and automatically generating a visual decision table containing a constraint value relation by a platform. The constraint value relation table generated by the decision table method is automatically converted into the test cases, all cases can be maintained and displayed in the platform, and the test cases are definitely classified according to module analysis and test service, so that a user can quickly position the test cases to be checked. For the test cases in the platform, all cases can be processed through a platform algorithm to generate executable test case codes (namely, Junit test codes), a code downloading function is provided, and a user can directly copy the downloaded test codes to the integrated development environment to run. In addition, all data in the platform can be inquired through a platform retrieval function, a plurality of hierarchical dimensionality inquiry functions are provided, and business model analysis documents, scene analysis documents and automatically generated test code programs can be inquired according to products, business services, constraint value relation groups and the like.
Based on the same inventive concept, the embodiment of the present invention further provides a test code generation apparatus based on a decision table method, as described in the following embodiments. Because the principle of solving the problems of the embodiment of the device is similar to the test code generation method based on the decision table method, the implementation of the embodiment of the device can refer to the implementation of the method, and repeated parts are not repeated.
Fig. 8 is a schematic diagram of a test code generation apparatus based on a decision table method according to an embodiment of the present invention, and as shown in fig. 8, the apparatus may include: a module analysis module 81, a constraint value relationship generation module 82, a test case generation module 83, and a test code generation module 84.
The module analysis module 81 is configured to obtain a value range of one or more service attribute objects in the service model; a constraint value relationship generating module 82, configured to generate a constraint value relationship table according to the value range of each service attribute object based on a decision table method, where the constraint value relationship table includes: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene; the test case generating module 83 is configured to generate one or more test cases according to the constraint value relationship table, where each test case corresponds to a set of constraint value relationships; and the test code generating module 84 is configured to generate a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship between each service attribute object.
The test code generation device based on the decision table method provided by the embodiment of the invention obtains the value range of one or more service attribute objects in the service model through the module analysis module 81, and obtains the value range of one or more service attribute objects in the service model through the constraint value relation generation module 82 based on the decision table method, generating a constraint value relation table containing the constraint value relation among the service attribute objects under different service scenes according to the value range of each service attribute object, further, the test case generating module 83 generates test cases corresponding to different service scenes for each service attribute object according to the constraint value relationship between each service attribute object contained in the constraint value relationship table, and finally the test code generating module 84 generates test cases corresponding to different service scenes for each service attribute object according to the value range of each service attribute object in each test case, and generating a test code corresponding to each test case according to the constraint value relationship among the service attribute objects.
The test code generation device based on the decision table method provided by the embodiment of the invention can generate executable test case codes based on the decision table method in a visual mode, so that the code coding amount is greatly reduced, testers without code compiling experience can participate in unit tests, the quality of the test cases of the unit tests is ensured in a multi-dimension mode, and in addition, the constraint value relation is generated based on the decision table method, so that the generated test cases can realize full-service logic coverage.
In an optional embodiment, in the test code generation apparatus based on the decision table method provided in the embodiment of the present invention, the module analysis module 81 may be configured to obtain a preconfigured service model, where the service model includes: presetting the value range of each service attribute object; grouping each service attribute object contained in the service model by adopting a module analysis mode; and acquiring the value range of one or more service attribute objects contained in each group.
In another optional embodiment, in the test code generation apparatus based on the decision table method provided in the embodiment of the present invention, the module analysis module 81 may be configured to receive an externally imported module analysis document, where the module analysis document includes a value range of one or more service attribute objects in a service model configured in advance.
In an optional embodiment, the test code generation apparatus based on a decision table method provided in the embodiment of the present invention may further include: and the parameter configuration module 85 is configured to receive a parameter configuration instruction, where the parameter configuration instruction is used to configure a value range of each service attribute object.
In an optional embodiment, in the test code generation apparatus based on the decision table method provided in the embodiment of the present invention, the constraint value relationship generation module 82 may also be configured to obtain a pre-configured decision table template; generating a decision table containing the relation of constraint values among all service attribute objects under a plurality of service scenes according to a pre-configured decision table template; receiving observation items and expected values configured for each service scene; and generating a constraint value relation table according to the constraint value relation among the service attribute objects under each service scene, and the observation items and the expected values of each service scene.
Optionally, in the test code generation apparatus based on the decision table method provided in the embodiment of the present invention, the decision table template includes a decision table template generated by any one of the following decision table methods: equivalence class method, boundary value method, error inference method.
In an optional embodiment, the test code generation apparatus based on a decision table method provided in the embodiment of the present invention may further include: and the code downloading module 86 is configured to receive a code downloading instruction, where the code downloading instruction is used to download the test code corresponding to each test case.
Based on the same inventive concept, the embodiment of the present invention further provides a computer device, so as to solve the technical problems of poor readability, easy error, inconvenient management, and low testing efficiency of a code-form test case in the existing test driver development.
Based on the same inventive concept, the embodiment of the invention further provides a computer readable storage medium, which is used for solving the technical problems that a test case in a code form has poor readability, is easy to make mistakes, is inconvenient to manage and has low test efficiency in the existing test drive development.
In summary, embodiments of the present invention provide a test code generation method and apparatus, a computer device, and a computer readable storage medium based on a decision table method, where a test case is generated based on the decision table method, and the test case has better visualization and readability, and a visualization test model of the test case can be used for users (e.g., service experts, testers, etc.) who do not write codes to understand the test case that can only be understood by developers before, and the test case can be converted to generate executable test codes, so that convenience is provided for the developers to execute the test case. The embodiment of the invention can provide a test case of a universal language, so that a service expert and a tester can contact a unit test in advance, and the unit test is reviewed and compiled together with a developer, thereby ensuring the test quality. In addition, the decision table method can realize the full coverage of business logic, help the personnel with weak business ability to guide the business scene design cases which are not considered, ensure that the business scene can be tested, reduce the risk to the minimum before compiling the product, find the problem in advance, and reduce the risk and the workload brought by modifying the defects later.
It should be noted that, the main architecture of the business code of the product is based on the business model, and the module analysis is also based on the business model, so the business attributes and business service behaviors in the module analysis are in one-to-one correspondence with the product code architecture, and the constraint value relational analysis is a subset of the module analysis, so the test data and the attributes of the observation items of the test case compiled under the constraint value relational analysis are all in the product code architecture, thus the test code generation method based on the decision table method provided by the embodiment of the invention can convert the case compiled by the constraint relational analysis into the test case code at executable code level, so that different role personnel can discuss the test case and test scene together, and also have more confidence for the developer to compile the code according to the unit test case, the function of generating test codes conveniently is provided for the development of test drivers, and meanwhile, the workload of compiling the test codes by developers is reduced. In addition, the embodiment of the invention can conveniently search and display tested cases through the omnibearing search function.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A test code generation method based on a decision table method is characterized by comprising the following steps:
obtaining the value range of one or more service attribute objects in the service model;
based on a decision table method, generating a constraint value relation table according to the value range of each service attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene;
generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations;
and generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects.
2. The method of claim 1, wherein obtaining a value range for one or more service attribute objects in a service model comprises:
acquiring a pre-configured service model, wherein the service model comprises: presetting the value range of each service attribute object;
grouping each service attribute object contained in the service model by adopting a module analysis mode;
and acquiring the value range of one or more service attribute objects contained in each group.
3. The method of claim 1, wherein obtaining a pre-configured value range of one or more service attribute objects comprises:
and receiving an externally imported module analysis document, wherein the module analysis document comprises the value range of one or more service attribute objects in a pre-configured service model.
4. The method of claim 1, wherein the method further comprises:
and receiving a parameter configuration instruction, wherein the parameter configuration instruction is used for configuring the value range of each service attribute object.
5. The method of claim 1, wherein generating a constraint value relationship table based on a decision table method according to a value range of each service attribute object comprises:
acquiring a pre-configured decision table template;
generating a decision table containing the relation of constraint values among all service attribute objects under a plurality of service scenes according to a pre-configured decision table template;
receiving observation items and expected values configured for each service scene;
and generating a constraint value relation table according to the constraint value relation among the service attribute objects under each service scene, and the observation items and the expected values of each service scene.
6. The method of claim 5, wherein the decision table template comprises a decision table template generated by any one of the following decision table methods: equivalence class method, boundary value method, error inference method.
7. The method of claim 1, wherein after generating the test code corresponding to each test case according to the value range of each business attribute object in each test case and the constraint value relationship between each business attribute object, the method further comprises:
and receiving a code downloading instruction, wherein the code downloading instruction is used for downloading the test codes corresponding to the test cases.
8. A test code generation apparatus based on a decision table method, comprising:
the module analysis module is used for acquiring the value ranges of one or more service attribute objects in the service model;
a constraint value relationship generating module, configured to generate a constraint value relationship table according to a value range of each service attribute object based on a decision table method, where the constraint value relationship table includes: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to the constraint value relation among all service attribute objects under one service scene;
the test case generating module is used for generating one or more test cases according to the constraint value relation table, wherein each test case corresponds to a group of constraint value relations;
and the test code generation module is used for generating a test code corresponding to each test case according to the value range of each service attribute object in each test case and the constraint value relationship among the service attribute objects.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method for generating test code based on a decision table method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the decision table method-based test code generation method according to any one of claims 1 to 7.
CN201911417334.8A 2019-12-31 2019-12-31 Test code generation method and device based on decision table method Active CN111143228B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911417334.8A CN111143228B (en) 2019-12-31 2019-12-31 Test code generation method and device based on decision table method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911417334.8A CN111143228B (en) 2019-12-31 2019-12-31 Test code generation method and device based on decision table method

Publications (2)

Publication Number Publication Date
CN111143228A true CN111143228A (en) 2020-05-12
CN111143228B CN111143228B (en) 2023-09-19

Family

ID=70522819

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911417334.8A Active CN111143228B (en) 2019-12-31 2019-12-31 Test code generation method and device based on decision table method

Country Status (1)

Country Link
CN (1) CN111143228B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858324A (en) * 2020-07-13 2020-10-30 中国工商银行股份有限公司 Automatic generation method and device of test case
CN112905461A (en) * 2021-02-09 2021-06-04 中国工商银行股份有限公司 Method and device for executing automatic interface test case

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788907A (en) * 2010-01-04 2010-07-28 北京航空航天大学 Automatic generation method for combination service simplified test case and device therefor
CN106874190A (en) * 2016-12-30 2017-06-20 上海亿账通互联网科技有限公司 The method of testing and server of user interface
CN107133174A (en) * 2017-05-04 2017-09-05 浙江路港互通信息技术有限公司 Test case code automatically generating device and method
CN110032515A (en) * 2019-04-12 2019-07-19 中国银行股份有限公司 A kind of interface detection case generation method, device and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101788907A (en) * 2010-01-04 2010-07-28 北京航空航天大学 Automatic generation method for combination service simplified test case and device therefor
CN106874190A (en) * 2016-12-30 2017-06-20 上海亿账通互联网科技有限公司 The method of testing and server of user interface
CN107133174A (en) * 2017-05-04 2017-09-05 浙江路港互通信息技术有限公司 Test case code automatically generating device and method
CN110032515A (en) * 2019-04-12 2019-07-19 中国银行股份有限公司 A kind of interface detection case generation method, device and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858324A (en) * 2020-07-13 2020-10-30 中国工商银行股份有限公司 Automatic generation method and device of test case
CN111858324B (en) * 2020-07-13 2023-08-25 中国工商银行股份有限公司 Automatic generation method and device for test cases
CN112905461A (en) * 2021-02-09 2021-06-04 中国工商银行股份有限公司 Method and device for executing automatic interface test case
CN112905461B (en) * 2021-02-09 2024-03-15 中国工商银行股份有限公司 Method and device for executing automatic interface test case

Also Published As

Publication number Publication date
CN111143228B (en) 2023-09-19

Similar Documents

Publication Publication Date Title
CN104407973B (en) A kind of implementation method and device of automation cell test
CN111158656B (en) Test code generation method and device based on fruit tree method
US6941546B2 (en) Method and apparatus for testing a software component using an abstraction matrix
CN111832236B (en) Chip regression testing method and system, electronic equipment and storage medium
Hartmann et al. A UML-based approach to system testing
Moreau et al. A templating system to generate provenance
US20210374040A1 (en) Auto Test Generator
CN106446412B (en) Model-based test method for avionics system
Gerpheide et al. Assessing and improving quality of QVTo model transformations
US20050137839A1 (en) Methods, apparatus and programs for system development
CN111143228B (en) Test code generation method and device based on decision table method
Binamungu et al. Detecting duplicate examples in behaviour driven development specifications
CN112799718A (en) Enumerated document generation method and device, electronic equipment and storage medium
Häser et al. An integrated tool environment for experimentation in domain specific language engineering
Elekes et al. Assessing the specification of modelling language semantics: a study on UML PSSM
CN113051262B (en) Data quality inspection method, device, equipment and storage medium
Nikiforova et al. Towards a Business Process Model-based Testing of Information Systems Functionality.
CN114385155A (en) vue project visualization tool generation method, device, equipment and storage medium
WO2022093178A1 (en) Ci/cd pipeline code recommendations
Henry A technique for hiding proprietary details while providing sufficient information for researchers; or, do you recognize this well-known algorithm?
Wotawa et al. The Java2CSP debugging tool utilizing constraint solving and model-based diagnosis principles
CN109669868A (en) The method and system of software test
Bicevskis et al. Data quality model-based testing of information systems
US11914503B2 (en) Automated performance measurement over software lifecycle
Heck et al. LaQuSo software product certification model (LSPCM)

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant