A test case generation method and device, electronic equipment and medium

CN111506511BActive Publication Date: 2026-09-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010316948.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-21
Publication Date
2026-09-25
Estimated Expiration
2040-04-21

AI Technical Summary

Technical Problem

[0004]为了解决现有技术应用在进行测试用例生成时,效率低等问题,本发明提供了一种测试用例生成方法、装置、电子设备及介质:

Benefits of technology

[0020]本发明基于业务请求自动生成目标测试用例,不需要关注该业务请求执行中相关联的硬件层服务对象以及硬件层服务对象涉及的库表结构,能够提高测试用例的生成效率,可以更好的满足需要进行快速测试的场景的需求。基于所述业务请求的执行情况获取服务调用链路信息和数据库调用信息,实现对业务请求的执行状态的有效追踪,相应的,这些更具全局性的数据为生成更具准确度的测试用例提供了保障。根据测试规则从所述服务调用链路信息所指示的链路中选取出测试节点,在测试规则的指导下选取测试节点,可以保证生成的测试用例更具针对性和实用性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111506511B_ABST
    Figure CN111506511B_ABST
Patent Text Reader

Abstract

The application discloses a test case generation method and device, electronic equipment and medium. The method comprises the following steps: receiving a service request; executing the service request, and obtaining service call link information and database call information based on the execution of the service request; selecting a test node from a link indicated by the service call link information according to a test rule; obtaining target associated data based on the test node and the database call information; and generating the target test case based on the service request, the service call link information and the target associated data. The application does not need to pay attention to the associated hardware layer service object in the execution of the service request and the library table structure involved by the hardware layer service object, can improve the generation efficiency of the test case, and can better meet the needs of the scene requiring rapid testing. The test node is selected under the guidance of the test rule, so that the generated test case is more targeted and practical.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Internet communication technology, and in particular to a test case generation method, apparatus, electronic device, and medium. Background Technology

[0002] With the continuous development of internet communication technology, providing various business services using internet communication technology has become a mainstream trend. The implementation of business services often requires calling corresponding service objects for support. To ensure the effective implementation of business functions, relevant testing is necessary.

[0003] In related technologies, testing service objects often requires staff to manually write corresponding test cases. For example, staff might manually write test cases for the service object under test based on keyword-driven principles, input the written test cases into the service object, and then use the keyword information returned by the service object for structural verification. However, the workload of manually writing test cases is enormous, and consequently, the test case generation speed is slow, making it difficult to meet the needs of scenarios requiring rapid testing. Therefore, a more efficient solution for generating test cases is needed. Summary of the Invention

[0004] To address the low efficiency and other issues associated with existing technologies in test case generation, this invention provides a test case generation method, apparatus, electronic device, and medium:

[0005] On one hand, the present invention provides a test case generation method, the method comprising:

[0006] Receive service requests;

[0007] Execute the business request, and obtain service call chain information and database call information based on the execution status of the business request;

[0008] Test nodes are selected from the links indicated by the service call link information according to the test rules;

[0009] The target associated data is obtained based on the test node and the database call information;

[0010] The target test cases are generated based on the business request, the service call chain information, and the target associated data.

[0011] On the other hand, a test case generation device is provided, the device comprising:

[0012] Request receiving module: Used to receive business requests;

[0013] Information acquisition module: used to execute the business request, and to acquire service call chain information and database call information based on the execution status of the business request;

[0014] Node selection module: used to select test nodes from the links indicated by the service call link information according to the test rules;

[0015] Data acquisition module: used to obtain target associated data based on the test node and the database call information;

[0016] Test case generation module: used to generate the target test cases based on the business request, the service call chain information and the target associated data.

[0017] On the other hand, an electronic device is provided, comprising a processor and a memory, wherein the memory stores at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the test case generation method as described above.

[0018] On the other hand, a computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored therein, the at least one instruction or the at least one program being loaded and executed by a processor to implement the test case generation method as described above.

[0019] The present invention provides a test case generation method, apparatus, electronic device, and medium, which have the following technical effects:

