Mobile terminal user interface testing method based on data simulation and storage medium
By intercepting API access requests and obtaining simulated backend response data, it supports mock testing and network interface testing, solving the problem of backend dependency in mobile user interface testing, and realizing flexible testing methods and efficient business scenario testing.
Patent Information
- Application Number
- CN202210051316.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2042-01-17
AI Technical Summary
In mobile user interface testing, existing technologies cannot flexibly test specific steps and rely on the backend service environment, resulting in insufficient testing flexibility.
By intercepting API access requests, obtaining simulated backend response data, and executing test cases, the system supports both mock testing and network interface testing. Users can select the test project entry point through interactive operations to generate simulated backend response data, enabling testing without requesting backend data via network interfaces.
It improves the flexibility and efficiency of testing, avoids dependence on backend servers, supports the selection and switching of multiple testing methods, and enables flexible testing of business scenarios.
Smart Images

Figure CN114564382B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a mobile user interface testing method and storage medium based on data simulation. Background Technology
[0002] Mobile user interface (User Interface) testing requires retrieving necessary data from the backend to execute tests, thus relying on the backend service environment. Furthermore, for process-related User Interface testing, it's necessary to sequentially execute the prerequisite steps of the step to be tested according to the process order to obtain the prerequisite data for that step before executing the step to be tested. This makes it impossible to test specific steps, resulting in significant inflexibility. Summary of the Invention
[0003] This invention provides a mobile user interface testing method based on data simulation, comprising: executing test cases for a business scenario; during the execution of the test cases, in response to receiving an interface access request, intercepting the interface access request and obtaining backend response simulation data corresponding to the interface access request, and continuing to execute the test cases based on the backend response simulation data; after the test cases are executed, obtaining the test case execution result, and determining whether the business scenario passes the test based on the test case execution result.
[0004] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. Before executing test cases of business scenarios, the method further includes: in response to receiving a user interaction operation, displaying a selection list of at least one test project entry.
[0005] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. The user interaction operation includes a shake operation or a click operation. The at least one test project entry point includes a mock test project entry point and a network interface test project entry point. The mock test project entry point is used to execute mock test code blocks, which are used to perform mobile user interface testing based on the backend response simulation data. The network interface test project entry point is used to execute network interface test code blocks, which are used to perform mobile user interface testing through a network interface. After displaying the selection list of at least one test project entry point and before executing test cases for the business scenario, the method further includes receiving user selection information for the mock test project entry point.
[0006] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. Before executing test cases of a business scenario, the method further includes: obtaining request parameters and backend return parameters of the interface access request; wherein, the request parameters include preset key request parameters and remaining request parameters; obtaining a first preset value of the preset key request parameters and a second preset value of the backend return parameters, and randomly generating values for the remaining request parameters; generating simulated backend response data corresponding to the interface access request based on the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameters, the values of the remaining request parameters, and the second preset value of the backend return parameters.
[0007] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. The step of obtaining the request parameters and backend return parameters of the interface access request includes: obtaining the request parameters and backend return parameters of the interface access request from the cloud; the step of obtaining the first preset value of the preset key request parameter and the second preset value of the backend return parameter includes: obtaining the first preset value of the preset key request parameter and the second preset value of the backend return parameter from the cloud.
[0008] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, wherein the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters are stored in a data table in the cloud.
[0009] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, wherein intercepting the interface access request includes: intercepting the interface access request by instrumentation set according to the interface method.
[0010] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. Before executing test cases for business scenarios, the method further includes: constructing the mock test code block according to the backend response simulation data involved in each business scenario, and isolating the mock test code block and the network interface test code block through switch configuration;
[0011] The switch configuration sets the mock test project entry point for executing the mock test code block and the network interface test project entry point for executing the network interface test code block.
[0012] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, wherein the test cases for executing business scenarios include: executing the test cases corresponding to the multiple business scenarios in sequence according to a pre-set test order of multiple business scenarios.
[0013] This invention also provides a mobile user interface testing system based on data simulation, comprising: a test execution module, configured to: execute test cases for a business scenario; during the execution of the test cases, in response to receiving an interface access request, intercept the interface access request, and obtain backend response simulation data corresponding to the interface access request, and continue executing the test cases based on the backend response simulation data; and a test result acquisition module, configured to: after the test cases are executed, acquire the test case execution result, and determine whether the business scenario passes the test based on the test case execution result.
[0014] This invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of the mobile user interface testing method based on data simulation described above.
[0015] This invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the mobile user interface testing method based on data simulation as described above.
[0016] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described data simulation-based mobile user interface testing methods.
[0017] The mobile user interface testing method and storage medium based on data simulation provided in this invention intercepts interface access requests during the execution of test cases, obtains backend response simulation data corresponding to the interface access requests, and continues to execute test cases based on the backend response simulation data. This eliminates the need to request backend data through network interfaces, thus avoiding dependence on backend servers during testing and improving flexibility by allowing testing to be performed according to flexibly configured business scenarios. Attached Figure Description
[0018] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is one of the flowcharts of the mobile user interface testing method based on data simulation provided in the embodiments of the present invention;
[0020] Figure 2 This is the second flowchart of the mobile user interface testing method based on data simulation provided in this embodiment of the invention;
[0021] Figure 3 This is a schematic diagram of the technical architecture of the automated test script in the mobile user interface testing method based on data simulation provided in the embodiments of the present invention;
[0022] Figure 4 This is a schematic diagram of the technical architecture of the mobile user interface testing method based on data simulation provided in an embodiment of the present invention;
[0023] Figure 5 This is a schematic diagram of the structure of a mobile user interface testing system based on data simulation provided in an embodiment of the present invention;
[0024] Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0026] Figure 1 This is one of the flowcharts illustrating a mobile user interface testing method based on data simulation provided in an embodiment of the present invention. For example... Figure 1 As shown, the method includes:
[0027] Step 101: Execute test cases for the business scenario; during the execution of test cases, in response to the acquisition of interface access requests, intercept the interface access requests, and obtain the backend response simulation data corresponding to the interface access requests, and continue to execute test cases based on the backend response simulation data.
[0028] The mobile user interface testing method based on data simulation provided in this invention can be used for user interface testing of mobile devices. Different business scenarios can be set according to testing requirements. Business scenarios can be small or large. Small business scenarios correspond to a single small function, which corresponds to a single operation step or a few simple operation steps. Large business scenarios correspond to complex operation steps, and can even correspond to all operations of the entire APP.
[0029] Test cases should be pre-designed for each business scenario. Test cases can include verification points (such as the project to be verified), test steps, involved pages, and user interface elements. For test cases involving API method calls (initiating API access requests to the backend by calling API methods), test cases can also include the API method request parameters (parameters used when the mobile device initiates an API access request to the backend), backend return parameters (parameters used when the backend responds to the API access request), and the order in which the API methods are called. Here, "backend" can refer to a backend server.
[0030] During the execution of test cases, whenever an interface access request is received—that is, information indicating that the mobile device is about to initiate an interface access request to the backend—the interface access request is intercepted, preventing it from being sent to the backend. Pre-generated simulated backend response data corresponding to the interface access request is then retrieved. This simulated backend response data is used to simulate the backend response data sent to the mobile device after the interface access request is sent to the backend. The test cases continue to execute based on this simulated backend response data.
[0031] Step 102: After the test cases are executed, obtain the test case execution results and determine whether the business scenario passes the test based on the test case execution results.
[0032] After the test cases are executed, obtain the test case execution results, such as the redirected page and the returned result. Compare the test case execution results with the expected results. If the test case execution results match the expected results, the business scenario test passes; if the test case execution results do not match the expected results, the business scenario test fails. Record the bug (error) information, modify it, and continue testing.
[0033] The mobile user interface testing method based on data simulation provided in this invention intercepts interface access requests during the execution of test cases, obtains simulated backend response data corresponding to the interface access requests, and continues to execute test cases based on the simulated backend response data. This eliminates the need to request backend data through network interfaces, thus avoiding dependence on backend servers during the testing process. Furthermore, it allows for flexible testing based on flexibly configured business scenarios, improving flexibility.
[0034] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. Before executing test cases of business scenarios, the method further includes: in response to receiving a user interaction operation, displaying a selection list of at least one test project entry.
[0035] Test case execution can be triggered by selecting a test project entry point. Different test project entry points can represent different testing methods. A selection list of at least one test project entry point can be displayed on the interface for the user to choose from.
[0036] The display of a selection list for at least one test project entry point can be triggered by a predefined user interaction. Specifically, in response to receiving a user interaction, a selection list for at least one test project entry point is displayed.
[0037] The mobile user interface testing method based on data simulation provided in this invention displays a selection list of at least one test project entry point in response to received user interaction operations, which helps to facilitate the selection of different testing methods.
[0038] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. The user interaction operation includes a shake operation or a click operation. The at least one test project entry point includes a mock test project entry point and a network interface test project entry point. The mock test project entry point is used to execute mock test code blocks, which are used to perform mobile user interface testing based on the backend response simulation data. The network interface test project entry point is used to execute network interface test code blocks, which are used to perform mobile user interface testing through a network interface. After displaying the selection list of at least one test project entry point and before executing test cases for the business scenario, the method further includes receiving user selection information for the mock test project entry point.
[0039] The user interaction that triggers the display of the test project entry selection list can be a shake action. This can be triggered upon receiving a shake action after the mobile device is powered on. Alternatively, it can be a click action. An initial test interface can be set, and a trigger button for displaying the test project entry selection list can be placed on this interface. Upon receiving a click on this trigger button, the test project entry selection list will be displayed.
[0040] The test project entry point can include a mock test project entry point and a network interface test project entry point. The mock test project entry point executes mock test code blocks, which perform mobile user interface testing based on simulated backend response data. If the mock test project entry point is selected, mobile user interface testing is performed based on simulated backend response data. The network interface test project entry point executes network interface test code blocks, which perform mobile user interface testing via the network interface. If the network interface test project entry point is selected, testing is performed by actually initiating API access requests to the backend.
[0041] The mobile user interface testing method based on data simulation provided in this invention supports two testing methods: mock testing (performing mobile user interface testing based on simulated backend response data) and ordinary network interface testing (performing mobile user interface testing through a network interface). To implement mock testing, a mock test project entry point needs to be selected. That is, after displaying a selection list of at least one test project entry point and before executing test cases for the business scenario, the method further includes: receiving the user's selection information for the mock test project entry point. During the subsequent execution of test cases for the business scenario, if an interface access request is received, it is intercepted, the simulated backend response data corresponding to the interface access request is obtained, and the test cases continue to be executed based on the simulated backend response data.
[0042] The mobile user interface testing method based on data simulation provided in this invention improves the flexibility of interaction and testing by setting various user interaction operations, triggering the execution of mobile user interface tests using backend response simulation data by setting a mock test project entry point, and triggering the execution of mobile user interface tests using a network interface by setting a network interface test project entry point.
[0043] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided. Before executing test cases of a business scenario, the method further includes: obtaining request parameters and backend return parameters of an interface access request; wherein, the request parameters include preset key request parameters and remaining request parameters; obtaining a first preset value of the preset key request parameters and a second preset value of the backend return parameters, and randomly generating values for the remaining request parameters; generating simulated backend response data corresponding to the interface access request based on the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameters, the values of the remaining request parameters, and the second preset value of the backend return parameters.
[0044] Before executing test cases for business scenarios, it is necessary to generate simulated backend response data for the interface access requests involved in the business scenario in advance.
[0045] Each API access request corresponds to an API method, generating simulated backend response data for the API access request, i.e., simulated backend response data for the API method. The simulated backend response data for the API method is related to the data structure of the API method and the values of the parameters involved in the API method (including request parameters and backend return parameters). Among these, the request parameters that affect the returned result are preset key request parameters, and the rest are remaining request parameters. The backend return parameters are the parameters that need to be returned based on the logical requirements of the preset key request parameters; these parameters determine the style of the user interface or the redirection logic.
[0046] You can pre-assign values to the preset key request parameters and backend return parameters according to the test requirements, that is, pre-set the first preset value of the preset key request parameters and the second preset value of the backend return parameters.
[0047] When generating simulated backend response data corresponding to an API access request, the following steps can be taken: First, obtain the request parameters (input parameters) and backend return parameters (output parameters) of the API access request. The request parameters include preset key request parameters and remaining request parameters. Obtain the first preset value of the preset key request parameters and the second preset value of the backend return parameters, and randomly generate the values of the remaining request parameters. Generate simulated backend response data corresponding to the API access request based on the data structure of the API method corresponding to the API access request, the first preset value of the preset key request parameters, the values of the remaining request parameters, and the second preset value of the backend return parameters.
[0048] Interface data can be downloaded in advance from an interface system (such as a weapon system), parsed, and the data structure of the interface method can be obtained. The data structure of the interface method includes the data structure of the backend response data. The values of the request parameters (including the first preset value of the preset key request parameters and the values of the remaining request parameters) and the second preset value of the backend request parameters are filled into the data structure of the backend response data to obtain the simulated backend response data.
[0049] A mapping relationship can be established between backend response simulation data and the request parameters of the corresponding interface access request. After obtaining the interface access request, the request parameters are obtained, and the corresponding backend response simulation data is obtained according to the mapping relationship between the backend response simulation data and the request parameters of the interface access request.
[0050] The mobile user interface testing method based on data simulation provided in this invention generates simulated backend response data corresponding to the interface access request by generating the simulated backend response data according to the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameters, the values of the remaining request parameters, and the second preset value of the backend return parameters. This enables the rapid generation of simulated backend response data.
[0051] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, which obtains the request parameters and backend return parameters of an interface access request, including: obtaining the request parameters and backend return parameters of the interface access request from the cloud; obtaining a first preset value of a preset key request parameter and a second preset value of the backend return parameter, including: obtaining the first preset value of the preset key request parameter and the second preset value of the backend return parameter from the cloud.
[0052] The request parameters and backend return parameters of the interface access request, as well as the first preset value of the key request parameters and the second preset value of the backend return parameters, can be pre-stored in the cloud. When generating simulated backend response data corresponding to the interface access request, the request parameters and backend return parameters of the interface access request, the first preset value of the key request parameters and the second preset value of the backend return parameters are obtained from the cloud, and then simulated backend response data corresponding to the interface access request is generated based on the randomly generated values of the remaining request parameters and the data structure of the interface method.
[0053] The mobile user interface testing method based on data simulation provided in this invention obtains the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters from cloud storage. The parameter configuration supports cloud storage, which can enable multiple devices to update the test version together and pull the parameter configuration at regular intervals to ensure data timeliness.
[0054] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, wherein the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters are stored in a data table in the cloud.
[0055] The request parameters for API access requests, backend response parameters, the first preset value of key request parameters, and the second preset value of backend response parameters can be stored in a cloud-based data table (such as an Excel spreadsheet). This simplifies the storage of parameter configurations and makes them easy to retrieve.
[0056] The mobile user interface testing method based on data simulation provided in this invention simplifies the storage and facilitates the retrieval of parameter configurations by storing the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters in a data table in the cloud.
[0057] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, which intercepts interface access requests, including: intercepting interface access requests through instrumentation set by the corresponding interface method.
[0058] You can set instrumentation for corresponding interface methods. For example, you can set instrumentation for corresponding interface methods based on AOP (Aspect Oriented Programming) instrumentation technology to intercept interface access requests through the instrumentation set for the corresponding interface method.
[0059] The mobile user interface testing method based on data simulation provided in this embodiment of the invention effectively intercepts interface access requests by using instrumentation settings in the corresponding interface methods.
[0060] According to the mobile user interface testing method based on data simulation provided in the embodiments of the present invention, before executing test cases for business scenarios, the method further includes: constructing mock test code blocks based on backend response simulation data involved in each business scenario; isolating the mock test code blocks and network interface test code blocks through switch configuration; and setting the mock test project entry point for executing the mock test code blocks and the network interface test project entry point for executing the network interface test code blocks according to the switch configuration.
[0061] Mock test code blocks are constructed based on the simulated backend responses from various business scenarios. Each business scenario can include all business scenarios of the app to be tested. The simulated backend responses for each business scenario are the simulated backend responses corresponding to the interface access requests involved in that scenario. There may be overlap in the interface access requests across different business scenarios; therefore, deduplicated simulated backend responses for each business scenario's interface access requests can be obtained. Mock test code blocks are then constructed based on this deduplicated simulated backend responses from each business scenario. These mock test code blocks are used to perform mobile user interface testing based on the simulated backend responses.
[0062] The mock test block and the network interface test block can be isolated by configuring a switch. The network interface test block is used to perform mobile user interface tests via the network interface. For example, when the switch is configured to "test", the network interface test block is run; when the switch is configured to "mock", the mock test block is run.
[0063] A test project package is generated based on the mock test code block and the network interface test code block. During testing, the test project package needs to be packaged from the app, and then the mock test code block and the network interface test code block can be used for testing respectively.
[0064] You can set the mock test project entry point for executing mock test code blocks and the network interface test project entry point for executing network interface test code blocks. These entry points are associated with switch configurations. For example, when selecting the mock test project entry point, the switch is configured as "mock"; when selecting the network interface test project entry point, the switch is configured as "test".
[0065] The mobile user interface testing method based on data simulation provided in this invention constructs mock test code blocks based on backend response simulation data involved in various business scenarios. By isolating the mock test code blocks and network interface test code blocks through switch configuration, it is beneficial to achieve the integration of network interface testing and data simulation testing without mutual interference. The mock test project entry point for executing the mock test code blocks and the network interface test project entry point for executing the network interface test code blocks are set according to the switch configuration, which facilitates easy switching of test methods.
[0066] According to an embodiment of the present invention, a mobile user interface testing method based on data simulation is provided, which executes test cases for business scenarios, including: executing test cases corresponding to multiple business scenarios sequentially according to a pre-set test order of multiple business scenarios.
[0067] Depending on the testing requirements, a single business scenario can be specified for testing, or multiple business scenarios can be specified for testing. When specifying multiple business scenarios for testing, the execution order of the multiple business scenarios is preset, and the execution order of the corresponding test cases is set according to the execution order of the multiple business scenarios. The test cases are then executed sequentially according to the execution order of the test cases of the multiple business scenarios, realizing automated testing of multiple business scenarios.
[0068] The mobile user interface testing method based on data simulation provided in this invention achieves automated testing under multiple business scenarios and improves testing efficiency by executing test cases corresponding to multiple business scenarios sequentially according to the pre-set test order of multiple business scenarios.
[0069] Figure 2 This is the second flowchart illustrating the mobile user interface testing method based on data simulation provided in this embodiment of the invention. Figure 2 As shown, the method includes:
[0070] Test cases are written based on the test scenario (the business scenario to be tested), and the relevant data of the test cases is stored in a cloud data table. The relevant data of the test cases includes the request parameters of the interface methods involved in the business scenario, the backend return parameters, and the first preset value of the preset key request parameters and the second preset value of the backend return parameters.
[0071] The system first retrieves interface data from the weapon system, downloads it, and returns JSON-structured interface data. It then parses the data structure of this interface data and encapsulates it into usable data, such as constructing Java-based bean entity classes. Each interface data point corresponds to an interface method, including the data structure of that method.
[0072] The system retrieves the request parameters of the API method, the backend return parameters, and the first preset value of the key request parameters and the second preset value of the backend return parameters from the cloud. It then randomly generates the values of the remaining request parameters of the API method and combines them with the data structure of the API method to generate mock data of the backend response.
[0073] Mock test code blocks are constructed based on backend response simulation data involved in various business scenarios. These mock test code blocks and network interface test code blocks are isolated via a switch configuration. Depending on the switch configuration, mock test code blocks based on backend response simulation data can be executed in mock mode, while network interface test code blocks can be executed in test mode.
[0074] Generate a test project package based on the mock test code block and the network interface test code block. Package the app into a test project package, which allows the application to be tested in two modes (mock test mode and network interface test mode). Before testing, it is necessary to set up the test environment, design test cases, and write test scripts.
[0075] A shake-to-play feature can be configured. When the application is launched on a mobile device and a shake notification is received, a selection list for the mock test project entry and the network interface test project entry will pop up, allowing users to choose the test mode. Selecting the mock test project entry will execute test cases using simulated backend response data. The automated script will directly call the mock branch (the branch corresponding to the mock test project entry) to test the user interface and navigation logic. Selecting the network interface test project entry will execute test cases via network requests (interaction with the backend).
[0076] For example, if a mock test project entry point is selected, the test results will determine whether the test passes. If it passes, a test report for the current test scenario will be generated. If it fails, the bug details will be recorded, and the bug will be regressed to the test. The code can be modified until the test passes.
[0077] The mobile user interface testing method based on data simulation provided in this invention can flexibly construct various request parameters according to the interface situation and test the expected jump or display results associated with the specified backend return parameters; it eliminates the dependence on the backend service environment and focuses the test on user interface inspection; it can dynamically configure parameters, manage configurations uniformly, and add, delete, and group them; it does not require pre-construction of data and the test data can cover more scenarios.
[0078] Figure 3 This is a schematic diagram of the technical architecture of the automated test script in the mobile user interface testing method based on data simulation provided in this embodiment of the invention. For example... Figure 3 As shown, from high to low, it involves the business layer, page, underlying operation and underlying technical support.
[0079] At the underlying technical level, an automated testing framework based on the PageObject pattern can be implemented using the Appium protocol and pytest. At the underlying operational level, this can involve actions such as clicking, swiping up and down, inputting text, and invoking the keyboard. At the page level, this may involve the homepage and different functional pages, including login and logout pages. At the business layer, taking online warehouse management as an example, this could involve operations such as login, logout, and switching warehouses.
[0080] Figure 4 This is a schematic diagram of the technical architecture of the mobile user interface testing method based on data simulation provided in an embodiment of the present invention. Figure 4 As shown, the underlying services involved in this method include a basic network framework, AOP (Aspect-Oriented Programming), and JSON parsing technology. Regarding data parsing, it involves fetching data through a weapon interface, parsing the weapon interface data, and constructing bean entity classes from the parsed data. For data mocking, it involves interface method instrumentation, importing test case interfaces (importing test scripts), scenario judgment (including identifying interface methods involved in business scenarios), intelligent generation of mock data (generating mock data corresponding to interface methods, i.e., simulated backend response data), and dynamic scenario interaction (executing user interface interactions during testing). Regarding user interface data display, it involves returning interface data (returning simulated backend response data corresponding to interface methods), testing through custom simulated clicks, and binding user interface elements during the testing process.
[0081] The following describes the mobile user interface testing system based on data simulation provided in the embodiments of the present invention. The mobile user interface testing system based on data simulation described below can be referred to in correspondence with the mobile user interface testing method based on data simulation described above.
[0082] Figure 5 This is a schematic diagram of the structure of a mobile user interface testing system based on data simulation provided in an embodiment of the present invention. Figure 5 As shown, the system includes a test execution module 10 and a test result acquisition module 20. The test execution module 10 is used to: execute test cases for business scenarios; during the execution of test cases, in response to receiving an interface access request, intercept the interface access request and obtain the backend response simulation data corresponding to the interface access request, and continue to execute test cases based on the backend response simulation data; the test result acquisition module 20 is used to: after the test cases are executed, obtain the test case execution results, and determine whether the business scenario passes the test based on the test case execution results.
[0083] The mobile user interface testing system based on data simulation provided in this invention intercepts interface access requests during the execution of test cases, obtains simulated backend response data corresponding to the interface access requests, and continues to execute test cases based on the simulated backend response data. This eliminates the need to request backend data through network interfaces, thus avoiding dependence on backend servers during testing and allowing for flexible testing based on flexibly configured business scenarios, thereby improving flexibility.
[0084] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. Before executing test cases for business scenarios, the test execution module 10 is further configured to: display a selection list of at least one test project entry point in response to receiving a user interaction operation.
[0085] The mobile user interface testing system based on data simulation provided in this invention displays a selection list of at least one test project entry point in response to received user interaction operations, which helps to facilitate the selection of different testing methods.
[0086] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. The user interaction operation includes a shake operation or a click operation. The at least one test project entry point includes a mock test project entry point and a network interface test project entry point. The mock test project entry point is used to execute mock test code blocks, which are used to perform mobile user interface testing based on the backend response simulation data. The network interface test project entry point is used to execute network interface test code blocks, which are used to perform mobile user interface testing through a network interface. After displaying the selection list of at least one test project entry point and before executing test cases for the business scenario, the test execution module 10 is further configured to: receive user selection information for the mock test project entry point.
[0087] The mobile user interface testing system based on data simulation provided in this invention improves the flexibility of interaction and testing by setting various user interaction operations, triggering the execution of mobile user interface tests using backend response simulation data by setting a mock test project entry point, and triggering the execution of mobile user interface tests using network interfaces by setting a network interface test project entry point.
[0088] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. The system further includes a backend response simulation data generation module. Before the test execution module 10 is executed, the backend response simulation data generation module is used to: obtain the request parameters and backend return parameters of the interface access request; wherein, the request parameters include preset key request parameters and remaining request parameters; obtain the first preset value of the preset key request parameters and the second preset value of the backend return parameters, and randomly generate the value of the remaining request parameters; generate backend response simulation data corresponding to the interface access request according to the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameters, the value of the remaining request parameters, and the second preset value of the backend return parameters.
[0089] The mobile user interface testing system based on data simulation provided in this invention generates simulated backend response data corresponding to the interface access request by using the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameters, the values of the remaining request parameters, and the second preset value of the backend return parameters. This enables the rapid generation of simulated backend response data.
[0090] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. When the backend response simulation data generation module is used to obtain the request parameters of the interface access request and the backend return parameters, it is specifically used to: obtain the request parameters of the interface access request and the backend return parameters from the cloud; when the backend response simulation data generation module is used to obtain the first preset value of the preset key request parameters and the second preset value of the backend return parameters, it is specifically used to: obtain the first preset value of the preset key request parameters and the second preset value of the backend return parameters from the cloud.
[0091] The mobile user interface testing system based on data simulation provided in this invention obtains the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters from cloud storage. The parameter configuration supports cloud storage, enabling multiple devices to update the test version together and periodically pull the parameter configuration to ensure data timeliness.
[0092] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided, wherein the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters are stored in a data table in the cloud.
[0093] The mobile user interface testing system based on data simulation provided in this invention simplifies the storage and facilitates the retrieval of parameter configurations by storing the request parameters of the interface access request, the backend return parameters, the first preset value of the preset key request parameters, and the second preset value of the backend return parameters in a data table in the cloud.
[0094] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. When the test execution module 10 is used to intercept interface access requests, it is specifically used to: intercept interface access requests by instrumenting the corresponding interface method.
[0095] The mobile user interface testing system based on data simulation provided in this embodiment of the invention effectively intercepts interface access requests by instrumenting corresponding interface methods.
[0096] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. The system further includes a project package configuration module. Before the test execution module 10 executes test cases for business scenarios, the project package configuration module is used to: construct mock test code blocks based on the backend response simulation data involved in each business scenario; isolate the mock test code blocks and network interface test code blocks through switch configuration; and set the mock test project entry point for executing the mock test code blocks and the network interface test project entry point for executing the network interface test code blocks according to the switch configuration.
[0097] The mobile user interface testing system based on data simulation provided in this invention constructs mock test code blocks based on backend response simulation data involved in various business scenarios. By configuring switches, the mock test code blocks and network interface test code blocks are isolated, which facilitates the integration of network interface testing and data simulation testing without mutual interference. The switch configuration sets the mock test project entry point for executing the mock test code blocks and the network interface test project entry point for executing the network interface test code blocks, which facilitates easy switching of test methods.
[0098] According to an embodiment of the present invention, a mobile user interface testing system based on data simulation is provided. When the test execution module 10 is used to execute test cases for business scenarios, it is specifically used to: execute test cases corresponding to multiple business scenarios in sequence according to the pre-set test order of multiple business scenarios.
[0099] The mobile user interface testing system based on data simulation provided in this invention achieves automated testing under multiple business scenarios and improves testing efficiency by executing test cases corresponding to multiple business scenarios sequentially according to the pre-set test order of multiple business scenarios.
[0100] Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiment of the present invention, such as... Figure 6As shown, the electronic device may include a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, communications interface 620, and memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute a mobile user interface testing system based on data simulation. This method includes: executing test cases for a business scenario; during the execution of the test cases, in response to receiving an interface access request, intercepting the interface access request and obtaining the backend response simulation data corresponding to the interface access request, and continuing to execute the test cases based on the backend response simulation data; after the test cases are executed, obtaining the test case execution result, and determining whether the business scenario passes the test based on the test case execution result.
[0101] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0102] On the other hand, embodiments of the present invention also provide a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the mobile user interface testing method based on data simulation provided by the above methods. The method includes: executing test cases for a business scenario; during the execution of the test cases, in response to obtaining an interface access request, intercepting the interface access request and obtaining backend response simulation data corresponding to the interface access request, and continuing to execute the test cases based on the backend response simulation data; after the test cases are executed, obtaining the test case execution result, and determining whether the business scenario passes the test based on the test case execution result.
[0103] In another aspect, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements a mobile user interface testing method based on data simulation provided by the above methods. The method includes: executing test cases for a business scenario; during the execution of the test cases, in response to receiving an interface access request, intercepting the interface access request and obtaining backend response simulation data corresponding to the interface access request, and continuing to execute the test cases based on the backend response simulation data; after the test cases are executed, obtaining the test case execution result, and determining whether the business scenario passes the test based on the test case execution result.
[0104] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.
[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for testing a mobile user interface based on data simulation, the method comprising: The method comprises: executing a test case of a business scenario; during execution of the test case, in response to obtaining an interface access request, intercepting the interface access request, obtaining backend response simulation data corresponding to the interface access request, and continuing to execute the test case based on the backend response simulation data; after the test case is executed, obtaining a test case execution result, and determining whether the business scenario passes the test according to the test case execution result; before the test case of the business scenario is executed, the method further comprises: obtaining request parameters and backend return parameters of the interface access request; wherein the request parameters comprise preset key request parameters and remaining request parameters, the request parameters affecting the return result are the preset key request parameters, and the remaining request parameters are the remaining request parameters; obtaining a first preset value of the preset key request parameter and a second preset value of the backend return parameter, and randomly generating a value of the remaining request parameter; generating the backend response simulation data corresponding to the interface access request according to the data structure of the interface method corresponding to the interface access request, the first preset value of the preset key request parameter, the value of the remaining request parameter, and the second preset value of the backend return parameter.
2. The method of claim 1, wherein, Before the test case of the business scenario is executed, the method further comprises: in response to receiving a user interaction operation, displaying a selection list of at least one test project entry.
3. The method of claim 2, wherein, The user interaction operation includes a shake operation or a click operation, and the at least one test project entry includes a mock test project entry and a network interface test project entry; wherein the mock test project entry is used to execute a mock test code block, the mock test code block is used to execute a mobile terminal user interface test based on the backend response simulation data, and the network interface test project entry is used to execute a network interface test code block, the network interface test code block is used to execute a mobile terminal user interface test through a network interface; after displaying the selection list of at least one test project entry and before executing the test case of the business scenario, the method further comprises: receiving user selection information of the mock test project entry.
4. The method of claim 1, wherein, The method further comprises: obtaining the request parameters and the backend return parameters of the interface access request from the cloud; 5. The method of claim 4, wherein, obtaining the first preset value of the preset key request parameter and the second preset value of the backend return parameter from the cloud.
6. The method of claim 1, wherein, The request parameters, the backend return parameters, the first preset value of the preset key request parameter, and the second preset value of the backend return parameter of the interface access request are stored in a data table in the cloud. The method further comprises:
7. The method of claim 3, wherein, intercepting the interface access request by plugging in the interface method. Before the test case of the business scenario is executed, the method further comprises: The mock test code block is constructed according to the backend response simulation data related to each business scenario, and the mock test code block and the network interface test code block are isolated through a switch configuration; and the mock test engineering entrance for executing the mock test code block and the network interface test engineering entrance for executing the network interface test code block are set according to the switch configuration.
8. The mobile end user interface testing method based on data simulation according to claim 1, wherein, The test case of the business scenario comprises: According to the test sequence of the plurality of business scenarios set in advance, the test cases corresponding to the plurality of business scenarios are executed in sequence. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to realize the steps of the mobile terminal user interface test method based on data simulation according to any one of claims 1 to 8.
Citation Information
Patent Citations
Interface testing method and device and computer equipment
CN110232018A
Mock test method and device, electronic equipment and medium
CN113190464A
Automatic testing method and device for user interface
CN113704110A