Nothing Special   »   [go: up one dir, main page]

CN116662143A - Test method, apparatus, device, storage medium and computer program product - Google Patents

Test method, apparatus, device, storage medium and computer program product Download PDF

Info

Publication number
CN116662143A
CN116662143A CN202210153603.XA CN202210153603A CN116662143A CN 116662143 A CN116662143 A CN 116662143A CN 202210153603 A CN202210153603 A CN 202210153603A CN 116662143 A CN116662143 A CN 116662143A
Authority
CN
China
Prior art keywords
event
page
response
test case
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210153603.XA
Other languages
Chinese (zh)
Inventor
毕志棉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202210153603.XA priority Critical patent/CN116662143A/en
Publication of CN116662143A publication Critical patent/CN116662143A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

The application provides a testing method, a testing device, testing equipment, a storage medium and a computer program product, which can be applied to a testing scene of a vehicle-mounted application to test the response condition of an interaction page of the vehicle-mounted sub-application. The application can improve the generation efficiency of the test case, and comprises the following steps: after an event bound with a target element in a tested page is triggered, saving an event object corresponding to the event, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event; mapping the target element into the test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain the target test case; and testing the response condition of the event bound with the target element in the tested page after being triggered according to the target test case.

Description

Test method, apparatus, device, storage medium and computer program product
Technical Field
The present application relates to the field of computer processing technology, and in particular, to a test method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of computer technology, in order to enable a user to better interact with a computer, a page capable of interacting with the user appears, the user can operate on the page, for example, click a button on the page, and the computer can respond to the user through the page, for example, display corresponding content on the page.
After a page is developed, it is generally necessary to simulate the operation of the user on the page before formally providing the page to the user, so as to test whether the response of the page to the operation of the user is normal or not. Generally, test cases may be written manually to simulate user operations on pages, but manually writing test cases is inefficient.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a test method, apparatus, computer device, storage medium, and computer program product that can improve the generation efficiency of test cases to improve the page test efficiency.
The application provides a testing method, which comprises the following steps:
after an event bound with a target element in a tested page is triggered, saving an event object corresponding to the event, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event;
Mapping the target element into a test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain a target test case;
and testing the response condition of the event bound with the target element in the tested page after being triggered according to the target test case.
The application provides a testing device, comprising:
the event object storage module is used for storing an event object corresponding to an event after the event bound with a target element in a tested page is triggered, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event;
the mapping module is used for mapping the target element into a test case according to the element path included by the event object, and mapping the event into the test case according to the event type included by the event object to obtain a target test case;
and the test module is used for testing the response condition of the event bound with the target element in the tested page after being triggered according to the target test case.
In one embodiment, the event object saving module is configured to obtain and save, by a proxy function, the event object that is transferred into the response function of the event, after the event object corresponding to the event is transferred into the response function of the event, before the response function responds with the event object as a parameter;
the device also comprises a proxy calling module, which is used for calling the response function through the proxy function based on the acquired event object.
In one embodiment, the event object saving module is further configured to intercept the response function of the event by running an intercept code of the proxy function before the response function responds with the event object as a parameter; and acquiring an event object serving as a parameter of the response function from the intercepted response function.
In one embodiment, the tested page belongs to an interaction page of a vehicle-mounted sub-application, and the device further comprises an injection module for injecting the proxy function into a logic layer of the vehicle-mounted sub-application framework;
the event object saving module is further configured to intercept a response function of the event by running an interception code of the proxy function in the logic layer before the proxy function in the logic layer is run to proxy-call the response function.
In one embodiment, the device further comprises an event trigger detection module, configured to initiate detection of a triggered event after the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework;
the event object saving module is further configured to intercept a response function of the event by running an interception code of the proxy function in the logic layer before the proxy function in the logic layer is executed to proxy the response function after the triggered event is detected.
In one embodiment, the injection module is further configured to inject the proxy function into the logic layer of the vehicle-mounted sub-application framework after the vehicle simulator is started when the tested page is operated by the vehicle-mounted sub-application framework and the vehicle-mounted sub-application framework is operated by the vehicle simulator.
In one embodiment, the event object saving module is further configured to obtain an event type of the event from an event object corresponding to the event; and when the event type characterizes the event as the event to be mapped to the test case, storing an event object corresponding to the event.
In one embodiment, the tested page belongs to an interaction page of a vehicle-mounted sub-application, and the device further comprises an event object forming module, configured to form an event object corresponding to the event through an event type of the event provided by the running rendering layer and an element path of a target element provided by the rendering layer in the tested page when the event bound with the target element in the tested page is detected by the rendering layer running the vehicle-mounted sub-application framework.
In one embodiment, the mapping module is configured to transfer the element path included in the event object as a parameter into an element obtaining function of the test case, so as to map the target element to the test case to obtain the target test case.
In one embodiment, the mapping module is configured to determine, from a plurality of 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, and obtain the target test case.
In one embodiment, the test module is configured to apply the target test case to the tested page, so that an event of a target element of the tested page is triggered to obtain a test response page, and obtain a screenshot of the test response page; acquiring a screenshot of a reference response page based on the reference response page obtained when the event bound with a target element in the tested page is triggered; and obtaining the response condition of the event bound with the target element in the tested page after being triggered according to the difference between the screenshot of the test response page and the screenshot of the reference response page.
In one embodiment, the test module is further configured to apply the target test case to the tested page in various operating systems provided by the vehicle-to-machine simulator, so that an event of a target element of the tested page is triggered under various operating systems to obtain a corresponding test response page, so as to obtain test response pages corresponding to various operating systems.
In one embodiment, the event object saving module is configured to save an event object corresponding to the event bound to the target element into a file; the file also stores event objects corresponding to other events except the event bound with the target element in the tested page when the other events are triggered;
the device also comprises an event object traversing module, a file processing module and a file processing module, wherein the event object traversing module is used for traversing each event object stored in the file; and when traversing to an event object corresponding to the event bound with the target element, executing the steps of mapping the target element into a test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain a target test case.
The present application provides a computer device comprising a memory storing a computer program and a processor executing the above-described test method.
The present application provides a computer readable storage medium having stored thereon a computer program for execution by a processor of the above-described test method.
The present application provides a computer program product comprising a computer program which, when executed by a processor, implements the above-described test method.
In the test method, the device, the computer equipment, the storage medium and the computer program product, after the event bound with the target element in the tested page is triggered, the event object corresponding to the triggered event is stored, and because the event object at least comprises the element path of the target element in the tested page and the event type of the triggered event, the target element can be mapped into the test case according to the element path included in the event object, and the triggered event can be mapped into the test case according to the event type included in the event object, so that the target test case is automatically generated without manual writing; and the response condition of the event bound with the target element in the tested page after being triggered can be tested directly according to the automatically generated target test case, so that the page test efficiency is improved; in addition, because the event object includes the element path of the target element in the tested page, when the starting tag of the target element does not include the unique identifier or class name of the target element, the target element can be mapped into the test case based on the element path of the target element in the tested page, so that a developer of the tested page is prevented from modifying the starting tag of the target element when the test case is formed, and the code processing amount is reduced.
Drawings
FIG. 1 is a diagram of an application environment for a test method in one embodiment;
FIG. 2 is a flow chart of a test method in one embodiment;
FIG. 3 is a schematic diagram of elements of a tested page in one embodiment;
FIG. 4 is a schematic diagram of an element node tree of a tested page in one embodiment;
FIG. 5 is a schematic diagram of an in-vehicle sub-application framework in one embodiment;
FIG. 6 is a schematic diagram illustrating the operation types of a user-tested page to be simulated in one embodiment;
FIG. 7 is a flow diagram of collecting event objects required to generate a target test case in one embodiment;
FIG. 8 is a flow diagram of element mapping and event mapping in one implementation;
FIG. 9 is a block diagram of a test apparatus in one embodiment;
fig. 10 is an internal structural view of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the described embodiments of the application may be combined with other embodiments.
FIG. 1 is a diagram of an application environment for a test method in one implementation. Referring to fig. 1, a terminal 102 may interact with a server 104 through a communication network; the terminal 102 may be, but not limited to, various desktop computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster or cloud server composed of a plurality of servers. Wherein the server 104 may be integrated with a data storage system; it will be appreciated that the server 104 may also be located separately from the data storage system.
The terminal 102 can display a tested page, and after an event bound with a target element in the tested page is triggered, an event object formed when the event bound with the target element is triggered can be sent to the server 104; the event object includes at least an element path of the target element in the tested page and an event type of the event. The server 104 may store the received event object in the data storage system, and in addition, the server 104 may map the target element into the test case according to the element path included in the event object, map the event into the test case according to the event type included in the event object, obtain the target test case, and test the response condition after the event bound with the target element in the tested page is triggered according to the target test case.
The test method provided by the application can be cooperatively executed by the terminal and the server, or can be independently executed by the terminal or the server. In one embodiment, the method is described as being performed by a terminal; FIG. 2 is a flow chart of a testing method in one embodiment, the method comprising the steps of:
step S202, after the event bound with the target element in the tested page is triggered, saving an event object corresponding to the event, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event.
The tested page is an interaction page to be tested for the response condition of user operation; the tested page can be an interactive page of a browser, an interactive page of a vehicle-mounted sub-application and the like. The tested page can be constructed based on a tag language, and accordingly, the basic constituent units of the tested page are tags, and a hierarchical structure is formed between the tags. The tags included in the interactive pages constructed based on the tag language basically comprise a language identification tag, a page title identification tag and a page body identification tag. The start and end of each tag may be defined by the start tag and end tag of the tag; for example, the start tag of the language identification tag is < html >, and the end tag of the language identification tag is </html >; for another example, the start tag of the page title identification tag is < head >, and the end tag of the title identification tag is </head >; for another example, the start tag of the page body identification tag is < body >, and the end tag of the page body identification tag is </body >. The language identification tag is a father-level tag of the page title identification tag and the page body identification tag, and the page title identification tag and the page body identification tag are the same-level tag; based on the hierarchical relationship among the language identification tag, the page title identification tag and the page body identification tag, the formed tag structure is as follows:
<html>
<head></head>
<body></body>
</html>
The page body identification tag may include sub-level tags, such as a button, an input text box, etc., the number of the included sub-level tags may be at least one, the page body identification tag and the sub-level tag of the page body identification tag may be referred to as elements, the elements have a hierarchical relationship, and the elements having the hierarchical relationship may form an element node tree of the tested page.
FIG. 3 is an element schematic diagram of a tested page in one embodiment, referring to FIG. 3, the elements in the tested page may include element 300, element 301, element 302, element 3011, and element 3012, where element 300 corresponds to a page body identification tag and element 301, element 302, element 3011, and element 3012 are sub-level tags of the page body identification tag.
Wherein the hierarchical relationship between element 300 and element 301 is: element 301 is a sub-level tag of element 300; the hierarchical relationship between element 300 and element 302 is: element 302 is the tag of element 300; the hierarchical relationship between element 301 and element 302 is: element 301 and element 302 are the same level tag; likewise, the hierarchical relationship between element 301 and element 3011 is: element 3011 is a sub-level label for element 301; the hierarchical relationship between element 301 and element 3012 is: element 3012 is a sub-level label for element 301; the hierarchical relationship between element 3011 and element 3012 is: element 3011 and element 3012 are the same level tags.
FIG. 4 is a schematic diagram of an element node tree of a tested page in one embodiment; referring to fig. 4, based on the hierarchical relationship among the elements 300, 301, 302, 3011, and 3012, the element node tree shown in fig. 4 can be obtained, in which the node a corresponds to the element 300, the node b corresponds to the element 301, and the node c corresponds to the element 302, and the node d corresponds to the element 3011, and the node e corresponds to the element 3012, respectively.
The element path is a path of each element in the element node tree of the tested page, for example, the path of the element 3011 in the element node tree shown in fig. 4 is: node a/node b/node d.
When developing the tested page, corresponding events can be bound on elements in the tested page, and each type of event is, for example, a single click event, a double click event, a long press event, a sliding event and the like, and different events correspond to different event types, for example, the event type corresponding to the single click event is a single click. An event bound to an element is triggered when an operation corresponding to the event bound to the element acts on the element, for example, an event bound to a button is a click event, and a click event bound to the button is triggered when a click operation corresponding to the click event acts on the button.
When an event bound to an element is triggered, event processing corresponding to the triggered event may be performed, which may be implemented by a response function of the event. When the event processing is realized through the response function of the event, the response function of the event needs to be carried out according to the event object of the event as a parameter, and the event object of the event is obtained by packaging the related information when the event is triggered.
In one embodiment, a test operation may be input to the tested page by a tester, and if the test operation acts on a target element of the tested page to trigger an event bound to the target element, then information related to the event when triggered may be encapsulated into an event object of the event, where the event object may include at least an element path of the target element bound to the event in the tested page and an event type of the event.
Step S204, mapping the target element into the test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object, so as to obtain the target test case.
The target test case is obtained after element mapping and event mapping; the target test case can simulate the operation of a user on the tested page so as to obtain a corresponding response condition. Specifically, the target test case can act on the tested page in various operating systems to trigger the event of binding the target element in the tested page, so as to obtain corresponding response conditions in various operating systems.
In order to enable the target test case to simulate the operation of a user on the tested page, the elements and the action types of the target test case on the tested page need to be defined. The element acted on can be a page main body corresponding to the page main body identification label in the tested page or a button, an input text box and the like corresponding to the sub-level label of the page main body identification label in the tested page; the action type is the event type of the triggered event, such as a single click, double click, etc.
The target test case can be positioned to the element to be acted in the tested page through the element path included by the event object; the target test case can be enabled to determine the action type through the event type included by the event object.
In one embodiment, the terminal may transfer the element path included in the event object as a parameter into an element acquisition function of the test case, so as to map the target element into the test case to obtain the target test case. Wherein the element retrieval function is a function for locating elements in the page.
The terminal takes the element path of the event object including the target element as a parameter transmitted to the element acquisition function, so that the target element can be positioned when the target test case executes the element acquisition function based on the element path.
In the above embodiment, the element path included in the event object is passed to the element obtaining function as a parameter, and the target element may be located if the start tag of the target element does not include a unique identifier or class name.
In one embodiment, among a plurality of element processing functions corresponding to the target element, the terminal may determine an element processing function whose processing type matches an event type included in the event object, so as to map the triggered event to the test case to obtain the target test case.
The element processing modes are various, such as acquiring element text, acquiring element attributes, clicking elements and the like. Therefore, each element processing mode can correspond to an element processing function, and the processing type of the element processing function is the element processing mode corresponding to the element processing function.
The terminal may determine, from among a plurality of element processing functions, an element processing function whose processing type matches an event type included in the event object, for example, the event type included in the event object is a click, and may determine an element processing function whose processing type matches the event type, where an element processing manner corresponding to the element processing function is also a click. And then, the determined element processing function is put into the test case so as to map the event triggered by the test operation into the test case, thereby obtaining the target test case.
In the above embodiment, the element processing function whose processing type matches the event type included in the event object is determined among the plurality of element processing functions, providing the accuracy of the event mapping.
Step S206, testing the response status of the event bound with the target element in the tested page after being triggered according to the target test case.
The response conditions may include good response conditions and non-good response conditions; the response logic obtained after the good response condition characterizes the target test case is consistent with the response logic which is supposed in advance, and the probability of occurrence of problems of the response logic code of the tested page is low; the response logic obtained after the non-good response condition characterizes the target test case is inconsistent with the pre-conceived response logic, which indicates that the probability of occurrence of problems in the response logic code of the tested page is higher.
After the target test case is obtained, the terminal can act the target test case on the tested page in various operating systems so as to trigger an event bound with a target element in the tested page, and response conditions in various operating systems are obtained.
In the test method, after the event bound with the target element in the tested page is triggered, the event object corresponding to the triggered event is stored, and because the event object at least comprises the element path of the target element in the tested page and the event type of the triggered event, the target element can be mapped into the test case according to the element path included in the event object, and the triggered event can be mapped into the test case according to the event type included in the event object, so that the target test case is automatically generated without manual writing; and the response condition of the event bound with the target element in the tested page after being triggered can be tested directly according to the automatically generated target test case, so that the page test efficiency is improved; in addition, because the event object includes the element path of the target element in the tested page, when the starting tag of the target element does not include the unique identifier or class name of the target element, the target element can be mapped into the test case based on the element path of the target element in the tested page, so that a developer of the tested page is prevented from modifying the starting tag of the target element when the test case is formed, and the code processing amount is reduced.
In one embodiment, after the event object corresponding to the event is transmitted into the response function of the event, the terminal may acquire and store the event object of the transmitted response function through the proxy function before the response function responds with the event object as a parameter; the terminal may also invoke a response function by the proxy function based on the acquired event object.
The proxy function is a function for calling the response function instead of the original function, the proxy function can be obtained by rewriting the original function, and the rewriting mode can be as follows: before the original function calls the code of the response function, the code for intercepting the response function is added. In the on-vehicle sub-application scene, since the interactive page of the on-vehicle sub-application is different from the web page (the page displayed on the browser) and has no window object (the window opened by the browser), interception cannot be performed through the window object, however, the elements of the interactive page of the on-vehicle sub-application are packaged by a page method (which may be called a page packaging method) or a component method (which may be called a component packaging method), so that the page method and the component method can be rewritten, and the rewritten method is used as a proxy function. The manner of rewriting may be: the code that intercepts the response function is added before the code that invokes the response function.
After the event bound with the target element in the tested page is triggered by the test operation, a corresponding event object is formed, the event object is used as a parameter to be transmitted to a response function of the event, and before the response function is executed by taking the event object as the parameter of the response function to realize the response, the event object of the response function transmitted to the event is acquired and stored through the proxy function. The terminal can also use the event object as a parameter of a response function through a proxy function, and the proxy calls the response function to realize response so as to complete event processing.
In the above embodiment, before the response function responds with the event object as a parameter, the event object transmitted to the response function is saved by the proxy function, so as to avoid the destruction of the event object when the event object is not saved; in addition, after the event object is saved, a response function is invoked through a proxy function proxy, so that event processing is completed.
In one embodiment, the terminal may further intercept the response function of the event by running an interception code of the proxy function before the response function responds with the event object as a parameter; from the intercepted response function, an event object is acquired as a parameter of the response function.
The interception code can be realized by storing the interception code into a setting array, and after the event is triggered by the test operation, the corresponding response function is stored into the setting array.
After an event bound with a target element in a tested page is triggered by a test operation, the formed event object is used as a parameter to be transmitted to a response function of the event, the response function of the event is intercepted by running an interception code in the proxy function, and the event object serving as the parameter of the response function is obtained from the intercepted response function.
In the embodiment, the response function of the event triggered by the test operation is intercepted through the interception code in the proxy function, so that the event object is obtained, and further, the test case is automatically generated based on the event object, and the generation efficiency of the test case is improved.
In one embodiment, the tested page belongs to an interactive page of the vehicle-mounted sub-application, and the terminal can also inject the proxy function into a logic layer of the vehicle-mounted sub-application framework; before invoking the response function by running the proxy function in the logical layer to proxy, the terminal may intercept the response function of the event by running an interception code of the proxy function in the logical layer.
The terminal can be used for running an operating system, running a parent application on the operating system and running a child application in an environment provided by the parent application.
An Operating System (OS) is a computer program for managing and controlling terminal hardware and software resources, and is the most basic System software directly running on a bare metal of a terminal, and an application program needs to run under the support of the Operating System. The operating system may be a desktop operating system such as a Windows (Windows) operating system, a Linux operating system, or a Mac OS (apple desktop operating system), or a mobile operating system such as an iOS (mobile operating system developed by apple corporation) or an Android operating system.
A parent application is an application that can run directly on an operating system. The parent application may be a social application, mailbox application, browser application, game application, or the like. The social application may include an instant messaging application, an SNS (Social Network Service, social networking site) application, or a live application, among others.
The child application is an application program that can run in an environment provided by the parent application, i.e., the parent application has a child application function for providing a service for a registered user of the parent application to use the child application in the parent application. The sub-applications may be take-away applications, shopping applications, business super fresh applications, food drink applications, travel applications, and the like. The sub-application may be referred to as an applet.
The vehicle-mounted sub-application is a sub-application applied to a vehicle, and the vehicle-mounted sub-application framework provides an operating environment for a development document of the vehicle-mounted sub-application; the development document of the vehicle-mounted sub application comprises a page structure description document and a page processing logic document; the page structure description document may describe the structure of the interactive page through a markup language. FIG. 5 is a schematic diagram of an in-vehicle sub-application framework in one embodiment, with reference to FIG. 5, a page structure description document may run at a rendering layer of the in-vehicle sub-application framework, and a page processing logic document may run at a logic layer of the in-vehicle sub-application framework; and the rendering layer and the logic layer of the vehicle-mounted sub-application framework are communicated through the parent application to which the vehicle-mounted sub-application belongs.
When the tested page belongs to the interactive page of the vehicle-mounted sub-application, the terminal can inject the proxy function obtained by rewriting the page method and the component rewriting method into the logic layer of the vehicle-mounted sub-application framework.
After determining that an event bound with a target element in a tested page is triggered on a logic layer of a vehicle-mounted sub-application running framework, forming an event object of the event on the logic layer, and transmitting the formed event object from the logic layer to a response function of the logic layer through a parent application to which the vehicle-mounted sub-application belongs. Since the proxy function is injected into the logic layer in advance, after the event object is passed to the response function of the logic layer, the response function can be intercepted by the interception code running the proxy function in the logic layer before the response function is invoked by running the proxy function in the logic layer.
In the above embodiment, the proxy function is pre-injected into the logic layer, so that after the event object is transmitted to the response function of the logic layer, the response function is intercepted by running the proxy function in the logic layer before the proxy function is invoked by proxy, and interception omission is avoided.
In one embodiment, after injecting the proxy function into the logical layer of the vehicle-mounted sub-application framework, the terminal may also initiate detection of the triggered event; after initiating detection of the triggered event, the terminal may also intercept the response function of the event by running an intercept code of the proxy function in the logical layer before invoking the response function in proxy by running the proxy function in the logical layer.
After the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework, the terminal can start to detect whether an event bound with the target element in the tested page is triggered or not, after the event bound with the target element in the tested page is triggered by the test operation after the detection is started, the response function of the triggered event can be intercepted by executing the interception code of the proxy function in the logic layer before the response function is invoked in a proxy by executing the proxy function in the logic layer.
In the above embodiment, after the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework, the triggered event may be started to be detected, and after the triggered event is detected, the terminal may intercept the response function of the event 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 intercepted.
In one embodiment, the tested page belongs to an interactive page of the vehicle-mounted sub-application, and when an event bound with a target element in the tested page is detected through a rendering layer of the running vehicle-mounted sub-application framework, the terminal can also form an event object corresponding to the event through an event type of the event provided by the running rendering layer and an element path of the target element in the tested page provided by the rendering layer.
When an event bound with a target element in a tested page is triggered by a test operation, after the logic layer of the vehicle-mounted sub-application framework detects that the event is triggered, an event type of the triggered event and an element path of the target element in the tested page can be provided through a rendering layer to form an event object corresponding to the triggered event.
In the above embodiment, since the logic layer of the vehicle-mounted sub-application framework supports adding the element path of the target element bound with the triggered event in the event object in the tested page, even if the initial 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 obtain the element path of the target element through the event object, complete the positioning of the target element, avoid the developer of the tested page from modifying the initial tag of the target element when forming the test case, and reduce the code processing amount.
In one embodiment, when the tested page runs on the vehicle-mounted sub-application framework and the vehicle-mounted sub-application framework runs on the vehicle-mounted machine simulator, the terminal can inject the proxy function into the logic layer of the vehicle-mounted sub-application framework after the vehicle-mounted machine simulator is started.
The vehicle simulator is used for simulating the running environment of the vehicle-mounted sub-application framework on the vehicle and providing an operating system of the vehicle supported by the vehicle-mounted sub-application framework during running. Because the vehicle-mounted sub-application framework operates by virtue of the vehicle-mounted simulator, after the vehicle-mounted simulator is started, the terminal can inject the proxy function into a logic layer of the vehicle-mounted sub-application framework.
In the above embodiment, after the vehicle simulator is started, the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework, so as to ensure that the proxy function can be successfully injected into the vehicle-mounted sub-application framework.
In one embodiment, the terminal may further obtain an event type of the event from an event object corresponding to the event; when the event type represents the event which needs to be mapped to the test case, the event object corresponding to the event is stored.
The events to be mapped to the test case can be predefined, and a click event, a sliding event, an input event, a carriage return event, a long press event, a page switch event, a page return event, a screen capture event, or the like can be used as the events to be mapped to the test case.
After the event bound with the target element in the tested page is triggered by the test operation, a corresponding event object is formed, the terminal can acquire the event type of the event triggered by the test operation from the event object, and when the event type represents the event required to be mapped to the event of the test case by the event triggered by the test operation, the terminal can comprise the event object.
In the above embodiment, before the event object of the event triggered by the test operation is saved, whether the triggered event is an event that needs to be mapped to the test case is determined according to 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 the test case.
In one embodiment, the terminal may further apply the target test case to the tested page, so that an event of a target element of the tested page is triggered to obtain a test response page, and a screenshot of the test response page is obtained; acquiring a screenshot of a reference response page based on the reference response page obtained when an event bound with a target element in the tested page is triggered; and obtaining the response condition after the event bound with the target element in the tested page is triggered according to the difference between the screenshot of the test response page and the screenshot of the reference response page.
The test response page is obtained by applying the target test case obtained after element mapping to the tested page, specifically, after the target test case is obtained through element mapping, the target test case is applied to the tested page, so that an event bound with the target element of the tested page is triggered, and a corresponding response page is obtained, wherein the response page is called a test response page.
The reference response page is obtained when the event objects required by the test case are collected for element mapping, specifically, when the event bound with the target element in the tested page is triggered by the test operation, the response page can be obtained, and the response page is called as the reference response page.
After obtaining the test response page, the terminal can obtain a screenshot of the test response page, and after obtaining the reference response page, the terminal can obtain a screenshot of the reference response page; the terminal may then compare the difference between the screenshot of the test response page and the screenshot of the reference response page, and determine a response condition after an event bound to the target element in the tested page is triggered based on the difference. Specifically, when the difference between the screenshot of the test response page and the screenshot of the reference response page is smaller than a threshold value, determining that the response condition after the event bound with the target element in the tested page is triggered is in a good response condition; when the difference between the screenshot of the test response page and the screenshot of the reference response page is greater than a threshold value, determining that the response condition after the event bound with the target element in the tested page is triggered is in a non-good response condition.
In the above embodiment, the screenshot of the reference response page obtained when the event bound with the target element in the tested page is triggered by the test operation is stored in the event object collecting process, and the difference is compared with the screenshot of the test response page obtained when the subsequent target test case acts on the tested page, so that the response condition after the event bound with the target element in the tested page is triggered can be automatically determined without manual intervention.
In one embodiment, the terminal may further apply the target test case to the tested page in various operating systems provided by the vehicle-mounted simulator, so that the event of the target element of the tested page is triggered under various operating systems to obtain a corresponding test response page, so as to obtain test response pages corresponding to various operating systems.
Because different vehicle types are different in operating systems, in order to ensure that the response of the vehicle-mounted sub-application in the operating systems of most vehicle types is normal, the response condition of the interactive page of the vehicle-mounted sub-application in the operating systems of various vehicle types needs to be tested.
The vehicle-mounted simulator can provide operating systems of various vehicle types, and the terminal can act on the tested page by the target test cases obtained after element mapping and event mapping in various operating systems provided by the vehicle-mounted simulator, so that the event bound with the target element of the tested page is triggered under various operating systems to obtain test response pages corresponding to various operating systems.
And then, the terminal can compare the screenshot of the test response page corresponding to various operating systems with the screenshot of the reference response page in a difference manner so as to determine the response condition of the interactive page of the vehicle sub-application in various operating systems.
In the above embodiment, in various operating systems provided by the vehicle-mounted simulator, the target test case may be applied to the tested page to obtain test response pages corresponding to the various operating systems, so as to determine whether the response of the vehicle-mounted sub-application in the various operating systems is normal.
In one embodiment, the terminal may further save an event object corresponding to the event bound to the target element to the file; the file also stores event objects corresponding to other events except the event bound with the target element in the tested page when the other events are triggered; the terminal can also traverse each event object stored in the file; and when traversing to an event object corresponding to the event bound with the target element, executing 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.
After the event bound with the target element is triggered by the test operation, a corresponding event object is formed, and the terminal can store the event object into a file; similarly, when the test operation triggers other events in the tested page, the terminal can save the event objects of the other events in the file. When element mapping and event mapping are needed, the terminal can traverse each event object in the file, map the corresponding element into the test case based on the traversed element path in each event object, and map the corresponding event into the test case based on the traversed event type in each event object to form the corresponding target test case of each event object.
In the embodiment, the event objects are uniformly stored in the same file, and then the event objects of the file can be directly traversed to restore to obtain each target test case, so that the test case generation efficiency is improved.
In order to better understand the above method, an application example of the test method of the present application is described in detail below. In this embodiment of the application, the tested page belongs to an interaction page of the vehicle-mounted sub-application. FIG. 6 is a schematic diagram illustrating the operation types of a user-tested page to be simulated in one embodiment; referring to fig. 6, when the functions provided by the tested page include: when the user clicks the button, the default page clicks the button, the page sliding event, the component clicks the button and jumps to the new page button, operations of various functions provided by the tested page need to be simulated to see whether the response condition of the tested page is normal, for example, operations of the user clicking the button need to be simulated to see whether the response condition of the tested page is normal, for example, operations of the user sliding the page need to be simulated to see whether the sliding of the tested page is normal, for example, operations of the user clicking the jump to the new page button need to be simulated to see whether the jump from the tested page to the new page is performed.
FIG. 7 is a flow diagram of collecting event objects required to generate a target test case in one embodiment;
the steps shown in fig. 7 may be performed by a terminal, and referring to fig. 7, mainly include the steps of:
step S702, when the tested page runs by the vehicle-mounted sub-application frame and the vehicle-mounted sub-application frame runs by the vehicle-mounted simulator, starting the vehicle-mounted simulator;
step S704, injecting the proxy function into a logic layer of the vehicle-mounted sub-application framework;
in the on-vehicle sub-application scene, because the interactive page of the on-vehicle sub-application is different from the web page and has no window object, interception can not be performed through the window object, however, the elements of the interactive page of the on-vehicle sub-application are packaged through a page method or a component method, so that the page method and the component method can be rewritten, and the rewritten method is used as a proxy function.
Step S706, starting to detect whether an event is triggered;
the principle of detecting that an event is triggered is: if a certain response function is called by the proxy function, an event corresponding to the called response function is triggered; and the proxy calls a certain response function through the proxy function, so that an event object serving as a parameter of the response function can be obtained, and whether an event triggered by the test operation is an event to be mapped to the test case or not is judged through the event type in the event object.
Step S708, receiving a test operation on the tested page;
step S710, after the event bound with the target element in the tested page is triggered by the test operation, obtaining a reference response page, and obtaining a screenshot of the reference response page;
step S712, testing whether the operation is ended;
if the test operation is not finished, jumping back to step S708; if the test operation is finished, jumping to step S714;
step S714, saving an event object corresponding to the event bound to the target element triggered by the test operation;
wherein, each saved event object can comprise the following information:
(1) A path of a page to which an element bound to an event triggered by a test operation belongs;
(2) A time stamp of when the event was triggered by the test operation;
(3) Event type of event triggered by test operation;
(4) When the test operation is an operation of inputting content, testing the content input by the operation; when the test operation is an operation of sliding the page body, testing a sliding distance of the operation on the page;
(5) Waiting time for the last test operation;
(6) Element path in the page to which the target element bound to the event triggered by the test operation belongs.
After the event objects formed by the test operation are saved, element mapping and event mapping can be performed on each event object, so as to obtain a target test case corresponding to each event object.
FIG. 8 is a flow diagram of element mapping and event mapping in one implementation. The steps shown in fig. 8 may be performed by a terminal, and referring to fig. 8, mainly include the steps of:
step S802, acquiring a file for storing an event object;
step S804, traversing each event object in the file;
step S806, for each traversed event object, mapping the event corresponding to the event object into the test case according to the event type included in the event object;
step S808, for each traversed event object, mapping the target element bound by the event corresponding to the event object into the test case according to the element path included by the event object;
step S810, aiming at each traversed event object, obtaining a target test case of the event object after event mapping and element mapping related to the event object are completed, and applying the target test case to a tested page to obtain a response condition of the tested page;
In various operating systems provided by the vehicle-mounted simulator, a target test case is applied to a tested page to trigger an event bound with a target element in the tested page, so as to obtain a corresponding test response page and a screenshot of the test response page; and then, comparing the screenshot of the test response page with the screenshot of the reference response page stored in the event object acquisition process, if the difference between the screenshot of the test response page and the screenshot of the reference response page is smaller than a threshold value, indicating that the response condition of the tested page in the corresponding operating system is in a good response condition, and if the difference between the screenshot of the test response page and the screenshot of the reference response page is larger than the threshold value, indicating that the response condition of the tested page in the corresponding operating system is in a non-good response condition, wherein the code of the tested page possibly has a problem.
Step S812, whether the event object in the file is traversed;
if the traversing is completed, ending element mapping and event mapping; if the traversal is not completed, the process returns to step S804.
In the above embodiment, a tester may input a test operation to a tested page, and when the test operation triggers an event bound with an element in the tested page, intercept an event object of the event, and automatically generate a target test case according to information included in the event object; subsequently, the automatically generated target test case can be applied to the tested page in various operating systems provided by the vehicle model device, and the response condition of the tested page in various operating systems is verified, so that the page test efficiency is improved.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a testing device for realizing the testing method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitations and technical effects of one or more embodiments of the test device provided below may be referred to above for the limitations and technical effects of the test method, which are not described herein.
FIG. 9 is a block diagram of a test apparatus in one embodiment. Referring to fig. 9, the apparatus includes:
an event object saving module 902, configured to save an event object corresponding to an event after an event bound to a target element in a tested page is triggered, where the event object includes at least an element path of the target element in the tested page and an event type of the event;
a mapping module 904, configured to map the target element to a test case according to the element path included in the event object, and map the event to the test case according to the event type included in the event object, so as to obtain a target test case;
and a testing module 906, configured to test, according to the target test case, a response condition after the event bound to the target element in the tested page is triggered.
In one embodiment, the event object saving module 902 is configured to obtain and save, by a proxy function, the event object that is transferred into the response function of the event, after the event object corresponding to the event is transferred into the response function of the event, before the response function responds with the event object as a parameter;
The device also comprises a proxy calling module, which is used for calling the response function through the proxy function based on the acquired event object.
In one embodiment, the event object saving module 902 is further configured to intercept the response function of the event by running the interception code of the proxy function before the response function responds with the event object as a parameter; and acquiring an event object serving as a parameter of the response function from the intercepted response function.
In one embodiment, the tested page belongs to an interaction page of a vehicle-mounted sub-application, and the device further comprises an injection module for injecting the proxy function into a logic layer of the vehicle-mounted sub-application framework;
the event object saving module 902 is further configured to intercept a response function of the event by executing an interception code of the proxy function in the logical layer before executing the proxy function in the logical layer to proxy the response function.
In one embodiment, the device further comprises an event trigger detection module, configured to initiate detection of a triggered event after the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework;
The event object saving module 902 is further configured to intercept, after initiating detection of a triggered event, a response function of the event by executing an intercept code of the proxy function in the logical layer before invoking the response function by executing the proxy function in the logical layer.
In one embodiment, the injection module is further configured to inject the proxy function into the logic layer of the vehicle-mounted sub-application framework after the vehicle simulator is started when the tested page is operated by the vehicle-mounted sub-application framework and the vehicle-mounted sub-application framework is operated by the vehicle simulator.
In one embodiment, the event object saving module 902 is further configured to obtain an event type of the event from an event object corresponding to the event; and when the event type characterizes the event as the event to be mapped to the test case, storing an event object corresponding to the event.
In one embodiment, the tested page belongs to an interaction page of a vehicle-mounted sub-application, and the device further comprises an event object forming module, configured to form an event object corresponding to the event through an event type of the event provided by the running rendering layer and an element path of a target element provided by the rendering layer in the tested page when the event bound with the target element in the tested page is detected by the rendering layer running the vehicle-mounted sub-application framework.
In one embodiment, the mapping module 904 is configured to transfer the element path included in the event object as a parameter into an element obtaining function of the test case, so as to map the target element to the test case to obtain the target test case.
In one embodiment, the mapping module 904 is configured to determine, from a plurality of element processing functions corresponding to different events and 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, so as to obtain the target test case.
In one embodiment, the test module 906 is configured to apply the target test case to the tested page, so that an event of a target element of the tested page is triggered to obtain a test response page, and obtain a screenshot of the test response page; acquiring a screenshot of a reference response page based on the reference response page obtained when the event bound with a target element in the tested page is triggered; and obtaining the response condition of the event bound with the target element in the tested page after being triggered according to the difference between the screenshot of the test response page and the screenshot of the reference response page.
In one embodiment, the test module 906 is further configured to apply the target test case to the tested page in various operating systems provided by the vehicle simulator, so that an event of a target element of the tested page is triggered under various operating systems to obtain a corresponding test response page, so as to obtain test response pages corresponding to various operating systems.
In one embodiment, the event object saving module 902 is configured to save an event object corresponding to the event bound to the target element into a file; the file also stores event objects corresponding to other events except the event bound with the target element in the tested page when the other events are triggered;
the device also comprises an event object traversing module, a file processing module and a file processing module, wherein the event object traversing module is used for traversing each event object stored in the file; and when traversing to an event object corresponding to the event bound with the target element, executing the steps of mapping the target element into a test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain a target test case.
The various modules in the test apparatus described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal or a server, and the internal structure of which may be as shown in fig. 10. The computer device comprises a processor, a memory, an Input/Output interface (I/O interface for short), a communication interface, a display unit and an Input means, which are connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input-output interface of the computer device is used for exchanging information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a test method. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 10 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory storing a computer program and a processor implementing the steps of the method embodiments described above when the processor executes the computer program.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the respective method embodiments described above.
In one embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the various method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application, which are described in detail and are not to be construed as limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of protection of the present application is to be determined by the appended claims.