[0020] This invention automatically generates target test cases based on business requests, without needing to consider the associated hardware layer service objects or the database table structures involved in the execution of the business request. This improves the efficiency of test case generation and better meets the needs of scenarios requiring rapid testing. By acquiring service call chain information and database call information based on the execution status of the business request, effective tracking of the execution status of the business request is achieved. Consequently, this more global data ensures the generation of more accurate test cases. Test nodes are selected from the chain indicated by the service call chain information according to test rules. Selecting test nodes under the guidance of test rules ensures that the generated test cases are more targeted and practical. Attached Figure Description

[0021] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0022] Figure 1 This is a schematic diagram of an application environment provided by an embodiment of the present invention;

[0023] Figure 2 This is a flowchart illustrating a test case generation method provided in an embodiment of the present invention;

[0024] Figure 3 This is a schematic diagram of a process for generating the target test case based on the business request, the service call chain information, and the target associated data, according to an embodiment of the present invention.

[0025] Figure 4 This is also a flowchart illustrating a test case generation method provided in an embodiment of the present invention;

[0026] Figure 5 This is a schematic diagram of the architecture of the test case generation platform provided in an embodiment of the present invention;

[0027] Figure 6 This is a flowchart illustrating a web layer in the architecture design provided by an embodiment of the present invention;

[0028] Figure 7 This is a flowchart illustrating the business logic layer in the architecture design provided by an embodiment of the present invention;

[0029] Figure 8 This is a block diagram of a test case generation device provided in an embodiment of the present invention;

[0030] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0031] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0032] It should be noted that the terms "comprising" and "having" and any variations thereof in the specification, claims, and accompanying drawings of this invention are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices.

[0033] Please see Figure 1 , Figure 1 This is a schematic diagram of an application environment provided by an embodiment of the present invention, which may include a client 01 and a server 02, with the client and server connected via a network. Staff can send business requests to the server through the client, and the server generates target test cases based on the received business requests. It should be noted that... Figure 1 This is just one example.

[0034] Specifically, client 01 can include physical devices such as smartphones, desktop computers, tablets, laptops, augmented reality (AR) / virtual reality (VR) devices, digital assistants, and smart wearable devices. It can also include software running on physical devices, such as computer programs. The operating system running on client 01 can include, but is not limited to, Android, iOS (a mobile operating system developed by Apple), Linux, and Microsoft Windows.

[0035] Specifically, server 02 may include a standalone server, a distributed server, or a server cluster consisting of multiple servers. Server 02 may include a network communication unit, a processor, and memory, etc. Server 02 can provide background services for the aforementioned clients.

[0036] The following describes a specific embodiment of a test case generation method according to the present invention. Figure 2 This is a flowchart illustrating a test case generation method provided by an embodiment of the present invention. This specification provides the operational steps of the method described in the embodiments or flowchart, but based on conventional or non-creative labor, more or fewer operational steps may be included. The order of steps listed in the embodiments is merely one possible execution order among many and does not represent the only execution order. In actual system or server product execution, the method can be executed sequentially according to the embodiments or drawings, or in parallel (e.g., in a parallel processor or multi-threaded processing environment). Specifically, as shown in the figures... Figure 2 As shown, the method may include:

[0037] S201: Receive service request;

[0038] In this embodiment of the invention, the server receives a business request sent by the client. Both the server and client point to the same business platform, which provides users with relevant business services, such as financial services. The financial services provided may include third-party payments for B2C (Business-to-Consumer) and B2B (Business-to-Business) e-commerce models. Correspondingly, the business request may be a payment request, a refund request, or an order generation request.

[0039] The service request is sent by the client, which can be a smartphone, desktop computer, tablet, laptop, augmented reality / virtual reality device, digital assistant, smart wearable device, or other similar physical device. The operating system of this physical device can be Android, iOS, Linux, Microsoft Windows, etc. The triggering object for sending the service request using this client can be a real user or a testing tool. When a real user is the triggering object, it can correspond to a real environment or a testing environment (e.g., a tester); when a testing tool is the triggering object, it can correspond to a testing environment. There are no restrictions on the geographical location or network status of the client when sending the service request. Furthermore, the type of physical device, the type of operating system, the aforementioned geographical location, and the aforementioned network status can be used as basic parameters carried in the service request, which facilitates subsequent analysis of the execution of the target test cases.

[0040] S202: Execute the business request, and obtain service call chain information and database call information based on the execution status of the business request;

