Test methods, apparatuses, devices, storage media, and computer program products
Patent Information
- Application Number
- CN202210153603.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-18
- Publication Date
- 2026-10-13
- Estimated Expiration
- 2042-02-18
AI Technical Summary
一般来说,可以手工编写测试用例,以模拟用户对页面的操作,但是手工编写测试用例效率较低
[0032]上述测试方法、装置、计算机设备、存储介质和计算机程序产品中,在与被测页面中的目标元素绑定的事件被触发后,保存与该被触发的事件所对应的事件对象,由于事件对象至少包括目标元素在被测页面中的元素路径和被触发的事件的事件类型,因此,可以根据事件对象包括的元素路径,将目标元素映射至测试用例中,以及根据事件对象包括的事件类型,将被触发的事件映射至测试用例中,自动生成目标测试用例,无需手工编写;并且,后续可以直接根据该自动生成的目标测试用例,测试与所述被测页面中所述目标元素绑定的所述事件被触发后的响应状况,提高页面测试效率;另外,由于事件对象包括目标元素在被测页面中的元素路径,因此,在该目标元素的起始标签不包括目标元素的唯一标识符或类名的情况下,也可以基于目标元素在被测页面中的元素路径,将目标元素映射至测试用例中,避免被测页面的开发人员在形成测试用例时修改目标元素的起始标签,降低代码处理量。
Smart Images

