CN111143228B - 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
CN111143228B
CN111143228B CN201911417334.8A CN201911417334A CN111143228B CN 111143228 B CN111143228 B CN 111143228B CN 201911417334 A CN201911417334 A CN 201911417334A CN 111143228 B CN111143228 B CN 111143228B
Authority
CN
China
Prior art keywords
business
test
constraint value
decision table
generating
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.)
Active
Application number
CN201911417334.8A
Other languages
Chinese (zh)
Other versions
CN111143228A (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

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method and a device for generating test codes based on a decision table method, wherein the method comprises the following steps: acquiring a value range of one or more business attribute objects in a business model; based on a decision table method, generating a constraint value relation table according to the value range of each business attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to constraint value relations among all business attribute objects in a business 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 business attribute object in each test case and the constraint value relation among the business attribute objects. The invention generates the test case code in a visual mode based on the decision table method, reduces the code writing amount, reduces 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 testing, in particular to a method and a device for generating test codes 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 principle of Test-Driven Development, TDD is that before developing the functional code, a unit Test case is written, and the Test code determines what business logic code needs to be written, that is, the progress of the whole software development is driven by testing.
Currently, in the existing test driver development, a developer directly writes a code (for example, writes a junit test code) to implement a test case, that is, the test case exists in a code form, and the test case in the code form has the following disadvantages: (1) the test cases in the code form are difficult to be understood by the testers, and the testers are difficult to participate in the writing of the test cases, so that the sufficient test is difficult to realize, and even some service scenes can be omitted; (2) because the test case codes are usually designed by relying on self experience when a developer writes the test case codes, it is difficult to ensure that the test case can cover all business logic; (3) manually writing test codes, and possibly causing errors of the codes, so that the test efficiency is low; (4) the complex business scenario may cause a large code amount of the test case, so that a developer wastes a large amount of time in writing the test code; (5) the code-type test cases have the disadvantage of inconvenient management.
In view of the above problems, no effective solution has been proposed at present.
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 code-form test cases in the existing test drive development, and comprises the following steps: acquiring a value range of one or more business attribute objects in a business model; based on a decision table method, generating a constraint value relation table according to the value range of each business attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to constraint value relations among all business attribute objects in a business 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; generating a 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 relation among each business attribute object; based on decision table method, generating constraint value relation table according to the value range of each business attribute object, including: according to the value range of each business attribute object, different decision table methods are adopted, and test cases under different business scenes are obtained through combined writing; taking the written service scene test cases as decision table templates; obtaining a pre-configured decision table template; generating a decision table containing constraint value relations among all business attribute objects in a plurality of business scenes according to a pre-configured decision table template; receiving observation items and expected values configured for each service scene; and generating the constraint value relation table according to the constraint value relation among the business attribute objects in each business scene and the observation items and the expected values of each business scene.
The embodiment of the invention also provides a test code generating device based on a decision table method, which is used for solving the technical problems of poor readability, easy error and inconvenient management and low test efficiency of code-form test cases in the existing test drive development, and comprises the following steps: the module analysis module is used for acquiring the value range of one or more business attribute objects in the business model; the constraint value relation generation module is used for generating a constraint value relation table according to the value range of each business 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 constraint value relations among all business attribute objects in a business 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; 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 relation among the service attribute objects; the constraint value relation generation module is specifically configured to: according to the value range of each business attribute object, different decision table methods are adopted, and test cases under different business scenes are obtained through combined writing; taking the written service scene test cases as decision table templates; obtaining a pre-configured decision table template; generating a decision table containing constraint value relations among all business attribute objects in a plurality of business scenes according to a pre-configured decision table template; receiving observation items and expected values configured for each service scene; and generating the constraint value relation table according to the constraint value relation among the business attribute objects in each business scene and the observation items and the expected values of each business scene.
The embodiment of the invention also provides a computer device which is used for solving the technical problems of poor readability, easy error, inconvenient management and low test efficiency of code-form test cases in the existing test drive development.
The embodiment of the invention also provides a computer readable storage medium for solving the technical problems of poor readability, easy error, inconvenient management and low test efficiency of code-form test cases in the existing test drive development.
In the embodiment of the invention, after the value range of one or more business attribute objects in a business model is obtained, a constraint value relation table containing constraint value relations among the business attribute objects under different business scenes is generated based on a decision table method according to the value range of each business attribute object, further, test cases corresponding to different business scenes by each business attribute object are generated according to the constraint value relations among the business attribute objects contained in the constraint value relation table, and finally, test codes corresponding to each test case are generated according to the value range of each business attribute object in each test case and the constraint value relations among the business attribute objects.
According to 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 the unit test is reduced, a tester without code writing experience can participate in the unit test, the multi-dimension ensures the quality of the test cases of the unit test, and in addition, the constraint value relation is generated based on the decision table method, so that the generated test cases can realize the full coverage of the service logic scene.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. 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 diagram of a business attribute object display 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 application;
FIG. 4 is a representation of a constraint value relationship provided in an embodiment of the present application;
FIG. 5 is a schematic diagram of an operator interface for generating test case codes according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a module analysis parameter configuration interface according to an embodiment of the present application;
FIG. 7 is a flowchart of an alternative method for converting test cases generated by the visual test decision table method into Java test codes according to an embodiment of the present application;
fig. 8 is a schematic diagram of a test code generating device based on a decision table method according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings. The exemplary embodiments of the present application and their descriptions herein are for the purpose of explaining the present application, but are not to be construed as limiting the application.
In the description of the present specification, the terms "comprising," "including," "having," "containing," and the like are open-ended terms, meaning including, but not limited to. The description of the reference 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, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. The order of steps involved in the embodiments is illustrative of the practice of the application, and is not limited and may be suitably modified as desired.
Test driven development is a core practice technology in agile development and is also a design methodology, and the principle is that test case codes of unit tests are written before functional codes are developed so as to determine what product codes need to be written. The unit test refers to analyzing the variation of a small enough code in the code writing process, and considering all the input and output conditions (expectations) in the small code, and only testing the written code until the code passes all the case tests.
Currently, unit testing is constrained by the following points:
(1) the unit test cases are only understandable to the developer. Because the current unit test cases are realized by directly writing the JUNIT test codes by developers and are embodied in a code level form, the testers cannot understand the test cases directly written by the codes and are less likely to participate in the writing of the unit test cases, so that insufficient case test can be caused, and business scenes can be omitted;
(2) the test coverage is low, and all cases are written empirically. Because the developer uses the code writing case, only the developer can understand the code writing case, and the writing case is designed and tested by relying on the experience of the developer, the full coverage of the business logic of the test case cannot be ensured for the personnel with insufficient development and test experience and insufficient understanding requirement;
(3) The unit tests the code itself for errors. Because the Junit test code is manually written by a developer, errors can exist in writing the test case code, and most efforts can be made to ensure the correctness of the test code when finding problems, so that the test efficiency is affected;
(4) the test code amount is large. If the related business scenes are more, the code content of the test case is large, and the code for writing the test case is often several times more than the code for writing the product, so that a great amount of time is spent on writing the test code;
(5) the existing test cases are queried, and the ergodic performance is poor. For cases written only in the code, the cases of which services and keywords are currently available must be known to inquire about when the existing cases are inquired, so that the inquiry is not very difficult for a person familiar with the test code, but the inquiry is time-consuming and laborious for a new member to find the cases, and the familiar colleagues must be inquired about to find the cases.
From the above, it can be seen that the current unit test only relies on the developer to write the test cases through his own experience, and there is a risk that the business logic is not fully covered; and the test cases can only be understood by the developer, resulting in limitation of review of the test cases (neither the tester nor the business expert can participate therein). In addition, the non-standardization of writing the test code itself also causes errors of the test cases, and the coding amount of the test code is often several times that of the product code, so that a developer can take a lot of time when writing the test code.
In order to solve the above problems, in an embodiment of the present invention, a method for generating test codes based on a decision table method is provided, and fig. 1 is a flowchart of a method for generating test codes based on a decision table method, as shown in fig. 1, the method may include the following steps:
s101, acquiring a value range of one or more business attribute objects in a business model.
The business model refers to objects and elements related to the business, and their attributes, behaviors and relationships among each other in a software model manner. The business model in the embodiment of the invention refers to a model which is modeled in a form aiming at the attribute, the behavior and the relationship in the field of the independent business meaning.
It should be noted that, in an embodiment of the present invention, each service attribute object obtained in the above S101 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, so as to test 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 editing table to obtain one or more service attribute objects that are edited online by the user, and the value range of each service attribute object; the system may also directly import a document (e.g., an excel document) that is created in advance by the user and contains the value ranges of one or more business attribute objects, so as to obtain the value ranges of the business attribute objects. Thus, the above S101 can be implemented by, but not limited to, the following two ways:
a first alternative embodiment, a pre-configured business model is obtained (the business model comprises a value range of each pre-configured business attribute object); grouping all the business attribute objects contained in the business model by adopting a module analysis mode; the value range of one or more business attribute objects contained in each packet is obtained.
In a second alternative embodiment, an externally imported module analysis document is received, wherein the module analysis document contains a range of values for one or more business attribute objects in a pre-configured business model.
Fig. 2 is a schematic diagram of a service attribute object display interface for module analysis according to an embodiment of the present invention, where as shown in fig. 2, a value range of each service attribute object in a service model is displayed in a table form. Alternatively, the value ranges of the service attribute objects shown in fig. 2 may be written in an excel table in advance by a user and imported to the platform, or may be directly edited on line in a platform page to form the same template content as the excel table, and stored in the platform.
The embodiment of the invention all lists all possible value ranges of each business attribute under the business service, and all visualizations of the correct value, the error value and the boundary value are required to be displayed in the table.
Further, 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 divided into a group, service logic can be simplified but service scenes can not be lost by grouping each service attribute object of the service model, test cases can be conveniently written, the possible combined scenes are as simple as possible, and the complexity of Cartesian products is reduced.
S102, generating a constraint value relation table according to the value range of each business attribute object based on a decision table method, wherein the constraint value relation table comprises: and the constraint value relations correspond to constraint value relations among all business attribute objects in one business scene.
It should be noted that, in S102, the service attribute objects are arranged and combined in a manner including, but not limited to: cartesian product combinations (for analyzing interactions of correct value data items), hash combinations (for analyzing expected errors of erroneous values), based on decision-table methods, the constraint value relationships are expressed in tabular form.
The decision table method supports the combination of all business attribute objects in an excel table form, so that business logic is fully covered, and personnel with insufficient development and test experience write test cases in a visual mode. The embodiment of the invention carries out module grouping on each business attribute object in the business model, refines the business rule, generates a writable constraint value relation model, and simultaneously provides an observation item and an expected value of each combination because the analysis of the constraint value relation takes the business attribute as the arrangement combination, so that 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 scene of data table storage, interface data and class attribute in the product.
Specifically, the step S102 may be implemented by: obtaining a pre-configured decision table template; generating a decision table containing constraint value relations among all business attribute objects in a plurality of business 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 constraint value relations among all business attribute objects under all business scenes and observation items and expected values of all business scenes. It should be noted that the observation item and the expected value of each business scenario are expected test result data corresponding to each business scenario inputted by the user. Optionally, after the embodiment of the invention generates the decision table of constraint value relationships among the business attribute objects in different business scenes, the observation items and the expected values configured for each business scene in the decision table are configured in a visual mode.
Optionally, the decision table template provided by the embodiment of the invention may be a decision table template generated by any one of the following decision table methods: equivalence class method, boundary value method, misspeculation method.
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, as shown in FIG. 3, where a plurality of decision table templates are configured in advance in a platform according to an embodiment of the present invention, so that a user can generate a decision table using different decision table templates by one key. For example, a decision table comprising a constraint value relationship between attribute objects in a business logic full coverage scene is automatically generated according to the value range of each attribute object by a hash permutation and combination of a correct value Cartesian product of an equivalence class method or a boundary value method and a misspeculation method. By arranging some decision table templates, the Cartesian product or hash test case can be automatically generated according to the value range of each business attribute object.
Because the corresponding expected test result data should be obtained for the test data in each service scenario, after the decision table containing the constraint value relations among the attribute objects in different service scenarios is generated, the user can input the corresponding observation items and the corresponding expected values in different service scenarios, thereby obtaining the constraint value relation table shown in fig. 4.
It should be noted that, in the test case code generation method provided by the embodiment of the present invention, for management of observation items, a semantic conversion function may be supported, so that a developer or a tester can configure the observation items corresponding to different service scenarios using a language that is common in the service field. After the business model is analyzed, a developer or a tester can uniformly maintain the expected value and the observation method observed by the business model to a platform observation item module, wherein the form of the platform observation item module is equivalent to that of mapping the observation method and the expected value 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 identifications to be observed are required to be placed in the corresponding combination relation cases when the constraint relation cases are written by using a decision-making method. The platform can automatically generate corresponding Java assertion program sentences according to the semantic conversion of the observation items.
Therefore, according to the embodiment of the invention, different decision table methods are adopted in advance according to the value range of each attribute object, the test cases under different service scenes are combined and compiled, and the compiled test cases of the service scenes are arranged in a platform and used as decision table templates, so that the purpose of automatically generating the test cases is realized.
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 relation table generated in the embodiment of the present invention includes constraint value relations corresponding to each service attribute object under different service scenarios, and expected test result data corresponding to different constraint value relations, and by performing semantic processing (association relations between natural language observation items and codes may be established in advance) on the expected test result data configured by the user, test cases corresponding to different constraint value relations can be generated, where each test case of the constraint value relations corresponds to one service scenario.
As can be seen from the constraint value relationship tables shown in fig. 4, a set of service attribute objects (i.e., the service attribute objects obtained in S101 above) in each constraint value relationship table corresponds to a plurality of test cases, and each test case corresponds to a service scenario.
It should be noted that when each constraint value relation in the constraint value relation table is converted into a corresponding test case, the content in the constraint value relation table in an excel format needs to be analyzed, and a test case which can be 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 enable a service expert, a tester and a developer to be able to understand. The data of the test cases can simulate the data table storage, the interface data and the class attribute, and corresponding test codes are generated through different data simulation, so that the platform can read what data the user needs to simulate for testing.
S104, generating test codes corresponding to each test case according to the value ranges of the business attribute objects in each test case and the constraint value relations among the business attribute objects.
It should be noted that, for each test case, a Java class is used to automatically generate a test case code (Junit test code), one test case corresponds to one class method under the class, the prepared data is assigned to each service attribute object by Java reflection characteristics, and a service method is executed, and finally, the correctness of the expected value in the observation item is checked by using an assertion statement. Verification is performed continuously using the generated test case code (Junit test code) while writing the product code until Junit code generated by all platforms is successfully run.
Fig. 5 is a schematic diagram of an operation interface for generating test case codes according to 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.
According to the test code generation method based on the decision table method, after the value range of one or more business attribute objects in the business model is obtained, a constraint value relation table containing constraint value relations among all business attribute objects in different business scenes is generated based on the decision table method according to the value range of each business attribute object, further, test cases corresponding to different business scenes by all business attribute objects are generated according to the constraint value relations among all business attribute objects contained in the constraint value relation table, and finally, test codes corresponding to all test cases are generated according to the value range of all business attribute objects in each test case and the constraint value relations among all business attribute objects.
According to the test code generation method based on the decision table method, executable test case codes can be generated based on the decision table method in a visual mode, code coding quantity is greatly reduced, a tester without code writing experience can participate in unit test, the multi-dimension degree guarantees the test case quality of the unit test, in addition, constraint value relations are generated based on the decision table method, and the generated test cases can achieve full-service logic coverage.
In an optional embodiment, the method for generating test codes based on the decision table method according to 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 may be downloaded via a download button.
In an optional embodiment, the method for generating test codes based on the decision table method according to 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 business attribute object. By configuring the value range of each business attribute object, each business attribute object for generating test cases has the advantage of multiplexing, so that 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, where, as shown in fig. 6, each service attribute object after the service model module analysis grouping is editable and modifiable, and for a modification part, test case contents generated by constraint relation can be synchronously updated at the same time. Therefore, the execution of the old case is not influenced by the modified or newly added content, so that the multiplexing and reconstruction of the module are more convenient. A new user story will in most cases be to add a behavior or to add multiple data elements to form a new scene. In most cases, the service model analysis and test data used for analyzing the corresponding service scene are reusable. The platform provides the function of adding data elements to the original business model, and can also add new behaviors (services or methods) under the analysis of the original business model. Thus, the new story can multiplex the results of the original business model analysis (test data) and scene analysis (test data combination and observation method). The test cases of the new story can be formed by only changing the expected results corresponding to the new story.
It should be noted that, by adopting the test code generation method based on the decision table method provided by the embodiment of the invention, a software platform for converting the test cases generated by the visual test decision table method into executable test codes can be developed, and the software platform can store the test cases which are analyzed as the father key table by the module into a form of a sub-table in the platform database, and visually display the data content in the platform browser, so that the user can browse and view conveniently. Preferably, the software platform may also provide an efficient use case indexing mechanism for querying module analysis documents, scene analysis documents, and automatically generated test case executable test code programs of a business model according to multiple hierarchical dimensions of products, components, constraint value groupings, and the like.
Fig. 7 is a flowchart of an alternative method for converting a test case generated by a visual test decision table method into Java test code, as shown in fig. 7, based on a service model, according to a test model analyzed by a test data determining module of a boundary value method, an equivalence class method or an error push algorithm, the test data may be data uploaded to a platform in an excel table form, or may be data in a table form newly added to an online editing page provided by the platform. Grouping all business attribute objects in the business model according to business rules, adopting a decision table method according to the grouped data, selecting different combination strategies in a table form, and automatically generating a visual decision table containing constraint value relations by a platform, wherein the decision table can be downloaded by the platform. The constraint value relation table generated by the decision table method is automatically converted into test cases, all cases can be maintained and displayed in a platform, the test cases are clearly classified according to module analysis and test services, and a user can quickly locate the positions of the test cases to be checked. For test cases in the platform, all cases can be processed through the platform algorithm, executable test case codes (namely, junit test codes) are generated, a code downloading function is provided, and a user can directly copy the downloaded test codes to an integrated development environment for operation. In addition, all data in the platform can be inquired out through the platform retrieval function, the inquiry function of a plurality of hierarchical dimensions is 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 invention also provides a test code generating device based on a decision table method, as described in the following embodiment. Because the principle of solving the problem of the embodiment of the device is similar to that of 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 the repetition is omitted.
Fig. 8 is a schematic diagram of a test code generating device based on a decision table method according to an embodiment of the present invention, where, as shown in fig. 8, the device 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; the constraint value relation generating module 82 is configured to generate a constraint value relation table according to the value range of each service attribute object based on a decision table method, where the constraint value relation table includes: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to constraint value relations among all business attribute objects in a business scene; a test case generation module 83, configured to generate one or more test cases according to the constraint value relation table, where each test case corresponds to a set of constraint value relations; 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.
According to the test code generating device based on the decision table method, a module analysis module 81 is used for obtaining the value range of one or more business attribute objects in a business model, a constraint value relation table containing constraint value relations among business attribute objects under different business scenes is generated according to the value range of each business attribute object based on the decision table method through a constraint value relation generating module 82, then test cases corresponding to different business scenes of each business attribute object are generated according to the constraint value relations among business attribute objects contained in the constraint value relation table through a test case generating module 83, and finally test codes corresponding to each test case are generated according to the value range of each business attribute object in each test case and the constraint value relations among business attribute objects through a test code generating module 84.
The test code generating device based on the decision table method can generate executable test case codes based on the decision table method in a visual mode, so that code coding quantity is greatly reduced, a tester without code writing experience can participate in unit test, the multi-dimension degree ensures the test case quality of the unit test, in addition, constraint value relation is generated based on the decision table method, and the generated test case can realize full-service logic coverage.
In an optional embodiment, in the test code generating device 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 pre-configured service model, where the service model includes: the value range of each business attribute object is preconfigured; grouping all the business attribute objects contained in the business model by adopting a module analysis mode; the value range of one or more business attribute objects contained in each packet is obtained.
In another alternative embodiment, in the test code generating device based on the decision table method according to 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 preconfigured service model.
In an optional embodiment, the test code generating device based on the decision table method provided by the embodiment of the invention may further include: the parameter configuration module 85 is configured to receive a parameter configuration instruction, where the parameter configuration instruction is configured to configure a value range of each service attribute object.
In an alternative embodiment, in the test code generating device based on the decision table method provided by the embodiment of the present invention, the constraint value relationship generating module 82 may be further configured to obtain a preconfigured decision table template; generating a decision table containing constraint value relations among all business attribute objects in a plurality of business 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 constraint value relations among all business attribute objects under all business scenes and observation items and expected values of all business scenes.
Optionally, in the test code generating device based on the decision table method provided by 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, misspeculation method.
In an optional embodiment, the test code generating device based on the decision table method provided by the embodiment of the invention may further include: the code downloading module 86 is configured to receive a code downloading instruction, where the code downloading instruction is configured to download the test code corresponding to each test case.
Based on the same inventive concept, the embodiment of the invention also provides a computer device, which is used for solving the technical problems of poor readability, easy error, inconvenient management and low test efficiency of code-form test cases in the existing test drive development.
Based on the same inventive concept, 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 test efficiency of the code-form test cases in the existing test drive development.
In summary, the embodiment of the invention provides a method, a device, a computer device and a computer readable storage medium for generating test codes based on a decision table method, which generate test cases based on the decision table method, have better visualization and readability, and the visualized test model can be used for seeing test cases which can not be seen by a developer before for users (such as business experts, testers and the like) who cannot write codes, and the test cases can be converted into executable test codes, so that convenience is provided for the developer to execute the test cases. The embodiment of the invention can provide the test cases of the general language, so that service experts and testers can contact the unit test in advance, and carry out unit test review and writing together with developers, thereby ensuring the test quality. In addition, the decision table method can realize full coverage of service logic, can help personnel with weak service capability to guide service scene design cases which are not considered, ensure that service scenes can be tested, minimize risks before writing products, discover problems in advance, and reduce risks and workload caused by later modification defects.
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 based on the business model, so that the business attribute and the business service behavior in the module analysis are in one-to-one correspondence with the code architecture of the product, and the constraint value relation analysis is a subset of the module grouping of the module analysis, so that the test data and the attribute of the observation item of the test case written under the constraint value relation analysis are in the code architecture of the product, so that the test case written by the constraint relation analysis can be converted into the executable code-level test case code by the decision-making method based on the decision-making method provided by the embodiment of the invention, so that the discussion of the test case and the test scene by different role personnel together becomes possible, and the code written by the developer according to the unit test case is more reliable, thereby providing a convenient function for generating the test code for test drive development, and reducing the writing test code workload of the developer. In addition, the embodiment of the invention can conveniently search and display the tested cases through the omnibearing search function.
It will be appreciated by those skilled in the art that 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 flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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 foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.

Claims (9)

1. A test code generation method based on a decision table method is characterized by comprising the following steps:
acquiring a value range of one or more business attribute objects in a business model; wherein, the business model refers to objects and elements related to the business, and their attributes, behaviors and relationships among each other in a software model mode; the business model comprises business attribute objects, and business association relations are arranged among the business attribute objects;
based on a decision table method, generating a constraint value relation table according to the value range of each business attribute object, wherein the constraint value relation table comprises: multiple groups of constraint value relations, wherein each group of constraint value relations corresponds to constraint value relations among all business attribute objects in a business 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;
generating a 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 relation among each business attribute object;
based on decision table method, generating constraint value relation table according to the value range of each business attribute object, including:
According to the value range of each business attribute object, different decision table methods are adopted, and test cases under different business scenes are obtained through combined writing;
taking the written service scene test cases as decision table templates;
obtaining a pre-configured decision table template;
generating a decision table containing constraint value relations among all business attribute objects in a plurality of business scenes according to a pre-configured decision table template;
receiving observation items and expected values configured for each service scene;
and generating the constraint value relation table according to the constraint value relation among the business attribute objects in each business scene and the observation items and the expected values of each business scene.
2. The method of claim 1, wherein obtaining a range of values for one or more business attribute objects in a business model comprises:
obtaining a pre-configured service model, wherein the service model comprises: the value range of each business attribute object is preconfigured;
grouping all the business attribute objects contained in the business model by adopting a module analysis mode;
the value range of one or more business attribute objects contained in each packet is obtained.
3. The method of claim 1, wherein obtaining a range of values for one or more business attribute objects that are pre-configured comprises:
and receiving an externally imported module analysis document, wherein the module analysis document comprises a value range of one or more business attribute objects in a pre-configured business 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 business attribute object.
5. The method of claim 1, wherein the decision table templates comprise decision table templates generated by any one of the following decision table methods: equivalence class method, boundary value method, misspeculation method.
6. The method of claim 1, wherein after generating the test code corresponding to each test case based on the range of values of the respective business attribute objects in each test case and the constraint value relationships between the respective business attribute objects, 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.
7. A test code generation apparatus based on a decision table method, comprising:
the module analysis module is used for acquiring the value range of one or more business attribute objects in the business model; wherein, the business model refers to objects and elements related to the business, and their attributes, behaviors and relationships among each other in a software model mode; the business model comprises business attribute objects, and business association relations are arranged among the business attribute objects;
the constraint value relation generation module is used for generating a constraint value relation table according to the value range of each business 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 constraint value relations among all business attribute objects in a business 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;
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 relation among the service attribute objects;
The constraint value relation generation module is specifically configured to:
according to the value range of each business attribute object, different decision table methods are adopted, and test cases under different business scenes are obtained through combined writing;
taking the written service scene test cases as decision table templates;
obtaining a pre-configured decision table template;
generating a decision table containing constraint value relations among all business attribute objects in a plurality of business scenes according to a pre-configured decision table template;
receiving observation items and expected values configured for each service scene;
and generating the constraint value relation table according to the constraint value relation among the business attribute objects in each business scene and the observation items and the expected values of each business scene.
8. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the decision table method based test code generation method of any of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program that executes the decision table method-based test code generation method of any one of claims 1 to 6.
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 CN111143228A (en) 2020-05-12
CN111143228B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111858324B (en) * 2020-07-13 2023-08-25 中国工商银行股份有限公司 Automatic generation method and device for test cases
CN112905461B (en) * 2021-02-09 2024-03-15 中国工商银行股份有限公司 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

Also Published As

Publication number Publication date
CN111143228A (en) 2020-05-12

Similar Documents

Publication Publication Date Title
CN111158656B (en) Test code generation method and device based on fruit tree method
EP3511836A1 (en) Generation of automated testing scripts by converting manual test cases
CN110008113B (en) Test method and device and electronic equipment
Müller et al. Automated analysis of conflicts in ws-agreement
WO2007001108A1 (en) System for providing feature-oriented software product line engineering environment
CN103180834B (en) Automatic operation system test frame
CN111143228B (en) Test code generation method and device based on decision table method
US20050137839A1 (en) Methods, apparatus and programs for system development
Popoola et al. EMG: A domain-specific transformation language for synthetic model generation
CN113138937A (en) Test method and device
CN113051262B (en) Data quality inspection method, device, equipment and storage medium
CN114385155A (en) vue project visualization tool generation method, device, equipment and storage medium
CN114647568A (en) Automatic testing method and device, electronic equipment and readable storage medium
CN111414194A (en) Interface information generation method and system, electronic equipment and storage medium
Archer et al. Specifying and proving properties of timed I/O automata using Tempo
CN109669868A (en) The method and system of software test
Pulido Applying behavior driven development practices and tools to low-code technology
Soffer et al. Model-Based Requirements Engineering Framework for Systems Life-Cycle Support
US12008362B2 (en) Software development environment
Heck et al. LaQuSo software product certification model (LSPCM)
CN114816425B (en) Method and system for converting an automation language program into a LUA language program
US20240176722A1 (en) Automated public certification of specifications and software
Qazi et al. Model driven architecture with encapsulated quality check and enhancement feature
CN113220591A (en) Method and device for generating test data
Mansurov Automatic synthesis of SDL from MSC and its applications in forward and reverse engineering

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