[0041] In this embodiment of the invention, the response result obtained by the server in executing the business request can be either success or failure. The time of receiving the business request and the time of execution can correspond to the current time period or a historical time period. Accordingly, when corresponding to the current time period, the server can obtain the service call chain information and database call information based on the execution status of the business request in real time or after confirming the response result. When corresponding to a historical time period, the server obtains the service call chain information and database call information based on the execution status of the business request after confirming the response result.

[0042] Service call chain information characterizes the order in which business layer service objects are called during the execution of a business request. Database call information records the contents of database tables referenced by service objects (regardless of whether they are in the business layer or hardware layer) during the execution of a business request. This database call information includes intermediate and result data stored in the database. The obtained service call chain information and database call information ensure comprehensive tracking of the execution status of the business request.

[0043] In practical applications, for example, if business request A corresponds to a transfer of money from merchant B to user C, the server's execution of business request A first calls port A of service A, then port B of service B, and finally port C of service C. Therefore, the service call chain information (corresponding to business request A) indicates the chain as port A of service A -> port B of service B -> port C of service C. The database call information (corresponding to business request A) records the database table content referenced by port A of service A, port B of service B, and port C of service C.

[0044] In one specific embodiment, a monitoring file can be configured on the server side based on the database replication protocol before obtaining the database call information. Accordingly, the database call information can be obtained by running the monitoring file.

[0045] Specifically, a data collection agent module (slave_agent) for monitoring the database can be encapsulated based on the MySQL (Relational Database Management System) replication protocol, and installed on the specific device (where the database is hosted) on the server side. The data collection agent module collects the contents of all database tables involved in the execution of business requests. This content can include relevant database information for the entire process from start to finish of the business request. Essentially, the data collection agent module disguises itself as a backup machine for the corresponding database (MySQL), and as the backup machine, it will synchronize a copy of the data. It's important to note that to ensure successful collection of database table contents, the database needs to have its logging functionality enabled, such as binlog (MySQL's binary log).

[0046] In another specific embodiment, a mock-up collection agent module (moudel_agent) can be deployed on a specific device on the server side. This module can monitor the call chain between business layer service objects in real time during the execution of business requests. Of course, the mock-up collection agent module can also monitor the call chain between hardware layer service objects in real time during the execution of business requests.

[0047] S203: Select test nodes from the links indicated by the service call link information according to the test rules;

[0048] In this embodiment of the invention, the test rules can be general rules or personalized rules, and can be flexibly selected. The test rules include at least one of the following: test type and attributes of the object under test. The test type can correspond to functional testing (e.g., test parameter type, boundary values), performance testing (e.g., test response time, concurrency, and throughput), and security testing (e.g., test whether sensitive information is encrypted, whether the interface prevents malicious requests), etc. The attributes of the object under test can correspond to relevant attributes of business layer service objects and hardware layer service objects. Using interface attributes as a relevant attribute of hardware layer service objects can include input / output (IO) port attributes, memory-mapped input / output (MMIO) port attributes, named pipe attributes, shared memory attributes, and virtual bus attributes.

[0049] Test nodes are selected from the service call chain information according to the test rules. A test node can correspond to all or some of the business layer service objects included in the indicated chain. The general rules can be pre-configured on the server side, and the server can automatically select test nodes from the service call chain information according to the general rules.

[0050] In practical applications, a service call relationship diagram at the business level can be generated based on the aforementioned service call chain information. Compared to the chains indicated by the service call chain information, returning a service call relationship diagram to testers provides a more intuitive representation of the call relationships between service objects, making it easier for testers to select appropriate general rules or formulate personalized rules. Accordingly, test nodes are determined on the service call relationship diagram based on the aforementioned selected or formulated rules.

[0051] In one specific embodiment, before selecting test nodes from the links indicated by the service call link information according to the test rules, local environment configuration information can be obtained first; then, the indicated links can be labeled according to the local environment configuration information to obtain the labeling results. Accordingly, test nodes can be selected from the labeled links according to the test rules.

[0052] Specifically, the process of obtaining local environment configuration information involves: 1) determining business attributes before obtaining the local environment configuration information; then constructing a runtime environment based on the business attributes; 2) obtaining the local environment configuration information based on the runtime environment, which includes at least one of the following: device name, cluster information to which the device belongs, device interface information, device network information, and database field support information. In practical applications, the constructed runtime environment can correspond to an environment network that supports the normal implementation of business services. This environment network includes electronic devices and a collection of programs distributed across different electronic devices. The local environment configuration information can be hardware layer information entered by relevant personnel.