Claims (17)

1. A method of testing, the method comprising:
after an event bound with a target element in a tested page is triggered, saving an event object corresponding to the event, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event;
mapping the target element into a test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain a target test case;
And testing the response condition of the event bound with the target element in the tested page after being triggered according to the target test case.
2. The method of claim 1, wherein the saving the event object corresponding to the event comprises:
after an event object corresponding to the event is transmitted into a response function of the event, acquiring and storing the event object transmitted into the response function through a proxy function before the response function responds by taking the event object as a parameter;
the method further comprises the steps of:
and invoking the response function by the proxy function based on the acquired event object.
3. The method according to claim 2, wherein the obtaining and saving the event object incoming to the response function by a proxy function before the response function responds with the event object as a parameter comprises:
intercepting a response function of the event by an interception code running the proxy function before the response function responds by taking the event object as a parameter;
and acquiring an event object serving as a parameter of the response function from the intercepted response function.
4. A method according to claim 3, wherein the tested page belongs to an interactive page of a vehicle-mounted sub-application, the method further comprising:
injecting the proxy function into a logic layer of the vehicle-mounted sub-application framework;
before the response function responds by taking the event object as a parameter, intercepting the response function of the event by running the interception code of the proxy function, and the method comprises the following steps:
intercepting a response function of the event by running an interception code of the proxy function in the logical layer before executing the proxy function in the logical layer to proxy the call of the response function.
5. The method according to claim 4, wherein the method further comprises:
after the proxy function is injected into the logic layer of the vehicle-mounted sub-application framework, starting to detect a triggered event;
intercepting the response function of the event by executing the interception code of the proxy function in the logical layer before the proxy function in the logical layer is executed to proxy the call of the response function, comprising:
after initiating detection of a triggered event, intercepting a response function of the event by executing an interception code of the proxy function in the logical layer before invoking the response function by executing the proxy function in the logical layer.
6. The method of claim 4, wherein the injecting the proxy function into the logical layer of the in-vehicle sub-application framework comprises:
when the tested page runs by depending on the vehicle-mounted sub-application framework and the vehicle-mounted sub-application framework runs by depending on the vehicle-machine simulator, the proxy function is injected into a logic layer of the vehicle-mounted sub-application framework after the vehicle-machine simulator is started.
7. The method of claim 1, wherein the saving the event object corresponding to the event comprises:
acquiring the event type of the event from the event object corresponding to the event;
and when the event type characterizes the event as the event to be mapped to the test case, storing an event object corresponding to the event.
8. The method of claim 1, wherein the tested page belongs to an interactive page of a vehicle-mounted sub-application, and wherein prior to saving an event object corresponding to the event, the method further comprises:
when an event bound with a target element in a tested page is detected through a rendering layer running the vehicle-mounted sub-application framework, an event object corresponding to the event is formed through an event type of the event provided by the running rendering layer and an element path of the target element provided by the rendering layer in the tested page.
9. The method according to claim 1, wherein the mapping the target element into a test case according to the element path included in the event object includes:
and taking the element path included in the event object as a parameter to be transmitted into an element acquisition function of the test case so as to map the target element into the test case to obtain the target test case.
10. The method according to claim 1, wherein the mapping the event to the test case according to the event type included in the event object to obtain a target test case includes:
and determining an element processing function with a processing type consistent with the event type included in the event object from a plurality of element processing functions corresponding to the target element, so as to map the event to the test case to obtain the target test case.
11. The method according to claim 1, wherein the testing the response status after the event bound to the target element in the tested page is triggered according to the target test case includes:
the target test case is acted on the tested page, so that an event of a target element of the tested page is triggered to obtain a test response page, and a screenshot of the test response page is obtained;
Acquiring a screenshot of a reference response page based on the reference response page obtained when the event bound with a target element in the tested page is triggered;
and obtaining the response condition of the event bound with the target element in the tested page after being triggered according to the difference between the screenshot of the test response page and the screenshot of the reference response page.
12. The method of claim 11, wherein the act of applying the target test case to the tested page to cause an event of a target element of the tested page to be triggered to obtain a test response page, and obtaining a screenshot of the test response page comprises:
and in various operating systems provided by the vehicle-mounted simulator, the target test case is acted on the tested page, so that the event of the target element of the tested page is triggered under various operating systems to obtain a corresponding test response page, and the test response page corresponding to various operating systems is obtained.
13. The method of claim 1, wherein the saving the event object corresponding to the event comprises:
storing an event object corresponding to the event bound with the target element into a file; the file also stores event objects corresponding to other events except the event bound with the target element in the tested page when the other events are triggered;
The method further comprises the steps of:
traversing each event object stored in the file;
and when traversing to an event object corresponding to the event bound with the target element, executing the steps of mapping the target element into a test case according to the element path included in the event object, and mapping the event into the test case according to the event type included in the event object to obtain a target test case.
14. A test apparatus, the apparatus comprising:
the event object storage module is used for storing an event object corresponding to an event after the event bound with a target element in a tested page is triggered, wherein the event object at least comprises an element path of the target element in the tested page and an event type of the event;
the mapping module is used for mapping the target element into a test case according to the element path included by the event object, and mapping the event into the test case according to the event type included by the event object to obtain a target test case;
and the test module is used for testing the response condition of the event bound with the target element in the tested page after being triggered according to the target test case.
15. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the method of any one of claims 1 to 13 when executing the computer program.
16. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the method of any one of claims 1 to 13.
17. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the method of any one of claims 1 to 13.
CN202210153603.XA 2022-02-18 2022-02-18 Test method, apparatus, device, storage medium and computer program product Pending CN116662143A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210153603.XA CN116662143A (en) 2022-02-18 2022-02-18 Test method, apparatus, device, storage medium and computer program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210153603.XA CN116662143A (en) 2022-02-18 2022-02-18 Test method, apparatus, device, storage medium and computer program product

