Generation Device, Generation Method, and Program
Patent Information
- Application Number
- JP2021182566
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-11-09
- Publication Date
- 2025-06-02
- Estimated Expiration
- 2041-11-09
AI Technical Summary
Conventional WebAPI testing requires extensive manual effort for test code development due to numerous parameter variations, leading to increased development time and potential deterioration in test quality.
A generation device comprising an analysis unit, test scenario generation unit, and test code generation unit that automatically generates test code for WebAPI based on structural analysis data and test setting files, reducing the need for manual test code creation.
Automated test code generation significantly reduces development time and burden on developers, enabling efficient and comprehensive WebAPI testing.
Smart Images

Figure 00000009_0000 
Figure 00000010_0000 
Figure 00000011_0000
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to a generation device, a generation method, and a program.
Background Art
[0002] In a Web API (Web Application Programming Interface), there are a plurality of parameters for one path. For each of these parameters, a large number of tests such as upper limit boundary value, lower limit boundary value, and standard value checks occur. Just a slight change in the path and parameters results in a large number of test changes and increases, making the development of test code a burden for developers in charge of testing. There is also a secondary problem that if the creation of test code is insufficient, the quality of the Web API, which is the work product, will decline.
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Patent Document 2
Summary of the Invention
Problems to be Solved by the Invention
[0004] In the conventional technology, it has been difficult to shorten the development time of test code for testing Web APIs.
Means for Solving the Problems
[0005] The embodiment of the generation apparatus comprises an analysis unit, a test scenario generation unit, and a test code generation unit. The analysis unit analyzes a definition file that defines the structure of a Web API (Web Application Programming Interface) and generates structural analysis data for the Web API. The test scenario generation unit generates test scenario data for the Web API from a test setting file that includes the test type of the Web API and the test items for each test type, and from the structural analysis data. The test code generation unit generates test code to test the Web API based on the test scenario data. [Brief explanation of the drawing]
[0006] [Figure 1] A diagram illustrating the development flow of the Web API in the first embodiment. [Figure 2] A diagram showing an example of the functional configuration of the generation apparatus according to the first embodiment. [Figure 3] A diagram showing an example of a test configuration file for the first embodiment. [Figure 4] A flowchart showing an example of the generation method of the first embodiment. [Figure 5] A diagram showing an example of a test configuration file for the second embodiment. [Figure 6] A flowchart showing an example of the generation method of the second embodiment. [Figure 7] A diagram showing examples of the hardware configuration of the generation apparatus of the first and second embodiments. [Modes for carrying out the invention]
[0007] The embodiments of the generation apparatus, generation method, and program will be described in detail below with reference to the attached drawings.
[0008] (First Embodiment) First, we will describe the development flow of the Web API in the first embodiment.
[0009] Figure 1 is a diagram illustrating the development flow of a Web API in the first embodiment. Figure 1 shows an example of the development flow of a Web API for a cloud system of an air conditioning manufacturer providing infrastructure services. Generally, Web API development includes a Web API design phase, a Web API implementation phase, a Web API test code implementation phase, and a Web API testing phase. After the Web API tests are performed, if there are no problems with the quality of the Web API, the Web API is released.
[0010] The need to prepare a large number of test patterns for Web APIs was a burden on test developers. For example, conventional automated test code generation systems could only generate normal cases and some abnormal cases of Web APIs that could be confirmed from the Web API definition file.
[0011] The generation device of the first embodiment relates to a device for automatically generating test code for Web APIs in Web API development. According to the generation device of the first embodiment described below, the test code implementation process can be automated, significantly reducing the time spent on test code development. Furthermore, the testing process can also be shortened by loading the test code generated by the generation device of the first embodiment into a commercially available or free automated test execution tool (e.g., Tavern). This automates the time-consuming task of creating test code in software development, thereby reducing the burden on test code developers.
[0012] [Example of functional configuration] Figure 2 shows an example of the functional configuration of the generation device according to the first embodiment. The generation device 10 according to the first embodiment comprises an analysis unit 1, a test scenario generation unit 2, and a test code generation unit 3.
[0013] The analysis unit 1 analyzes the definition file 101 that defines the structure of the Web API and generates Web API structure analysis data 102. The definition file 101 includes, for example, the source code of the Web API.
[0014] The test scenario generation unit 2 generates test scenario data 104, which represents the test scenario for the Web API, from the test configuration file 103, which includes the test type of the Web API and the test items for each test type, and the structural analysis data 102. This test scenario data 104 is used to generate test code 105, which is actually executed as a program.
[0015] The test code generation unit 3 generates test code 105 to test the Web API based on the test scenario data 104.
[0016] [Example of a test configuration file] Figure 3 shows an example of a test configuration file 103 in the first embodiment. The test configuration file 103 is used to generate test scenario data 104 to verify the functionality of the Web API. In the example in Figure 3, the parameter type information (test type of parameter) of the Web API parameters is included as a variation of the Web API test type.
[0017] Parameter type <integer>includes test items "zero", "max", "min", and "string". The test item "zero" is an item that performs a test by substituting 0 (or a null character if it is a string type) into the parameter. The test item "max" is an item that performs a test by substituting the maximum value of the parameter into the parameter. The test item "min" is an item that performs a test by substituting the minimum value of the parameter into the parameter. The test item "string" is an item that performs a test by substituting string data into the parameter.
[0018] Parameter type <string>includes test items "zero", "byte", and "len". The test item "zero" is an item that performs a test by substituting a null character (0 if it is a numerical type) into the parameter. The test item "byte" is an item that performs a test by substituting, for example, string data of 2-byte code into the parameter. The test item "len" is an item that performs a test by substituting, for example, string data with the maximum string length that can be substituted into the parameter.
[0019] Note that FIG. 3 is an example, and for test items for each parameter type, test items for testing arbitrary data such as upper limit values, lower limit values, standard values, and abnormal values corresponding to the parameter type may be defined.
[0020] [Example of generation method] FIG. 4 is a flowchart showing an example of the generation method of the first embodiment. First, the analysis unit 1 reads the definition file 101 of the WebAPI (step S1). The definition file 101 is created, for example, by a WebAPI developer. The format of this definition file 101 is described in a machine-readable format. The machine-readable format may be any of OpenAPI, WSDL (Web Services Description Language), or SOAP (Simple Object Access Protocol), etc. For simplicity of explanation, hereinafter, the case of using OpenAPI will be described.
[0021] Next, the analysis unit 1 analyzes the definition file 101 (OpenAPI) read in step S1 (step S2), and generates structure analysis data 102 showing the structure of the WebAPI. The structure analysis data 102 includes parameter information of the WebAPI. This structure analysis data 102 is input to the test scenario generation unit 2.
[0022] Here, the structure of a Web API includes, for example, path information of the Web API described in OpenAPI, the HTTP method access method for each path, parameter names (for example, combinations of path and method), and parameter type information (for example, parameter types such as integer and string).
[0023] Next, the test scenario generation unit 2 reads the test configuration file 103 (see Figure 3) (step S3). The test configuration file 103 is written, for example, in a proprietary format DSL (Domain-Specific Language).
[0024] Next, the test scenario generation unit 2 confirms the types of parameters (parameter types) included in the Web API based on the structural analysis data 102 and the test configuration file 103 (step S4). Specifically, the test scenario generation unit 2 confirms the parameter type for each combination of path and method from the Web API parameter information identified by the structural analysis data 102. Then, the test scenario generation unit 2 compares this parameter type with the parameter type in the test configuration file 103.
[0025] Next, the test scenario generation unit 2 checks the test type (test item) of the parameter confirmed in step S4 (step S5). Specifically, for each parameter type matched in the process of step S4, the test scenario generation unit 2 obtains the test item for that parameter type from the test setting file 103.
[0026] Next, the test scenario generation unit 2 generates test scenario data 104 based on the test items obtained through the processing in step S5 (step S6). For example, if the test item is "zero", the test scenario generation unit 2 generates a test scenario that puts the value 0 into the Web API parameter value, specifically 0 for numeric types and the null character for string types, and queries the server device.
[0027] Finally, the test code generation unit 3 generates test code 105 that will actually be executed by the automated test execution tool based on the test scenario data 104 generated by the processing in step S6 (step S7).
[0028] As explained above, the generation device 10 of the first embodiment can shorten the development time of test code 105 for testing Web APIs. Specifically, there are multiple parameters for a single path specific to Web APIs, and tests such as upper and lower boundary value checks and standard value checks for each parameter cannot be represented in the Web API definition file 101. The test code generation unit 3 reads test items for each parameter type (parameter type) contained in the test setting file 103, which is defined separately from the definition file 101, and can automatically generate test code 105 for the multiple parameters that exist for each combination of Web API path and method.
[0029] According to the first embodiment, Web API developers can prepare test code simply by creating a Web API definition file 101 in accordance with the specifications, thereby reducing the burden on developers. Specifically, for example, it becomes easier to expand the variations of test items for each parameter type of the Web API, and the time required for test code development can be significantly reduced.
[0030] Traditionally, it was not possible to automatically generate all test code specific to Web APIs. For example, while a technology that creates test code templates from definition files 101 for configuring Web APIs, such as workflow documents and interface documents, could reduce the burden on test developers, the reduction was limited as a human still had to write the code. Similarly, in a technology that automatically runs the next test after a test is executed, changing parameters and generating new test code, a human still had to write the initial test code.
[0031] (Second Embodiment) Next, a second embodiment will be described. In the description of the second embodiment, explanations similar to those of the first embodiment will be omitted, and the differences from the first embodiment will be described.
[0032] In the second embodiment, the description format of the test configuration file 103 differs from that of the first embodiment. By providing a new test configuration file 103 for the second embodiment in addition to the Web API definition file 101, it becomes possible to output test code for authentication and authorization in the Web API, as well as for irregular abnormal case tests.
[0033] In the first embodiment, a test scenario was generated that covered all tests of the values assigned to the parameters of the Web API. In the second embodiment, a configuration is described that allows for the addition of test items that include up to a certain point in the processing flow, such as authentication and authorization (up to the failure of the process).
[0034] [Example of a test configuration file] Figure 5 shows an example of the test configuration file 103 of the second embodiment. In the example in Figure 5, the Web API test type includes Web API flow information (flow-type test type) and Web API parameter-type information (parameter-type test type). In addition, in the test configuration file 103 of the second embodiment, the test type is set for each combination of Web API path and method.
[0035] Flow information <flow>This includes the test path in the order of test items "auth", "login", and "token". Test item "auth" is a test item that tests the success and failure patterns of the authentication process. Test item "login" is a test item that tests the success and failure patterns of the login process when the authentication process is successful. Test item "token" is a test item that tests the success and failure patterns of the token process when the login process is successful.
[0036] Flow information in Figure 5 <flow>This is just one example; the flow information can be any test item that verifies the execution order of a series of processes included in the flow.
[0037] [Example of generation method] Figure 6 is a flowchart showing an example of the generation method of the second embodiment. The processing of steps S1 to S7 is the same as the generation method of the first embodiment (see Figure 4), so the explanation is omitted. The differences from the first embodiment are that the contents of the test setting file 103 are different, new flow information has been added, and steps S8 to S10 have been added to the operation flow.
[0038] The generation device 10 operates in the same manner as in the first embodiment up to step S3. Next, the test scenario generation unit 2 determines whether to test the parameter information or the sequential processing (flow information) for each combination of path and method included in the test setting file 103 (step S8).
[0039] When testing parameter information, the process transitions to step S4, and the generation device 10 performs the same processing as in the first embodiment.
[0040] When testing flow information, the test scenario generation unit 2 confirms the test target path of the flow information included in the Web API based on the structural analysis data 102 and the test configuration file 103 (step S9). For example, in the example of the test configuration file 103 in Figure 5, the test scenario generation unit 2 checks the flow information <flow>The test target path is obtained in the order of "auth", "login", and "token". Then, the test scenario generation unit 2 identifies the flow corresponding to this test target path from the Web API flow information (information showing the structure of the Web API flow) included in the structural analysis data 102.
[0041] Next, the test scenario generation unit 2 generates test scenario data 104 corresponding to the test target path (step S10). For example, in the example of the test setting file 103 in Figure 5, the test scenario generation unit 2 adds the following first to fourth test scenarios to the test scenario data 104.
[0042] The first test scenario is one in which the authentication process for test item "auth" fails.
[0043] The second test scenario is one in which the authentication process for test item "auth" is successful, but the authentication process for test item "login" fails.
[0044] The third test scenario is one in which the authentication process for test item "auth" is successful, the authentication process for test item "login" is successful, and the authentication process for test item "login" fails.
[0045] The fourth test scenario is one in which the authentication process for test item "auth" is successful, the authentication process for test item "login" is successful, and the authentication process for test item "login" is successful.
[0046] After the processing in step S10, the process transitions to step S7, where the same processing as in the first embodiment is performed.
[0047] As explained above, the second embodiment can also handle testing when it is necessary to use other Web APIs to execute one Web API. For example, in the case of testing a Web API that involves authentication and authorization, testing may be required for multiple test target paths depending on the authorization method. Even in such cases, the second embodiment allows testing to be performed sequentially for each path, which is expected to reduce the burden on developers in creating tests. This will significantly reduce the time spent on developing test code.
[0048] Finally, examples of the hardware configuration of the generation device 10 in the first and second embodiments will be described.
[0049] [Example hardware configuration] Figure 7 shows examples of the hardware configuration of the generation apparatus 10 in the first and second embodiments. The generation apparatus 10 in the first and second embodiments comprises a control device 201, a main memory 202, an auxiliary storage device 203, a display device 204, an input device 205, and a communication device 206. The control device 201, the main memory 202, the auxiliary storage device 203, the display device 204, the input device 205, and the communication device 206 are connected via a bus 210.
[0050] Note that the generation device 10 in the first and second embodiments may not be equipped with some of the above-described components. For example, if the generation device 10 can utilize the input and display functions of an external device, the generation device 10 may not be equipped with a display device 204 and an input device 205.
[0051] The control device 201 executes the program read from the auxiliary storage device 203 into the main storage device 202. The main storage device 202 is memory such as ROM and RAM. The auxiliary storage device 203 is such as an HDD (Hard Disk Drive) and a memory card.
[0052] The display device 204 is, for example, a liquid crystal display. The input device 205 is an interface for operating the access point device 20. The display device 204 and the input device 205 may be implemented by a touch panel or the like that has both display and input functions. The communication device 206 is an interface for communicating with other devices.
[0053] The program executed by the generation device 10 is recorded in an installable or executable file format on a computer-readable storage medium such as a CD-ROM, memory card, CD-R, or DVD and provided as a computer program product.
[0054] Alternatively, the program executed by the generation device 10 may be stored on a computer connected to a network such as the Internet and provided by being downloaded via the network. Alternatively, the program executed by the generation device 10 may be provided via a network such as the Internet without requiring downloads.
[0055] Alternatively, the program for the generation device 10 may be pre-installed and provided in ROM or the like.
[0056] The program executed by the generation device 10 has a modular configuration that includes functions that can also be implemented by the program, as shown in the functional configuration of Figure 2 above. In actual hardware terms, each of these functions is loaded onto the main memory 202 by the control device 201 reading and executing the program from the storage medium. In other words, each of the above function blocks is generated on the main memory 202.
[0057] It should be noted that some or all of the functions shown in Figure 2 above may be implemented using hardware such as ICs instead of software.
[0058] Furthermore, when multiple processors are used to implement each function, each processor may implement one of the functions, or it may implement two or more of the functions.
[0059] While several embodiments of the present invention have been described, these embodiments are presented as examples only and are not intended to limit the scope of the invention. These novel embodiments can be carried out in a variety of other forms, and various omissions, substitutions, and modifications can be made without departing from the spirit of the invention. These embodiments and their variations are included in the scope and spirit of the invention, as well as in the claims of the invention and its equivalents. [Explanation of Symbols]
[0060] 1 Analysis section 2. Test Scenario Generation Unit 3. Test Code Generation Unit 10 Generator 201 Control device 202 Main storage 203 Auxiliary storage device 204 Display device 205 Input device 206 Communication equipment 210 Bus< / flow> < / flow> < / flow> < / string> < / integer>
Claims
1. an analysis unit that analyzes a definition file that defines a structure of a Web API (Web Application Programming Interface) and generates structural analysis data of the Web API; a test scenario generation unit that generates test scenario data for the Web API from a test setting file including test types for the Web API and test items for each test type, and the structural analysis data; a test code generation unit that generates test code for testing the Web API based on the test scenario data; A generating device comprising:
2. the structural analysis data includes parameter information of the Web API; The test type includes a parameter type of the Web API; the test scenario generation unit generates test scenario data for testing test items for each parameter type for the parameters of the Web API identified from the parameter information; The generating device of claim 1 .
3. The test items for each parameter type include at least one of an upper limit value, a lower limit value, a standard value, and an abnormal value according to the parameter type. The generating device of claim 2 .
4. The structural analysis data includes flow information of the Web API, the test type includes a flow type of the Web API; the test scenario generation unit generates test scenario data for testing test items for each flow type in the Web API flow identified from the structural analysis data; The generating device of claim 1 .
5. The test items for each flow type include a test to check the execution order of a series of processes included in the flow. The generating device of claim 4 .
6. The definition file is written in a machine-readable format. A generating device according to any one of claims 1 to 5.
7. The machine-readable format is OpenAPI, WSDL (Web Services Description Language) or SOAP (Simple Object Access Protocol); The generating device of claim 6.
8. The test setting file is written in a proprietary format, DSL (Domain-Specific Language), A generating device according to any one of claims 1 to 7.
9. A generating device analyzes a definition file that defines a structure of a Web API (Web Application Programming Interface) and generates structural analysis data of the Web API; The generation device generates test scenario data for the Web API from a test setting file including test types of the Web API and test items for each test type, and from the structural analysis data; generating test code for testing the Web API based on the test scenario data by the generating device; A generation method including:
10. Computer, an analysis unit that analyzes a definition file that defines a structure of a Web API (Web Application Programming Interface) and generates structural analysis data of the Web API; a test scenario generation unit that generates test scenario data for the Web API from a test setting file including test types for the Web API and test items for each test type, and the structural analysis data; a test code generation unit that generates test code for testing the Web API based on the test scenario data; A program to function as a