[0053] Referring to the relevant description of the service call chain information (corresponding to business request A) in step S202 above, it will not be repeated here. It can be seen that the service call chain information (corresponding to business request A) points to the call order of service objects in the business layer. Here, the marked chain points to the call order of service objects in the hardware layer, which is equivalent to performing a hardware-based marking process. For example, the A port of service A in the business layer is hardware-based marked to the c interface of server B, and the B port of service B in the business layer is hardware-based marked to the e interface of server A. Thus, the marked chain includes the c interface of server B -> the e interface of server A.

[0054] The hardware-based annotation process yields the calling order of hardware layer service objects involved in the execution of business requests. The test nodes selected using test rules also point to hardware layer service objects, which facilitates the checking of interface routing information when executing subsequent target test cases.

[0055] S204: Obtain the target associated data based on the test node and the database call information;

[0056] In this embodiment of the invention, since the database call information records comprehensive table content, the target database information corresponding to the test node can be extracted from the database call information, and this target database information is used as the target associated data. Compared to the database call information, the target associated data focuses more on the correlation between the table content and the test node, thus making the subsequently generated target test cases more targeted to the test node.

[0057] Referring to the relevant description of "hardware annotation processing" in step S203 above, it will not be repeated here. When the test node is selected from the annotated links according to the test rules, the content of the database tables involved in the hardware layer service object is considered when extracting the target related data from the database call information. For example, the content of the database tables involved in the relevant interfaces in the execution of business requests: the input parameters of the relevant interfaces, the output parameters of the relevant interfaces, etc. In this way, testers do not need to know the hardware layer service object (such as the interface) and the database table structure involved in the hardware layer service object in advance, do not need to encapsulate the query interface separately in advance, and do not need to modify the business code.

[0058] S205: Generate the target test case based on the business request, the service call chain information, and the target association data.

[0059] In this embodiment of the invention, unittest (a unit testing framework) can be used to combine business requests, service call chain information, and target-related data to write target test cases. Specifically, the business request is used as the input condition; the business parameters carried by the business request, the service call chain information, and the target-related data are used as the expected results; and the target test cases are generated based on the input conditions and the expected results. This allows for more proactive and multi-dimensional testing of related service objects by comparing previous executions of the same business request when using target test cases.

[0060] In one specific embodiment, referring to the relevant description of "hardware annotation processing" in step S203 above, it will not be repeated here. Accordingly, as Figure 3 As shown, generating the target test case based on the business request, the service call chain information, and the target association data includes:

[0061] S301: Use the service request as an input condition;

[0062] S302: The business parameters carried in the business request, the service call chain information, the annotation result, and the target association data are taken as the expected result;

[0063] S303: Generate the target test case based on the input conditions and the expected results.

[0064] For example, the service call chain information (corresponding to business request A) indicates a chain from port A of service A to port B of service B to port C of service C. The database call information (corresponding to business request A) records the database table content referenced by port A of service A, port B of service B, and port C of service C. The port A of service A in the business layer is hardware-annotated to interface c of server B, the port B of service B in the business layer is hardware-annotated to interface e of server A, and the port C of service C in the business layer is hardware-annotated to interface a of server D. Thus, the annotated chain is interface c of server B -> interface e of server A -> interface a of server D. If interface c of server B is selected as the test node, then the target associated data is the database table content mentioned in the database call information for interface c. Using the above information and the business parameters carried in the business request as the expected results of the target test case, it is possible to verify whether the response result obtained from executing the target test case matches the response result of the business request, whether the relevant parameters of the obtained test node are consistent with the target associated data, whether the order of business layer service object calls is consistent with the service call chain information, and whether the order of hardware layer service object calls matches the annotation results.

[0065] When generating target test cases using unittest, a separate file can be created for each interface, regardless of whether that interface is selected as a test node. When an interface is selected as a test node, the information representing that test node can be encapsulated into the corresponding file. Target test cases are generated by scanning these files.