Publications (1)

Publication Number Publication Date
CN116662143A true CN116662143A (en) 2023-08-29

Family

ID=87726584

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210153603.XA Pending CN116662143A (en) 2022-02-18 2022-02-18 Test method, apparatus, device, storage medium and computer program product

Country Status (1)

Country Link
CN (1) CN116662143A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117763255A (en) * 2023-10-11 2024-03-26 中国电力科学研究院有限公司 Method for evaluating service system performance after machine learning of browser data

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117763255A (en) * 2023-10-11 2024-03-26 中国电力科学研究院有限公司 Method for evaluating service system performance after machine learning of browser data

Similar Documents

Publication Publication Date Title
US11403364B2 (en) Method and terminal device for extracting web page content
US9183072B1 (en) Error troubleshooting using a correlated knowledge base
US20150236799A1 (en) Method and system for quick testing and detecting mobile devices
US20230035104A1 (en) Verification method, apparatus and device, and storage medium
CN110020370B (en) Method and device for realizing animation in client application and framework of animation script
CN116662143A (en) Test method, apparatus, device, storage medium and computer program product
JP6505849B2 (en) Generation of element identifier
CN111881043B (en) Page testing method and device, storage medium and processor
CN116932392A (en) Interface test method, apparatus, device, storage medium and computer program product
CN115421693A (en) Method and device for realizing micro front-end architecture, computer equipment and storage medium
CN110708270A (en) Abnormal link detection method and device
CN116932356A (en) Cross-platform testing method, device, computer equipment and storage medium
CN107766216A (en) It is a kind of to be used to obtain the method and apparatus using execution information
CN117493113B (en) Data reporting method, device, computer equipment and storage medium
CN113961110B (en) User operation response method, device, computer equipment and storage medium
CN118295897A (en) Method and device for testing application interface, computer equipment and storage medium
CN118245699A (en) Page acquisition method, device, equipment, storage medium and computer program product
CN117971823A (en) Form data storage method, device, computer equipment and storage medium
CN118427199A (en) Multi-language document self-adaptive adaptation method and device
CN117807334A (en) First screen page display method and device, computer equipment and storage medium
CN117389762A (en) Application program interface calling method and device, computer equipment and storage medium
CN118193083A (en) Software resource loading method and device, computer equipment and storage medium
CN116701184A (en) Socket compatibility testing method and device, computer equipment and storage medium
CN118897923A (en) Cross-platform data front-end display method
CN116389409A (en) Page path processing method and device, computer equipment and storage medium

Legal Events

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