Figure CN116662143B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer processing technology, and in particular to a testing method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] With the development of computer technology, interactive web pages have emerged to enable users to better interact with computers. Users can perform operations on the page, such as clicking buttons, and the computer can respond to the user through the page, such as displaying corresponding content.
[0003] After a webpage is developed, before it is officially released to users, it is generally necessary to simulate user interactions with the page to test whether the page responds correctly to these actions. Typically, test cases can be written manually to simulate user interactions, but this method is inefficient. Summary of the Invention
[0004] Therefore, it is necessary to provide a testing method, apparatus, computer equipment, storage medium, and computer program product that can improve the efficiency of test case generation and thus improve page testing efficiency, in order to address the above-mentioned technical problems.
[0005] This application provides a testing method, the method comprising:
[0006] After an event bound to a target element in the page under test is triggered, the event object corresponding to the event is saved. The event object includes at least the element path of the target element in the page under test and the event type of the event.
[0007] Based on the element path included in the event object, the target element is mapped to the test case, and based on the event type included in the event object, the event is mapped to the test case to obtain the target test case;
[0008] Based on the target test case, test the response status after the event bound to the target element in the page under test is triggered.
[0009] This application provides a testing apparatus, the apparatus comprising:
[0010] The event object saving module is used to save the event object corresponding to the event after the event bound to the target element in the page under test is triggered. The event object includes at least the element path of the target element in the page under test and the event type of the event.
[0011] The mapping module is used to map the target element to a test case according to the element path included in the event object, and to map the event to the test case according to the event type included in the event object, so as to obtain the target test case;
[0012] The testing module is used to test the response status of the event bound to the target element in the page under test after it is triggered, based on the target test case.
[0013] In one embodiment, the event object storage module is used to obtain and save the event object passed to the response function through a proxy function after the event object corresponding to the event is passed to the event response function and before the response function responds with the event object as a parameter.
[0014] The device further includes a proxy invocation module, used to invoke the response function on behalf of the obtained event object through the proxy function.
[0015] In one embodiment, the event object storage module is further configured to intercept the event response function by running the interception code of the proxy function before the response function responds with the event object as a parameter; and to obtain the event object as a parameter of the response function from the intercepted response function.
[0016] In one embodiment, the page under test belongs to the interactive page of the vehicle sub-application, and the device further includes an injection module for injecting the proxy function into the logic layer of the vehicle sub-application framework.
[0017] The event object storage module is further configured to intercept the event response function by running the interception code of the proxy function in the logic layer before the proxy function in the logic layer is run to call the response function.
[0018] In one embodiment, the apparatus further includes an event trigger detection module, configured to initiate the detection of triggered events after the proxy function is injected into the logic layer of the vehicle sub-application framework;
[0019] The event object storage module is further configured to, after initiating the detection of a triggered event, intercept the event's response function by running the interception code of the proxy function in the logic layer before delegating the call to the response function by running the proxy function in the logic layer.
[0020] In one embodiment, the injection module is further configured to inject the proxy function into the logic layer of the vehicle sub-application framework after starting the vehicle simulator when the page under test runs on the vehicle sub-application framework and the vehicle sub-application framework runs on the vehicle simulator.
[0021] In one embodiment, the event object saving module is further configured to obtain the event type of the event from the event object corresponding to the event; when the event type indicates that the event is an event that needs to be mapped to a test case, the event object corresponding to the event is saved.
[0022] In one embodiment, the page under test is an interactive page of an in-vehicle sub-application, and the device further includes an event object forming module, which is used to form an event object corresponding to the event when an event bound to a target element in the page under test is detected by the rendering layer of the running in-vehicle sub-application framework, based on the event type of the event provided by the running rendering layer and the element path of the target element in the page under test provided by the rendering layer.
[0023] In one embodiment, the mapping module is used to pass the element path included in the event object as a parameter to the element retrieval function of the test case, so as to map the target element to the test case to obtain the target test case.
[0024] In one embodiment, the mapping module is configured to determine, among the multiple element processing functions corresponding to the target element, an element processing function whose processing type matches the event type included in the event object, so as to map the event to the test case to obtain the target test case.
[0025] In one embodiment, the testing module is configured to apply the target test case to the page under test, causing an event of a target element on the page under test to be triggered, resulting in a test response page; obtain a screenshot of the test response page; obtain a screenshot of a reference response page based on a reference response page obtained when the event bound to the target element on the page under test is triggered; and obtain the response status after the event bound to the target element on the page under test is triggered based on the difference between the screenshot of the test response page and the screenshot of the reference response page.
[0026] In one embodiment, the testing module is further configured to apply the target test cases to the page under test in various operating systems provided by the vehicle simulator, so that the events of the target elements of the page under test are triggered under various operating systems to obtain corresponding test response pages, thereby obtaining test response pages corresponding to various operating systems.
[0027] In one embodiment, the event object saving module is used to save the event object corresponding to the event bound to the target element to a file; the file also stores the event objects corresponding to other events, other than the event bound to the target element in the page under test, when they are triggered.
[0028] The device further includes an event object traversal module, used to traverse each event object stored in the file; when traversing to the event object corresponding to the event bound to the target element, the device performs the steps of mapping the target element to a test case according to the element path included in the event object, and mapping the event to the test case according to the event type included in the event object, to obtain the target test case.
[0029] This application provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor executes the above-described test method.
[0030] This application provides a computer-readable storage medium having a computer program stored thereon, the computer program being executed by a processor using the above-described test method.
[0031] This application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described testing method.
[0032] In the aforementioned testing methods, apparatus, computer devices, storage media, and computer program products, after an event bound to a target element on the page under test is triggered, an event object corresponding to the triggered event is saved. Since the event object includes at least the element path of the target element on the page under test and the event type of the triggered event, the target element can be mapped to test cases based on the element path included in the event object, and the triggered event can be mapped to test cases based on the event type included in the event object, automatically generating target test cases without manual writing. Furthermore, the response status after the event bound to the target element on the page under test is triggered can be directly tested based on the automatically generated target test cases, improving page testing efficiency. In addition, since the event object includes the element path of the target element on the page under test, even if the starting tag of the target element does not include the unique identifier or class name of the target element, the target element can still be mapped to test cases based on the element path of the target element on the page under test, avoiding the need for developers of the page under test to modify the starting tag of the target element when forming test cases, thus reducing the amount of code processing. Attached Figure Description
[0033] Figure 1 This is a diagram illustrating the application environment of the test method in one embodiment;
[0034] Figure 2 This is a flowchart illustrating a testing method in one embodiment;
[0035] Figure 3 This is a schematic diagram of the elements of the page under test in one embodiment;
[0036] Figure 4 This is a schematic diagram of the element node tree of the page under test in one embodiment;
[0037] Figure 5 This is a schematic diagram of the vehicle-mounted sub-application framework in one embodiment;
[0038] Figure 6 This is a schematic diagram illustrating the user's operation type on the tested page in one embodiment;
[0039] Figure 7 This is a flowchart illustrating the process of collecting and generating the event objects required for the target test cases in one embodiment.
[0040] Figure 8 This is a flowchart illustrating the element mapping and event mapping process in one embodiment;
[0041] Figure 9 This is a structural block diagram of the test apparatus in one embodiment;
[0042] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0044] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application can be combined with other embodiments.
[0045] Figure 1 This is a diagram illustrating the application environment of a testing method in practice. (Refer to...) Figure 1Terminal 102 can interact with server 104 via a communication network. Terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server, a server cluster composed of multiple servers, or a cloud server. Server 104 can integrate a data storage system; however, it is understood that server 104 can also be set up separately from the data storage system.
[0046] Terminal 102 can display the page under test. When an event bound to a target element on the page under test is triggered, it can send an event object formed when the event is triggered to server 104. This event object includes at least the element path of the target element on the page under test and the event type. Server 104 can store the received event object in a data storage system. In addition, server 104 can map the target element to test cases based on the element path included in the event object, and map the event to test cases based on the event type included in the event object, thus obtaining target test cases. Based on the target test cases, the response status after the event bound to the target element on the page under test is triggered is tested.
[0047] The testing method provided in this application can be executed collaboratively by a terminal and a server, or by either a terminal or a server alone. In one embodiment, the method is illustrated using an example of execution by a terminal. Figure 2 This is a flowchart illustrating a testing method in one embodiment, which includes the following steps:
[0048] Step S202: After the event bound to the target element in the page under test is triggered, save the event object corresponding to the event. The event object includes at least the element path of the target element in the page under test and the event type of the event.
[0049] The page under test is an interactive page whose responsiveness to user actions is to be tested. This page can be an interactive page of a browser or an interactive page of an in-vehicle application, etc. The page under test can be built based on a tag language; correspondingly, the basic building blocks of the page under test are tags, and there is a hierarchical structure between tags. The tags included in an interactive page built based on a tag language basically include language identifier tags, page title identifier tags, and page body identifier tags. The start and end of each tag can be defined by its start and end tags; for example, the start tag of a language identifier tag is ``, and the end tag of a language identifier tag is ``; another example is the start tag of a page title identifier tag, ``, and the end tag of a title identifier tag is ``; yet another example is the start tag of a page body identifier tag, ``, and the end tag of a page body identifier tag is ``. The language identifier tag is the parent-level tag of the page title identifier tag and the page body identifier tag, and the page title identifier tag and the page body identifier tag are tags of the same level. Based on the hierarchical relationship between the language identifier tag, page title identifier tag, and page body identifier tag, the resulting tag structure is as follows:
[0050]
[0051]
[0052]
[0053]
[0054] The main page identifier tag can include sub-level tags, such as buttons and input text boxes. The number of sub-level tags can be at least one. The main page identifier tag and its sub-level tags can be called elements. There is a hierarchical relationship between elements. Elements with a hierarchical relationship can form the element node tree of the page being tested.
[0055] Figure 3 This is a schematic diagram of the elements of the page under test in one embodiment, with reference to... Figure 3 The elements in the tested page may include element 300, element 301, element 302, element 3011, and element 3012. Element 300 corresponds to the main page identifier tag, and elements 301, 302, 3011, and 3012 are sub-level tags of the main page identifier tag.
[0056] The hierarchical relationship between elements 300 and 301 is as follows: element 301 is a child level tag of element 300; the hierarchical relationship between elements 300 and 302 is as follows: element 302 is a tag of element 300; the hierarchical relationship between elements 301 and 302 is as follows: elements 301 and 302 are tags at the same level; similarly, the hierarchical relationship between elements 301 and 3011 is as follows: element 3011 is a child level tag of element 301; the hierarchical relationship between elements 301 and 3012 is as follows: element 3012 is a child level tag of element 301; the hierarchical relationship between elements 3011 and 3012 is as follows: elements 3011 and 3012 are tags at the same level.
[0057] Figure 4 This is a schematic diagram of the element node tree of the page under test in one embodiment; refer to Figure 4 Based on the hierarchical relationship between elements 300, 301, 302, 3011, and 3012, we can obtain Figure 4 The element node tree shown is as follows, where node a corresponds to element 300, nodes b and c correspond to elements 301 and 302 respectively, and nodes d and e correspond to elements 3011 and 3012 respectively.
[0058] The element path is the path of each element in the element node tree of the page being tested. For example, element 3011 is located in... Figure 4 The path in the element node tree shown is: node a / node b / node d.
[0059] When developing a page under test, you can bind corresponding events to the elements on that page. These events include various types such as click events, double-click events, long-press events, and swipe events. Different events correspond to different event types; for example, the click event corresponds to the event type "click". When an operation corresponding to the event bound to an element is performed on that element, the event bound to that element is triggered. For example, if the event bound to a button is a click event, when a click operation corresponding to that click event is performed on the button, the click event bound to that button is triggered.
[0060] When an event bound to an element is triggered, event handling can be performed accordingly. This event handling can be implemented through the event's response function. Since the event response function requires the event object as a parameter, and the event object is encapsulated based on information related to when the event was triggered, this process is necessary.
[0061] In one embodiment, a tester may input a test operation into the page under test. If the test operation is applied to a target element of the page under test and triggers an event bound to that target element, then the relevant information about when the event is triggered will be encapsulated into an event object of that event. The event object may include at least the element path of the target element bound to the event in the page under test and the event type of the event.
[0062] Step S204: Based on the element paths included in the event object, map the target element to the test case, and based on the event types included in the event object, map the event to the test case to obtain the target test case.
[0063] The target test case is the test case obtained after element mapping and event mapping. The target test case can simulate user operations on the page under test to obtain the corresponding response. Specifically, the target test case can be applied to the page under test on various operating systems to trigger events bound to the target elements on the page under test and obtain the corresponding response on various operating systems.
[0064] To ensure that the target test cases can simulate user interactions with the page under test, it is necessary to clearly define the elements on the page under test that the target test cases affect and the type of their effect. The affected elements can be the page body corresponding to the page body tag, or buttons, text input boxes, etc., corresponding to sub-level tags of the page body tag. The effect type is the event type of the triggered event, such as a single click or double click.
[0065] By using the element path included in the event object, the target test case can locate the element that needs to be affected on the page under test; by using the event type included in the event object, the target test case can determine the type of action.
[0066] In one embodiment, the terminal can pass the element path included in the event object as a parameter to the element retrieval function of the test case to map the target element to the test case and obtain the target test case. The element retrieval function is used to locate elements on the page.
[0067] The terminal passes the event object, including the element path of the target element, as a parameter to the element retrieval function, so that when the target test case executes the element retrieval function based on the element path, it can locate the target element.
[0068] In the above embodiments, the element path included in the event object is passed as a parameter to the element retrieval function, so that the target element can be located even if the starting tag of the target element does not include a unique identifier or class name.
[0069] In one embodiment, among the multiple element processing functions corresponding to the target element, the terminal can determine the element processing function whose processing type matches the event types included in the event object, so as to map the triggered event to the test case to obtain the target test case.
[0070] There are various ways to process elements, such as retrieving element text, retrieving element attributes, and clicking on elements. Therefore, each element processing method can correspond to an element processing function, and the processing type of the element processing function is the element processing method it corresponds to.
[0071] The terminal can determine the element handling function whose processing type matches the event type included in the event object from among multiple element handling functions. For example, if the event object includes the event type "click," then the element handling function whose processing type matches this event type can be determined, and the element handling method corresponding to this element handling function is also "click." Next, the determined element handling function is placed into the test case to map the event triggered by the operation being tested to the test case, thus obtaining the target test case.
[0072] In the above embodiments, the element processing function whose processing type matches the event types included in the event object is determined among multiple element processing functions, thereby improving the accuracy of event mapping.
[0073] Step S206: Based on the target test case, test the response status after the event bound to the target element in the page under test is triggered.
[0074] The response status can be divided into good response status and bad response status. A good response status indicates that the response logic obtained after the target test case is applied is consistent with the pre-planned response logic, and the possibility of problems with the response logic code of the page under test is low. A bad response status indicates that the response logic obtained after the target test case is applied is inconsistent with the pre-planned response logic, indicating that the possibility of problems with the response logic code of the page under test is high.
[0075] After obtaining the target test cases, the terminal can apply the target test cases to the page under test in various operating systems to trigger events bound to the target elements in the page under test and obtain the response status in various operating systems.
[0076] In the above testing method, after an event bound to a target element on the page under test is triggered, the event object corresponding to the triggered event is saved. Since the event object includes at least the element path of the target element on the page under test and the event type of the triggered event, the target element can be mapped to test cases based on the element path included in the event object, and the triggered event can be mapped to test cases based on the event type included in the event object, automatically generating target test cases without manual writing. Furthermore, the response status after the event bound to the target element on the page under test is triggered can be tested directly based on the automatically generated target test cases, improving page testing efficiency. In addition, since the event object includes the element path of the target element on the page under test, even if the starting tag of the target element does not include the unique identifier or class name of the target element, the target element can still be mapped to test cases based on the element path of the target element on the page under test, avoiding the need for developers of the page under test to modify the starting tag of the target element when forming test cases, thus reducing the amount of code processing.
[0077] In one embodiment, after the event object corresponding to the event is passed to the event response function, the terminal can obtain and save the event object passed to the response function through a proxy function before the response function responds with the event object as a parameter; the terminal can also use the proxy function to call the response function on behalf of the obtained event object.
[0078] A proxy function is a function that calls a response function in place of the original function. This proxy function can be obtained by rewriting the original function. The rewriting method can be to add code that intercepts the response function before the code in the original function calls it. In the context of in-vehicle applications, because the interactive pages of in-vehicle applications differ from web pages (pages displayed in a browser) and do not have a window object (the window opened in the browser), interception cannot be performed using the window object. However, the elements of the interactive pages of in-vehicle applications are wrapped by page methods (which can be called page wrapping methods) or component methods (which can be called component wrapping methods). Therefore, the page methods and component methods can be rewritten, and the rewritten methods can be used as proxy functions. The rewriting method can be to add code that intercepts the response function before the code that calls it.
[0079] When an event bound to a target element on the page under test is triggered by a test operation, a corresponding event object is generated. This event object is passed as a parameter to the event's response function. Before executing the response function with this event object as a parameter, a proxy function retrieves and saves the event object passed to the response function. The terminal can also use the proxy function to call the response function with this event object as a parameter to complete the event handling.
[0080] In the above embodiments, before the response function responds with the event object as a parameter, the event object passed to the response function is saved through a proxy function to prevent the event object from being destroyed before it is saved; in addition, after the event object is saved, the response function is called through the proxy function so that the event processing is completed.
[0081] In one embodiment, the terminal can also intercept the event response function by running interception code of the proxy function before the response function responds with the event object as a parameter; and obtain the event object as a parameter of the response function from the intercepted response function.
[0082] Interception code can be implemented by storing it in a set array. After the event is triggered by the test operation, the corresponding response function is stored in the set array.
[0083] After the event bound to the target element in the page under test is triggered by the test operation, the resulting event object is passed as a parameter to the event's response function. The event's response function is then intercepted by the interception code in the proxy function, and the event object, which is used as a parameter of the response function, is obtained from the intercepted response function.
[0084] In the above embodiments, the interception code in the proxy function intercepts the response function of the event triggered by the tested operation, obtains the event object, and then automatically generates test cases based on the event object, thereby improving the efficiency of test case generation.
[0085] In one embodiment, the page under test is an interactive page of the vehicle sub-application. The terminal can also inject proxy functions into the logic layer of the vehicle sub-application framework. Before running the proxy function in the logic layer to proxy the call to the response function, the terminal can intercept the event response function by running the interception code of the proxy function in the logic layer.
[0086] The terminal can run an operating system, run the parent application on the operating system, and run the child application in the environment provided by the parent application.
[0087] An operating system (OS) is a computer program that manages and controls the hardware and software resources of a terminal. It is the most basic system software that runs directly on the bare metal of the terminal, and applications need the support of the operating system to run. The operating system can be a desktop operating system such as Windows, Linux, or Mac OS (Apple's desktop operating system), or a mobile operating system such as iOS (Apple's mobile operating system) or Android.
[0088] The parent application is an application that can run directly on the operating system. Parent applications can be social applications, email applications, browser applications, game applications, etc. Social applications can include instant messaging applications, SNS (Social Network Service) applications, or live streaming applications, etc.
[0089] A sub-application is an application that can run within the environment provided by a parent application. In other words, the parent application possesses the functionality of the sub-application, which is used to provide registered users of the parent application with the service of using the sub-application within the parent application. Sub-applications can be food delivery applications, shopping applications, supermarket and fresh food applications, food and beverage applications, travel applications, etc. Sub-applications can also be called mini-programs.
[0090] In-vehicle sub-applications are sub-applications applied to vehicles. The in-vehicle sub-application framework provides a runtime environment for the development documentation of in-vehicle sub-applications. The development documentation of in-vehicle sub-applications includes page structure description documentation and page processing logic documentation. The page structure description documentation can describe the structure of interactive pages using tag language. Figure 5 This is a schematic diagram of the vehicle-mounted sub-application framework in one embodiment, with reference to... Figure 5 The page structure description document can run in the rendering layer of the in-vehicle sub-application framework, and the page processing logic document can run in the logic layer of the in-vehicle sub-application framework; the rendering layer and logic layer of the in-vehicle sub-application framework communicate through the parent application to which the in-vehicle sub-application belongs.
[0091] When the page under test belongs to the interactive page of the vehicle sub-application, the terminal can inject the proxy function obtained by rewriting the page method and component method into the logic layer of the vehicle sub-application framework.
[0092] After determining that an event bound to a target element in the tested page has been triggered at the logic layer of the in-vehicle sub-application runtime framework, an event object for that event is created at the logic layer. This event object is then passed from the logic layer to the response function of the logic layer via the parent application to which the in-vehicle sub-application belongs. Because the proxy function is pre-injected into the logic layer, after the event object is passed to the response function of the logic layer, and before the response function is called by proxy through the execution of the proxy function in the logic layer, the interception code of the proxy function in the logic layer can be used to intercept the response function.
[0093] In the above embodiments, the proxy function is pre-injected into the logic layer so that after the event object is passed to the response function of the logic layer, the response function is intercepted before it is called by proxy through the execution of the proxy function in the logic layer, thus avoiding missed interception.
[0094] In one embodiment, after injecting the proxy function into the logic layer of the vehicle sub-application framework, the terminal can also initiate the detection of triggered events; after initiating the detection of triggered events, before delegating the call to the response function by running the proxy function in the logic layer, the terminal can also intercept the event response function by running the interception code of the proxy function in the logic layer.
[0095] After injecting the proxy function into the logic layer of the vehicle sub-application framework, the terminal can start detecting whether the event bound to the target element in the page under test is triggered. After the detection is started, when the event bound to the target element in the page under test is triggered by the test operation, the response function of the triggered event can be intercepted by running the interception code of the proxy function in the logic layer before the response function is called by proxy through the execution of the proxy function.
[0096] In the above embodiments, after injecting the proxy function into the logic layer of the vehicle sub-application framework, the detection of triggered events can be initiated. After the detection of triggered events is initiated, the terminal can intercept the event response function through the interception code of the proxy function in the logic layer, so as to prevent the response function of the event triggered by the test operation from being missed.
[0097] In one embodiment, the page under test is an interactive page of an in-vehicle sub-application. When an event bound to a target element in the page under test is detected by the rendering layer of the running in-vehicle sub-application framework, the terminal can also form an event object corresponding to the event by using the event type provided by the running rendering layer and the element path of the target element in the page under test provided by the rendering layer.
[0098] When an event bound to a target element on the page under test is triggered by a test operation, the logic layer of the vehicle sub-application framework detects that the event has been triggered and can then provide the event type of the triggered event and the element path of the target element on the page under test through the rendering layer to form an event object corresponding to the triggered event.
[0099] In the above embodiments, since the logic layer of the vehicle sub-application framework supports adding the element path of the target element bound to the triggered event in the event object, even if the starting tag of the target element in the page structure description document does not define the unique identifier or class name of the target element, the target test case can still obtain the element path of the target element through the event object and complete the location of the target element. This avoids the developers of the page under test from modifying the starting tag of the target element when forming test cases, thus reducing the amount of code processing.
[0100] In one embodiment, when the page under test runs on the in-vehicle sub-application framework, and the in-vehicle sub-application framework runs on the in-vehicle simulator, the terminal can inject the proxy function into the logic layer of the in-vehicle sub-application framework after starting the in-vehicle simulator.
[0101] The vehicle simulator is used to simulate the running environment of the in-vehicle sub-application framework in a vehicle, providing the vehicle's operating system on which the in-vehicle sub-application framework relies for runtime. Since the in-vehicle sub-application framework runs on the vehicle simulator, the terminal can inject proxy functions into the logic layer of the in-vehicle sub-application framework after starting the vehicle simulator.
[0102] In the above embodiments, after starting the vehicle simulator, the proxy function is injected into the logic layer of the vehicle sub-application framework to ensure that the proxy function can be successfully injected into the vehicle sub-application framework.
[0103] In one embodiment, the terminal can also obtain the event type of the event from the event object corresponding to the event; when the event type indicates that the event needs to be mapped to a test case, the event object corresponding to the event is saved.
[0104] Events that need to be mapped to test cases can be predefined. Click events, swipe events, input events, enter events, long press events, page switching events, page return events, or screenshot events can be used as events that need to be mapped to test cases.
[0105] After an event bound to a target element on the page under test is triggered by a test operation, a corresponding event object is formed. The terminal can obtain the event type of the event triggered by the test operation from the event object. When the event type indicates that the event triggered by the test operation needs to be mapped to the event of the test case, the terminal can include the event object.
[0106] In the above embodiments, before saving the event object of the event triggered by the tested operation, it is first determined whether the triggered event is an event that needs to be mapped to a test case based on the event type of the event object, so as to avoid saving the event object of the event that does not need to be mapped to a test case.
[0107] In one embodiment, the terminal can also apply the target test case to the page under test, so that the event of the target element on the page under test is triggered and a test response page is obtained, and a screenshot of the test response page is obtained; based on the reference response page obtained when the event bound to the target element in the page under test is triggered, a screenshot of the reference response page is obtained; and based on the difference between the screenshot of the test response page and the screenshot of the reference response page, the response status after the event bound to the target element in the page under test is triggered is obtained.
[0108] The test response page is obtained by applying the target test case (obtained through element mapping) to the page under test. Specifically, after obtaining the target test case through element mapping, the target test case is applied to the page under test, causing the event bound to the target element of the page under test to be triggered, resulting in the corresponding response page, which is called the test response page.
[0109] The reference response page is obtained when collecting event objects required by the test case for element mapping. Specifically, when an event bound to a target element in the page under test is triggered by a test operation, a response page can be obtained, which is called the reference response page.
[0110] After receiving the test response page, the terminal can obtain a screenshot of the test response page, and after receiving the reference response page, it can obtain a screenshot of the reference response page. Then, the terminal can compare the differences between the screenshots of the test and reference response pages to determine the response status after an event bound to a target element on the tested page is triggered. Specifically, when the difference between the screenshots of the test and reference response pages is less than a threshold, the response status after an event bound to a target element on the tested page is determined to be a good response status; when the difference is greater than the threshold, the response status after an event bound to a target element on the tested page is determined to be a poor response status.
[0111] In the above embodiments, during the event collection process, a screenshot of the reference response page obtained when the event bound to the target element of the page under test is triggered by the test operation is stored, and the difference is compared with the screenshot of the test response page obtained when the target test case is applied to the page under test. This allows for automatic determination of the response status after the event bound to the target element in the page under test is triggered without manual intervention.
[0112] In one embodiment, the terminal can also apply the target test cases to the page under test in various operating systems provided by the vehicle simulator, so that the events of the target elements of the page under test are triggered under various operating systems to obtain the corresponding test response pages, so as to obtain the test response pages corresponding to various operating systems.
[0113] Since different car models use different operating systems, in order to ensure that the in-vehicle sub-application responds normally in the operating systems of most car models, it is necessary to test the responsiveness of the in-vehicle sub-application's interactive page in the operating systems of various car models.
[0114] The vehicle simulator can provide operating systems for various vehicle models. The terminal can apply the target test cases obtained by mapping elements and events to the page under test in the various operating systems provided by the vehicle simulator. This will cause the events bound to the target elements of the page under test to be triggered under various operating systems, resulting in test response pages corresponding to various operating systems.
[0115] Next, the terminal can compare the screenshots of the test response pages corresponding to various operating systems with the screenshots of the reference response pages to determine the response of the in-vehicle sub-application's interactive page in various operating systems.
[0116] In the above embodiments, the target test cases can be applied to the page under test in various operating systems provided by the vehicle simulator to obtain the test response pages corresponding to various operating systems, so as to determine whether the response of the vehicle sub-application is normal in various operating systems.
[0117] In one embodiment, the terminal may also save the event object corresponding to the event bound to the target element to a file; the file also stores the event objects corresponding to other events when they are triggered, in addition to the events bound to the target element in the page under test; the terminal may also traverse the event objects stored in the file; when traversing to the event object corresponding to the event bound to the target element, the terminal executes the steps of mapping the target element to the test case according to the element path included in the event object, and mapping the event to the test case according to the event type included in the event object, to obtain the target test case.
[0118] After an event bound to a target element is triggered by a test operation, a corresponding event object is created, which the terminal can save to a file. Similarly, when a test operation triggers other events on the page under test, the terminal can also save the event objects of those other events to the same file. When element and event mapping is required, the terminal can iterate through each event object in the file and, based on the element path in each event object, map the corresponding element to a test case. Based on the event type in each event object, it can also map the corresponding event to a test case, thus creating a target test case for each event object.
[0119] In the above embodiments, event objects are uniformly saved to the same file, and the event objects in the file can be directly traversed to restore each target test case, thereby improving the efficiency of test case generation.
[0120] To better understand the above method, an application embodiment of the testing method of this application is described in detail below. In this application embodiment, the page under test is an interactive page of an in-vehicle sub-application. Figure 6 This is a schematic diagram illustrating the user's operation type on the tested page in one embodiment; refer to Figure 6 When the functions provided by the page under test include: "click button", "default page click button", page swipe event, "component click button", and "jump to new page" button, it is necessary to simulate the user's operation of various functions provided by the page under test to check whether the response of the page under test is normal. For example, simulate the user's operation of "click button" to check whether the response of the page under test is normal, simulate the user's operation of swiping the page to check whether the swiping of the page under test is normal, and simulate the user's operation of clicking the "jump to new page" button to check whether the user jumps from the page under test to the new page.
[0121] Figure 7 This is a flowchart illustrating the process of collecting and generating the event objects required for the target test cases in one embodiment. Figure 7 The steps shown can be performed by a terminal, see below. Figure 7 The main steps include the following:
[0122] Step S702: When the page under test is running on the vehicle sub-application framework and the vehicle sub-application framework is running on the vehicle simulator, start the vehicle simulator.
[0123] Step S704: Inject the proxy function into the logic layer of the vehicle sub-application framework;
[0124] In the context of in-vehicle sub-applications, since the interactive pages of in-vehicle sub-applications differ from web pages and do not have a window object, interception cannot be performed through the window object. However, the elements of the interactive pages of in-vehicle sub-applications are wrapped by the page method or component method, so the page method and component method can be overridden and used as proxy functions.
[0125] Step S706: Start the detection of whether the event has been triggered;
[0126] The principle behind detecting event triggering is as follows: if a proxy function calls a response function, the event corresponding to that called response function will be triggered. By using a proxy function to call a response function, the event object that serves as the parameter of the response function can be obtained. By examining the event type in the event object, it can be determined whether the event triggered by the tested operation is an event that needs to be mapped to a test case.
[0127] Step S708: Receive the test operation applied to the page under test;
[0128] Step S710: After the event bound to the target element in the page under test is triggered by the test operation, a reference response page is obtained, and a screenshot of the reference response page is acquired.
[0129] Step S712: Test whether the operation is complete;
[0130] If the test operation is not yet completed, jump back to step S708; if the test operation is completed, jump to step S714.
[0131] Step S714: Save the event object corresponding to the event bound to the target element triggered by the tested operation;
[0132] The saved event objects may include the following types of information:
[0133] (1) The path of the page to which the element to which the event triggered by the tested operation belongs;
[0134] (2) The timestamp when the event was triggered by the test operation;
[0135] (3) The event type of the event triggered by the operation being tested;
[0136] (4) When the test operation is an input operation, test the input content; when the test operation is a sliding operation of the main body of the page, test the sliding distance of the operation on the page.
[0137] (5) The time required to wait since the last test operation;
[0138] (6) The element path of the target element in the page to which the event triggered by the tested operation is bound.
[0139] After saving the data to the various event objects generated by the test operations, you can then perform element mapping and event mapping on each event object to obtain the target test case corresponding to each event object.
[0140] Figure 8 This is a schematic diagram illustrating the process of element mapping and event mapping in one embodiment. Figure 8 The steps shown can be performed by a terminal, see below. Figure 8 The main steps include the following:
[0141] Step S802: Obtain the file used to store the event objects;
[0142] Step S804: Traverse each event object in the file;
[0143] Step S806: For each event object traversed, map the events corresponding to the event object to the test cases according to the event types included in the event object;
[0144] Step S808: For each event object traversed, map the target element bound to the event corresponding to the event object to the test case according to the element path included in the event object;
[0145] Step S810: For each event object traversed, after completing the event mapping and element mapping related to the event object, the target test case of the event object is obtained. The target test case is then applied to the page under test to obtain the response status of the page under test.
[0146] In the various operating systems provided by the vehicle simulator, the target test cases are applied to the page under test to trigger events bound to the target elements on the page under test, resulting in the corresponding test response page and a screenshot of the test response page. Then, the screenshot of the test response page is compared with the screenshot of the reference response page saved during the event object collection process. If the difference is less than a threshold, it indicates that the response of the page under test in the corresponding operating system is in a good state. If the difference is greater than the threshold, it indicates that the response of the page under test in the corresponding operating system is not in a good state, and there may be a problem with the code of the page under test.
[0147] Step S812: Has the event object in the file been traversed completely?
[0148] If the traversal is complete, end the element mapping and event mapping; if the traversal is not complete, return to step S804.
[0149] In the above embodiments, testers can input test operations into the page under test. When the test operation triggers an event bound to an element in the page under test, the event object of the event is intercepted, and target test cases are automatically generated based on the information included in the event object. Subsequently, the automatically generated target test cases can be applied to the page under test in various operating systems provided by the vehicle simulator to verify the response of the page under test in various operating systems, thereby improving the efficiency of page testing.
[0150] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0151] Based on the same inventive concept, this application also provides a testing apparatus for implementing the testing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations and technical effects of one or more testing apparatus embodiments provided below can be found in the limitations and technical effects of the testing method described above, and will not be repeated here.
[0152] Figure 9 This is a structural block diagram of the test apparatus in one embodiment. (Refer to...) Figure 9 The device includes:
[0153] The event object storage module 902 is used to save the event object corresponding to the event after the event bound to the target element in the page under test is triggered. The event object includes at least the element path of the target element in the page under test and the event type of the event.
[0154] The mapping module 904 is used to map the target element to a test case according to the element path included in the event object, and to map the event to the test case according to the event type included in the event object, so as to obtain the target test case;
[0155] Test module 906 is used to test the response status of the event bound to the target element in the page under test after it is triggered, based on the target test case.
[0156] In one embodiment, the event object storage module 902 is used to obtain and save the event object passed to the response function through a proxy function after the event object corresponding to the event is passed to the event response function and before the response function responds with the event object as a parameter.
[0157] The device further includes a proxy invocation module, used to invoke the response function on behalf of the obtained event object through the proxy function.
[0158] In one embodiment, the event object storage module 902 is further configured to intercept the event response function by running the interception code of the proxy function before the response function responds with the event object as a parameter; and to obtain the event object as a parameter of the response function from the intercepted response function.
[0159] In one embodiment, the page under test belongs to the interactive page of the vehicle sub-application, and the device further includes an injection module for injecting the proxy function into the logic layer of the vehicle sub-application framework.
[0160] The event object storage module 902 is further configured to intercept the event response function by running the interception code of the proxy function in the logic layer before the proxy function in the logic layer is run to call the response function.
[0161] In one embodiment, the apparatus further includes an event trigger detection module, configured to initiate the detection of triggered events after the proxy function is injected into the logic layer of the vehicle sub-application framework;
[0162] The event object storage module 902 is further configured to, after starting the detection of a triggered event, intercept the event's response function by running the interception code of the proxy function in the logic layer before the proxy function in the logic layer is run to call the response function.
[0163] In one embodiment, the injection module is further configured to inject the proxy function into the logic layer of the vehicle sub-application framework after starting the vehicle simulator when the page under test runs on the vehicle sub-application framework and the vehicle sub-application framework runs on the vehicle simulator.
[0164] In one embodiment, the event object storage module 902 is further configured to obtain the event type of the event from the event object corresponding to the event; when the event type indicates that the event is an event that needs to be mapped to a test case, the event object corresponding to the event is stored.
[0165] In one embodiment, the page under test is an interactive page of an in-vehicle sub-application, and the device further includes an event object forming module, which is used to form an event object corresponding to the event when an event bound to a target element in the page under test is detected by the rendering layer of the running in-vehicle sub-application framework, based on the event type of the event provided by the running rendering layer and the element path of the target element in the page under test provided by the rendering layer.
[0166] In one embodiment, the mapping module 904 is used to pass the element path included in the event object as a parameter to the element retrieval function of the test case, so as to map the target element to the test case to obtain the target test case.
[0167] In one embodiment, the mapping module 904 is used to determine, among the multiple element processing functions corresponding to different events corresponding to the target element, an element processing function whose processing type matches the event type included in the event object, so as to map the event to the test case to obtain the target test case.
[0168] In one embodiment, the testing module 906 is configured to apply the target test case to the page under test, causing the event of the target element on the page under test to be triggered, resulting in a test response page, and obtain a screenshot of the test response page; based on a reference response page obtained when the event bound to the target element on the page under test is triggered, obtain a screenshot of the reference response page; and based on the difference between the screenshot of the test response page and the screenshot of the reference response page, obtain the response status after the event bound to the target element on the page under test is triggered.
[0169] In one embodiment, the test module 906 is further configured to apply the target test cases to the page under test in various operating systems provided by the vehicle simulator, so that the events of the target elements of the page under test are triggered under various operating systems to obtain corresponding test response pages, thereby obtaining test response pages corresponding to various operating systems.
[0170] In one embodiment, the event object saving module 902 is used to save the event object corresponding to the event bound to the target element to a file; the file also stores the event objects corresponding to other events when they are triggered, other than the events bound to the target element in the page under test.
[0171] The device further includes an event object traversal module, used to traverse each event object stored in the file; when traversing to the event object corresponding to the event bound to the target element, the device performs the steps of mapping the target element to a test case according to the element path included in the event object, and mapping the event to the test case according to the event type included in the event object, to obtain the target test case.
[0172] Each module in the aforementioned testing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0173] In one embodiment, a computer device is provided, which may be a terminal or a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, input / output interfaces (I / O interfaces), communication interfaces, a display unit, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a test method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0174] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0175] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps in the various method embodiments described above.
[0176] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the various method embodiments described above.
[0177] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the various method embodiments described above.
[0178] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0179] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0180] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0181] The above embodiments are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A testing method, characterized in that, The method includes: After an event bound to a target element on the page under test is triggered, and after the event object corresponding to the event is passed to the event's response function, before the response function responds with the event object as a parameter, the interception code of the proxy function is used to intercept the event's response function; the interception code is used to store the corresponding response function in a set array; From the intercepted response function, obtain and save the event object as a parameter of the response function, the event object including at least the element path of the target element in the page under test and the event type of the event; Based on the element path included in the event object, the target element is mapped to the test case, and based on the event type included in the event object, the event is mapped to the test case to obtain the target test case; Based on the target test case, test the response status after the event bound to the target element in the page under test is triggered.
2. The method according to claim 1, characterized in that, The method further includes: The proxy function invokes the response function on behalf of the obtained event object.
3. The method according to claim 1, characterized in that, The page under test is an interactive page of an in-vehicle sub-application, and the method further includes: Inject the proxy function into the logic layer of the vehicle sub-application framework; The step of intercepting the event response function by running interception code of the proxy function before the response function responds with the event object as a parameter includes: The event's response function is intercepted by running the intercept code of the proxy function in the logic layer before the response function is invoked on behalf of the proxy function.
4. The method according to claim 3, characterized in that, The method further includes: After injecting the proxy function into the logic layer of the vehicle sub-application framework, the system starts detecting the triggered events. The step of intercepting the event's response function by running the interception code of the proxy function in the logic layer before delegating the call to the response function includes: After the event is detected, the event's response function is intercepted by running the intercept code of the proxy function in the logic layer before the response function is called on behalf of the proxy function.
5. The method according to claim 3, characterized in that, The step of injecting the proxy function into the logic layer of the vehicle sub-application framework includes: When the page under test runs on the vehicle sub-application framework, and the vehicle sub-application framework runs on the vehicle simulator, the proxy function is injected into the logic layer of the vehicle sub-application framework after the vehicle simulator is started.
6. The method according to claim 1, characterized in that, The event object that stores parameters for the response function includes: Obtain the event type from the event object corresponding to the event; When the event type indicates that the event needs to be mapped to a test case, the event object, which is used as a parameter of the response function, is saved.
7. The method according to claim 1, characterized in that, The page under test is an interactive page of an in-vehicle sub-application. Before saving the event object as a parameter of the response function, the method further includes: When an event bound to a target element in the page under test is detected by the rendering layer of the running vehicle sub-application framework, an event object corresponding to the event is formed by the event type provided by the running rendering layer and the element path of the target element in the page under test provided by the rendering layer.
8. The method according to claim 1, characterized in that, The step of mapping the target element to the test case based on the element path included in the event object includes: The element path included in the event object is passed as a parameter to the element retrieval function of the test case to map the target element to the test case to obtain the target test case.
9. The method according to claim 1, characterized in that, The step of mapping the event to the test case based on the event type included in the event object to obtain the target test case includes: Among the multiple element processing functions corresponding to the target element, determine the element processing function whose processing type matches the event type included in the event object, so as to map the event to the test case to obtain the target test case.
10. The method according to claim 1, characterized in that, The step of testing the response status after the event bound to the target element in the page under test is triggered, according to the target test case, includes: Apply the target test case to the page under test, so that the event of the target element of the page under test is triggered to obtain the test response page, and obtain a screenshot of the test response page. Based on the reference response page obtained when the event bound to the target element in the page under test is triggered, obtain a screenshot of the reference response page; Based on the differences between the screenshot of the test response page and the screenshot of the reference response page, the response status after the event bound to the target element in the test page is triggered is obtained.
11. The method according to claim 10, characterized in that, The step of applying the target test case to the page under test, causing the event of the target element on the page under test to be triggered, and obtaining a screenshot of the test response page, includes: In the various operating systems provided by the vehicle simulator, the target test cases are applied to the page under test, so that the events of the target elements of the page under test are triggered under various operating systems to obtain the corresponding test response pages, so as to obtain the test response pages corresponding to various operating systems.
12. The method according to claim 1, characterized in that, The event object that stores parameters for the response function includes: Save the event object corresponding to the event bound to the target element to a file; the file also stores the event objects corresponding to other events, other than the event bound to the target element in the page under test, when they are triggered; The method further includes: Iterate through the event objects stored in the file; When traversing to the event object corresponding to the event bound to the target element, the steps of mapping the target element to the test case according to the element path included in the event object, and mapping the event to the test case according to the event type included in the event object, are executed to obtain the target test case.
13. A testing device, characterized in that, The device includes: An event object storage module is used to intercept the event response function by running interception code of a proxy function after an event bound to a target element in the page under test is triggered, after the event object corresponding to the event is passed to the event response function, and before the response function responds with the event object as a parameter. The interception code is used to store the corresponding response function in a set array. From the intercepted response function, the module obtains and saves the event object as a parameter of the response function. The event object includes at least the element path of the target element in the page under test and the event type of the event. The mapping module is used to map the target element to a test case according to the element path included in the event object, and to map the event to the test case according to the event type included in the event object, so as to obtain the target test case; The testing module is used to test the response status of the event bound to the target element in the page under test after it is triggered, based on the target test case.
14. The apparatus according to claim 13, characterized in that, The device further includes a proxy invocation module, used to invoke the response function on behalf of the obtained event object through the proxy function.
15. The apparatus according to claim 13, characterized in that, The page under test is an interactive page of an in-vehicle sub-application. The device also includes an injection module for injecting the proxy function into the logic layer of the in-vehicle sub-application framework. The event object storage module is used to intercept the event response function by running the interception code of the proxy function in the logic layer before the proxy function in the logic layer is called.
16. The apparatus according to claim 15, characterized in that, The device further includes an event trigger detection module, which is used to detect triggered events after the proxy function is injected into the logic layer of the vehicle sub-application framework; The event object storage module is used to intercept the event response function by running the interception code of the proxy function in the logic layer before the proxy function in the logic layer is called on behalf of the event response function after the event is detected.
17. The apparatus according to claim 15, characterized in that, The injection module is further configured to inject the proxy function into the logic layer of the vehicle sub-application framework after starting the vehicle simulator when the tested page runs on the vehicle sub-application framework and the vehicle sub-application framework runs on the vehicle simulator.
18. The apparatus according to claim 13, characterized in that, The event object storage module is further configured to obtain the event type of the event from the event object corresponding to the event; when the event type indicates that the event is an event that needs to be mapped to a test case, the event object is stored as a parameter of the response function.
19. The apparatus according to claim 13, characterized in that, The page under test is an interactive page of the vehicle sub-application. The device also includes an event object forming module, which is used to form an event object corresponding to the event when an event bound to a target element in the page under test is detected by the rendering layer of the running vehicle sub-application framework. This event object is formed by the event type provided by the running rendering layer and the element path of the target element in the page under test provided by the rendering layer.
20. The apparatus according to claim 13, characterized in that, The mapping module is used to pass the element path included in the event object as a parameter to the element retrieval function of the test case, so as to map the target element to the test case to obtain the target test case.
21. The apparatus according to claim 13, characterized in that, The mapping module is used to determine, among the multiple element processing functions corresponding to the target element, an element processing function whose processing type matches the event type included in the event object, so as to map the event to the test case to obtain the target test case.
22. The apparatus according to claim 13, characterized in that, The testing module is used to apply the target test case to the page under test, so that the event of the target element of the page under test is triggered to obtain the test response page, and to obtain a screenshot of the test response page. Based on the reference response page obtained when the event bound to the target element in the page under test is triggered, obtain a screenshot of the reference response page; Based on the differences between the screenshot of the test response page and the screenshot of the reference response page, the response status after the event bound to the target element in the test page is triggered is obtained.
23. The apparatus according to claim 22, characterized in that, The testing module is used to apply the target test cases to the page under test in various operating systems provided by the vehicle simulator, so that the events of the target elements of the page under test are triggered under various operating systems to obtain the corresponding test response pages, so as to obtain test response pages corresponding to various operating systems.
24. The apparatus according to claim 13, characterized in that, The event object saving module is used to save the event object corresponding to the event bound to the target element to a file; the file also stores the event objects corresponding to other events, other than the event bound to the target element in the page under test, when they are triggered; the device further includes an event object traversal module, used to traverse each event object stored in the file; when traversing to the event object corresponding to the event bound to the target element, the steps of mapping the target element to a test case according to the element path included in the event object, and mapping the event to the test case according to the event type included in the event object, are executed to obtain the target test case.
25. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 12.
26. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 12.
27. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 12.
Citation Information
Patent Citations
Page code testing method and device
CN103678105A
Application program testing method and device, electronic equipment and storage medium
CN110781091A
Test case generation method, device and equipment
CN113254338A