[0066] In another specific embodiment, the server can return the generated target test cases to the test client (different from the client described in step S201). The test client provides testers with a user interface for viewing. The user interface can present testers with: 1) the service objects involved in the target test cases. Service objects can point to a broad category of business layer service objects or hardware layer service objects (e.g., service A, server A), or a subcategory of business layer service objects or hardware layer service objects (e.g., port A of service A, interface e of server A); 2) the machine attributes of the hardware layer service objects involved in the target test cases; 3) the database call information involved in the target test cases, the corresponding database table structures, and which servers these databases are hosted on. Among these, 1) and 2) ensure the automated display of the service call chain.

[0067] When the number of identical business requests increases or there are more diverse business requests, the number of target test cases generated also increases, resulting in a test suite. This test suite can be displayed in a mind map format within the user interface. This display allows for the configuration of different test cases for each service object, providing a clearer view of the test suite's structure. Testers can select test cases and trigger their execution, for example, by clicking a target button in the user interface. The user interface then provides a real-time view of the execution of the selected test cases. Furthermore, finer-grained test rules can be designed for each service object to select checkpoints, thereby refining the existing test cases.

[0068] like Figure 4 As shown, the method further includes:

[0069] S206: Execute the target test case;

[0070] S207: Obtain test data based on the execution status of the target test cases;

[0071] S208: Compare the test data with the expected results of the target test case to obtain the comparison results.

[0072] In a specific embodiment, when the expected result includes the response result of the business request, the service call chain information, and the parameter information of the indicator node, comparing the test data with the expected result of the target test case to obtain a comparison result includes: determining the response result of the target test case based on the test data, and comparing the response result of the target test case with the response result of the business request to obtain a first result; determining the actual associated parameters of the indicator node based on the test data, and comparing the actual associated parameters with the parameter information to obtain a second result; determining the acquisition of actual call chain information based on the test data, and comparing the actual call chain information with the service call chain information to obtain a third result; and using the first result, the second result, and the third result as the comparison result.

[0073] For example, business request A corresponds to merchant B transferring 100 yuan to user C. If the expected results are: the business request response is successful; the service call chain information indicates the chain as port 1 of service 1 - port 2 of service 2 - port 3 of service 3; the parameter information of the indicator node includes the marked chain as interface a of server a - interface b of server b - interface c of server c, interface c of server c (or port 3 of service 3) is the test node, and the input parameters of the test node, then the response result of the target test case needs to indicate that the transfer of 100 yuan from merchant B to user C was completed (both parties involved in the transfer are correct, the transfer path is correct, and the transfer amount is correct), then the first result is qualified. The actual associated parameters of the indicator node need to reflect that the above three interfaces were called during the execution of the target test case, the call order is consistent with the marked chain, and the input parameters of the test node are identical, then the second result is qualified. The actual call chain information needs to reflect that the call order is consistent with the indicated chain, then the third result is qualified.

[0074] As can be seen from the technical solutions provided in the embodiments of this specification above, the embodiments of this specification automatically generate target test cases based on business requests, without needing to focus on the hardware layer service objects associated with the execution of the business request or the database table structures involved in the hardware layer service objects. This improves the efficiency of test case generation and better meets the needs of scenarios requiring rapid testing. By obtaining service call chain information and database call information based on the execution status of the business request, effective tracking of the execution status of the business request is achieved. Consequently, this more global data provides a guarantee for generating more accurate test cases. Test nodes are selected from the chain indicated by the service call chain information according to the test rules. Selecting test nodes under the guidance of the test rules ensures that the generated test cases are more targeted and practical.

[0075] This invention also provides a test case generation platform, which includes a server and a test client. The server executes the test case generation method provided in the above embodiments based on business requests.

[0076] exist Figure 5 The architecture shown comprises three layers, designed for the test case generation platform:

[0077] 1. Web Layer: This layer provides the user interface and can receive input data from testers. Specifically, this web layer corresponds to the test client. Of course, business requests can be sent to the server by testers through the test client. Figure 6 The web layer can display the process of generating test cases, creating test tasks with test cases, and checking the execution results of test tasks. Testers can input data in the relevant process.

[0078] 2. Business Logic Layer: This layer centralizes system design related to business requirements, including the formulation of business rules and the implementation of business processes. (See also...) Figure 7 The database and table monitoring module corresponds to the aforementioned data collection agent module. The interface generation module can be used to abstract the business layer service objects into interfaces.

[0079] Referring to the relevant records in steps S201-S208, the model debugging collection agent module can also monitor the return results of the interface and the time consumption information in the service object call chain, etc.

[0080] 3. Data Layer: This layer is responsible for database access management, persistently storing the execution results of the target test cases, and non-persistently storing the service object information called in the execution of the target test cases and the contents of the database tables involved in the service objects. Redis (a key-value store) can be used to store the data that needs to be stored non-persistently, with an expiration time set for automatic expiration. Referring to the relevant description in step S202, the data collection agent module acting as the standby machine writes the synchronized data into Redis so that this data can be used for subsequent comparisons. It should be noted that after generating the target test cases (which can be persistently stored), the execution results of the corresponding business requests, the service object information called in the execution of the corresponding business requests, and the contents of the database tables involved in the service objects can be stored non-persistently.

[0081] Based on the above architecture design, the environment networking information can maintain multiple (e.g., 11) core test environments for processing business logic such as merchants, users, and orders. The deployment time for each test environment is short, typically within 10 minutes. The test case generation module significantly improves the speed of test case generation, playing a crucial role in some project version testing processes. For example, the time for full command word testing can be reduced from 4 days to 15 minutes in practical applications, demonstrating a significant improvement. Furthermore, for disaster recovery-related test cases, automatically checking interface routing information based on data collected by the model debugging agent module can also reduce the time from 3 days to 40 minutes.

[0082] This invention also provides a test case generation device, such as... Figure 8 As shown, the device includes:

[0083] Request receiving module 810: Used to receive business requests;

[0084] Information acquisition module 820: used to execute the business request, and to acquire service call chain information and database call information based on the execution status of the business request;

[0085] Node selection module 830: used to select test nodes from the links indicated by the service call link information according to the test rules;

[0086] Data acquisition module 840: used to obtain target associated data based on the test node and the database call information;

[0087] Test case generation module 850: used to generate the target test cases based on the business request, the service call chain information and the target association data.

[0088] It should be noted that the apparatus and method embodiments described in the device embodiments are based on the same inventive concept.

[0089] This invention provides an electronic device including a processor and a memory. The memory stores at least one instruction or at least one program segment, which is loaded and executed by the processor to implement the test case generation method provided in the above method embodiments.

[0090] Furthermore, Figure 9 A schematic diagram of the hardware structure of an electronic device for implementing the test case generation method provided in the embodiments of the present invention is shown. The electronic device may participate in or include the test case generation apparatus provided in the embodiments of the present invention. Figure 9 As shown, the electronic device 90 may include one or more processors 902 (shown as 902a, 902b, ..., 902n in the figure) 902 (processor 902 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 904 for storing data, and a transmission device 906 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 9 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 90 may also include... Figure 9 The more or fewer components shown, or having the same Figure 9 The different configurations shown.

[0091] It should be noted that the aforementioned one or more processors 902 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be wholly or partially integrated into any other element within the electronic device 90 (or mobile device). As involved in the embodiments of this application, the data processing circuit serves as a processor control mechanism (e.g., selection of a variable resistor termination path connected to an interface).

[0092] The memory 904 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the method described in the embodiments of the present invention. The processor 902 executes various functional applications and data processing by running the software programs and modules stored in the memory 94, thereby realizing the above-described test case generation method. The memory 904 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 904 may further include memory remotely located relative to the processor 902, and these remote memories can be connected to the electronic device 90 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0093] The transmission device 906 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the electronic device 90. In one example, the transmission device 906 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In one embodiment, the transmission device 906 may be a radio frequency (RF) module for wireless communication with the Internet.

[0094] The display can be, for example, a touchscreen liquid crystal display (LCD), which allows users to interact with the user interface of an electronic device (or mobile device).

[0095] Embodiments of the present invention also provide a storage medium, which can be disposed in an electronic device to store at least one instruction or at least one program related to implementing a test case generation method in the method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the test case generation method provided in the above method embodiment.

[0096] Optionally, in this embodiment, the storage medium may be located at at least one of the multiple network servers in a computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0097] It should be noted that the order of the above embodiments of the present invention is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, specific embodiments have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0098] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and electronic device embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0099] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by hardware related to program instructions. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A test case generation method, characterized in that, The method includes: Receive service requests; Execute the business request, and obtain service call chain information and database call information based on the execution status of the business request; The service call chain information is hardware-based annotated according to the local environment configuration information to obtain the annotation result; the annotation result is composed of hardware layer service objects. Test nodes are selected from the labeled results according to the test rules; Extract the target database information corresponding to the test node from the database call information, and use the target database information as target associated data; The business request is determined as the input condition, the business parameters carried by the business request, the service call chain information, the annotation result and the target associated data are determined as the expected result, and target test cases are generated based on the input condition and the expected result.

2. The method according to claim 1, characterized in that, The method further includes: Determine business attributes; The runtime environment is constructed based on the aforementioned business attributes; The local environment configuration information is obtained based on the operating environment. The local environment configuration information includes at least one of the following: device name, cluster information to which the device belongs, interface information of the device, network information of the device, and field support information of the database.

3. The method according to claim 1, characterized in that, After generating the target test case based on the input conditions and the expected results, the method further includes: Execute the target test case; Test data is obtained based on the execution status of the target test cases; The test data is compared with the expected results of the target test case to obtain the comparison results.

4. The method according to claim 3, characterized in that, When the expected result includes the response result of the business request, the service call chain information, and the parameter information of the indicator flag node, the comparison of the test data with the expected result of the target test case to obtain the comparison result includes: Based on the test data, determine the response result of the target test case, and compare the response result of the target test case with the response result of the business request to obtain a first result; Based on the test data, the actual association parameters of the flag node are determined, and the actual association parameters are compared with the parameter information to obtain a second result; Based on the test data, the actual call chain information is determined, and the actual call chain information is compared with the service call chain information to obtain a third result; The first result, the second result, and the third result are used as the comparison results.

5. The method according to claim 1, characterized in that, Before obtaining the database call information, the method further includes: Configure monitoring files based on the database replication protocol; Accordingly, obtaining the database call information includes: Run the monitoring file to obtain the database call information.

6. A test case generation device, characterized in that, The device includes: Request receiving module: Used to receive business requests; Information acquisition module: used to execute the business request, and to acquire service call chain information and database call information based on the execution status of the business request; Node selection module: used to perform hardware-based annotation processing on the service call chain information according to the local environment configuration information to obtain annotation results; the annotation results are composed of hardware layer service objects; and test nodes are selected from the annotation results according to the test rules. Data acquisition module: used to extract target database information corresponding to the test node from the database call information, and to use the target database information as target associated data; Test case generation module: used to determine the business request as input condition, determine the business parameters carried by the business request, the service call chain information, the annotation result and the target associated data as expected result, and generate target test cases based on the input condition and the expected result.

7. The apparatus according to claim 6, characterized in that, The device is also used for: Determine business attributes; The runtime environment is constructed based on the aforementioned business attributes; The local environment configuration information is obtained based on the operating environment. The local environment configuration information includes at least one of the following: device name, cluster information to which the device belongs, interface information of the device, network information of the device, and field support information of the database.

8. The apparatus according to claim 6, characterized in that, The device is also used for: After generating the target test case based on the input conditions and the expected results, the target test case is executed. Test data is obtained based on the execution status of the target test cases; The test data is compared with the expected results of the target test case to obtain the comparison results.

9. The apparatus according to claim 8, characterized in that, When the expected result includes the response result of the business request, the service call chain information, and the parameter information of the indicator flag node, the comparison of the test data with the expected result of the target test case to obtain the comparison result includes: Based on the test data, determine the response result of the target test case, and compare the response result of the target test case with the response result of the business request to obtain a first result; Based on the test data, the actual association parameters of the flag node are determined, and the actual association parameters are compared with the parameter information to obtain a second result; Based on the test data, the actual call chain information is determined, and the actual call chain information is compared with the service call chain information to obtain a third result; The first result, the second result, and the third result are used as the comparison results.

10. The apparatus according to claim 6, characterized in that, The device is also used for: Before obtaining the database call information, a monitoring file is configured based on the database replication protocol; Accordingly, the information acquisition module is also used to: run the monitoring file to acquire the database call information.

11. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the test case generation method as described in any one of claims 1-5.

12. A computer-readable storage medium, characterized in that, The storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the test case generation method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Interface testing method, apparatus, computer device and storage medium

    CN109471796A