An automated testing method based on Windows underlying API without service network
By defining the properties and operation methods of the object being tested based on Windows' underlying API and using the TestTool tool set to intercept and tamper with operation behavior messages, the problem of client UI automation testing in the existing technology is solved, and the serviceless network is realized MOCK testing reduces development costs and improves testing efficiency, ensuring the stability and compatibility of the client UI.
Patent Information
- Application Number
- CN202111400273.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-24
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-11-24
AI Technical Summary
The existing client UI automation testing methods rely on service networks and test piles, resulting in low testing efficiency and high cost, and the inability to perform UI automation testing in a service-free network environment, affecting the stability of the client front-end.
By defining the properties and operation methods of the object being tested, it is based on the Windows underlying API and using the TestTool tool set to intercept, parse and tamper with operation behavior messages, it realizes MOCK testing under a serviceless network, simulates backend data, and ensures the stability of the client UI Sex and robustness.
It realizes automated testing of client UI without the need for service networks and test stakes, which reduces software development costs, improves testing efficiency, saves testing time, and ensures the stability and compatibility of client UI.
Smart Images

Figure CN114138638B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a client UI automation testing method, and in particular to a testing method for implementing client UI automation testing in a serviceless network environment based on intercepting Windows underlying API. Background Art
[0002] In the era of rapid development of the software testing industry, automation technology has become the core skill of the testing industry. Automated testing has many advantages, such as: improving test execution efficiency, saving time costs, thereby freeing up manpower to do more important work; reusable, reducing dependence on people, and significantly reducing the workload of compatibility testing. At present, there are some very mature and stable open source automated testing tools for implementing mainstream client UI automated testing, such as UI Automator, Selenium, AutoIT, WinRunner, etc. These mainstream automated testing tools all require pre-embedded test stubs in software development. When performing UI automated testing in the later stage, the automated testing tools will call the pre-embedded test stubs and use Driver to drive the client to implement UI automated testing. Embedding test stubs in software development provides an effective guarantee for the implementation of automated testing, so the existing automated testing methods rely on pre-embedded test stubs. Embedding test stubs in the software development process will not only increase the volume of the software code itself, but also reduce the efficiency of software development to a certain extent.
[0003] When the existing mainstream automated testing tools perform client UI automated testing, there are two test prerequisites: the first test prerequisite is that the overall test process needs to rely on the support of the service network, otherwise the background data cannot be obtained and the correct test results cannot be obtained. Client UI automated testing is usually tested in a non-production environment (for example: test station environment), and the process of setting up the test station and synchronizing the test data with the main station data requires a lot of time and manpower costs, and the data maintenance of the test station is also relatively cumbersome. Without the support of the background service, it is impossible to perform UI automated testing to ensure the stability of the client front-end UI. The second test prerequisite is that the robustness of the test client is achieved through MOCK testing. MOCK testing requires the construction of a MOCK test environment (the construction and configuration of the MOCK server), and MOCK testing is performed after the MOCK server is built. Summary of the invention
[0004] The purpose of the present invention is to provide a method for realizing automatic testing based on the bottom API of Windows without relying on the service network.
[0005] In order to achieve the above object, the technical solution of the present invention is to provide an automated testing method based on Windows underlying API without a service network, and to implement client UI automated testing based on Windows underlying API in a serviceless network environment, characterized in that it includes the following steps:
[0006] Step 1: Define the objects to be tested in the operation layer, each of which has properties and operation methods defined by the Windows underlying API function;
[0007] A TestTool tool set is defined in the interpretation layer. The TestTool tool set has at least an interception function, a parsing function, and a tampering function;
[0008] Step 2: The tester performs effective operations on the client under test, and the tester's operation behavior triggers the operation layer to obtain the object under test;
[0009] Step 3: The operation layer automatically analyzes and calls the Windows underlying API function related to the object under test obtained in step 2;
[0010] Step 4: The operation layer parses the underlying API function obtained in step 3 to determine whether there is a service request behavior. If so, the attributes, operation methods and request parameters of the current object under test are fed back as an operation behavior message. If not, the attributes and operation methods of the current object under test are fed back as an operation behavior message.
[0011] Step 5: The TestTool toolset intercepts the operation behavior message of the current object under test fed back by the operation layer based on the interception function. After the operation behavior message is intercepted by the TestTool toolset, the parsing function of the TestTool toolset is triggered;
[0012] Step 6, the TestTool toolset parses the operation behavior message and determines whether there is a service request behavior. If there is a service request behavior, the tampering function of the TestTool toolset is triggered and the process goes to step 7. If there is no service request behavior, the process goes to step 10 after generating a return result based on the intercepted operation behavior message.
[0013] Step 7: The tester chooses to tamper with the service request or not. If the tester chooses to tamper with the service request, the process proceeds to step 8. If the tester chooses not to tamper with the service request, the process proceeds to step 9.
[0014] Step 8: Define return data for different service requests in the interface document, obtain corresponding return data from the interface document according to the current request parameters, use the return data as the return result, and proceed to step 10;
[0015] Step 9: Define return data for different service requests in the interface document. After obtaining the corresponding return data from the interface document according to the current request parameters, the tester tampers with the return data, modifies the specific content of the return data, and uses the modified return data as the return result, and proceeds to step 10;
[0016] Step 10. The TestTool toolset feeds back the returned results to the client under test. The client renders the data based on the returned results to form the display results. Then the tester writes the display results in the corresponding automated test cases and uses assertions for automated judgment, thereby achieving the MOCK automated testing effect.
[0017] Preferably, the measured object is a standardized control or a non-standardized control.
[0018] Preferably, in step 5, the intercepted operation behavior message is temporarily stored in the TestTool tool set.
[0019] Preferably, in step 6, if the operation behavior message includes the request parameter, there is a service request behavior, otherwise, there is no service request behavior.
[0020] Preferably, in step 9, the modified returned data is correct data or erroneous data.
[0021] Preferably, in step 9, the specific modification content of the returned data is defined by the test case.
[0022] Preferably, the tester defines the specific data and data type of the returned result through the TestTool toolset.
[0023] The core of the present invention is to break away from the dependence of the real service network environment on the client's UI automation test, and no test server support is required (the test service deployment step is omitted). In the technical solution provided by the present invention, all operation behaviors of the client based on the Windows underlying API can be regarded as calls to the underlying API. The TestTool toolset in the present invention can achieve the effect of simulating the server network by intercepting and tampering with messages and communication content, returning the background data that the tester needs to test, and realizing the MOCK test effect, thereby ensuring the stability and robustness of the client's UI interface display.
[0024] Compared with existing mainstream automated testing tools, the present invention has the following advantages:
[0025] 1. As an automated testing solution, the present invention can realize automated testing without modifying the target program source code and inserting test stubs in the source code, thereby reducing software development costs and improving testing efficiency.
[0026] 2. The present invention uses the TestTool tool to intercept client operation behaviors and can perform tests in an environment without a service network. The TestTool can directly simulate the data returned by the background, thereby directly realizing the MOCK test effect. There is no need to build a MOCK test environment, saving test time, while ensuring the client's fault tolerance and compatibility for data rendering. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0028] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.
[0029] The present invention provides an automated testing method for bytecode implantation based on the underlying API function of the system. The present invention can realize automated testing without modifying the target program source code, reduce the automation development cost and improve the testing efficiency, and ensure no code intrusion. Different from other hook technologies, the underlying interface of the present invention is encapsulated and optimized, and can effectively identify controls and operate target programs.
[0030] The present invention provides an automated testing method based on Windows underlying API without the need for a service network, which is mainly implemented in two layers: the first layer is the operation layer, which is used to define the object under test; the second layer is the interpretation layer, and the TestTool toolset uses the Windows underlying API to interpret the behavior of the object under test defined by the operation layer. At the same time, the TestTool toolset intercepts the client behavior (i.e., the client's operation on the object under test), and returns normal data and abnormal data (MOCK) after interception. Finally, the client renders the front-end page based on the normal data or abnormal data returned from the TestTool toolset, thereby achieving the effect of testing the compatibility and fault tolerance of the client data. The first layer (operation layer) and the second layer (interpretation layer) are described in detail below:
[0031] The first layer: the operation layer. The tester performs effective operations on the client under test, and the operation behavior defines the object under test (the object under test is a standardized control or a non-standardized control). The object under test has certain properties and operation methods. The properties and operation methods of the object under test are defined by the underlying API of Windows. For example, the AdjustWindowRect method calculates the window size required to obtain the target client area rectangle given a window style. The tester's operation behavior triggers the operation layer to obtain the object under test. The operation layer automatically analyzes and accurately calls a function of the Windows underlying API, and returns the properties and operation methods of the object under test. At the same time, the operation layer analyzes whether the underlying API function of the object under test has a service request behavior. If there is a service request behavior, the properties, operation methods, and request parameters of the object under test will be returned together; if there is only a non-service call operation, for example, the tester's effective operation on the client under test is to press the Back key, etc., and the operation layer only obtains the basic properties and operation methods of the object under test.
[0032] The second layer: the interpretation layer. The interpretation layer defines a toolset (TestTool), which is named the TestTool toolset in the present invention. The TestTool toolset has three core functions, namely: interception, analysis, and tampering. Function 1, interception: The TestTool toolset intercepts the operation behavior of the object under test (the behavior of the object under test can be click, slide, double-click, long press, etc. The present invention intercepts all behaviors of the object under test), and the intercepted message is temporarily stored in the TestTool toolset, and then triggers function 2. Function 2, analysis: The TestTool toolset parses and obtains the properties, operation methods, and request parameters of the object under test returned by the operation layer. There are many operation methods for the object under test (including but not limited to touchable, scrollable, longClickable, editalbe, etc., as mentioned above, such properties are defined by the underlying API of Windows). There are also many properties of the object under test, such as: name (text), coordinates (position), resolution (resolution), etc. The request parameters are not fixed. The TestTool toolset parses the data returned by the operation layer and automatically distinguishes whether there is a request when processing the behavior. Function 3, tampering. The tampering function is also completed by the TestTool toolset. The activation of the tampering function is only applicable to operations with requests. When the TestTool toolset parses that the object under test has a service request behavior, the tester chooses to tamper with the request or not. The returned data is also customized by the tester. The tester can customize the return value of the requested interface (the customization of the return value includes but is not limited to the data type and data size of the return value). The implementation of the tampering function allows the object under test to break away from its dependence on network services and customize the returned data, thereby achieving the MOCK test effect. The tampering function is not triggered for operations without requests.
[0033] The above tampering function is described in detail as follows:
[0034] After intercepting the client operation behavior, the TestTool toolset is controlled by the tester to determine whether to tamper with the return result of the service request behavior. There are two situations. The first is not to tamper with the return result corresponding to the request. The TestTool toolset does not tamper with the request. In this case, the return data defined in the interface document (the interface request type, parameters, and returned data (including the content and data type of the returned data) are all defined by the standard interface provided by the software developer). The second is to tamper with the return result corresponding to the request. The TestTool toolset can define the data and data type of the returned result, and the tester can customize the returned result. For example: the client requested the financial data of 600600.SH (Tsingtao Beer) for the last month. The tester will tamper with the requested financial data, modify the specific content of the financial data, and return the wrong data packet to the client. The specific amount of content to be modified is defined by the test case. This covers the scenarios that need to be tested. Finally, the client obtains the data packet returned by the TestTool toolset and renders the client page (as long as the returned data format complies with the provisions of the interface document, the client rendering must be normal. Of course, the wrong data format can also be returned, and the client cannot render normally. This is also a coverage test for abnormal situations in the test to ensure the fault tolerance of the client page). After the client renders the data, the tester can write the client's display results in the corresponding automated test case and use assertions for automated judgment, thereby achieving the mock automated test effect.
[0035] In the process of project development, the progress of front-end and back-end development is generally not equal. When the development of back-end services is slower than that of foreground development, after adopting the method provided by the present invention, the tester does not need to wait for the development and deployment of the back-end services to be successful, and can directly start the client UI automation test to ensure the stability of the client front-end page. Moreover, the test method provided by the present invention does not need to insert the test pile code during the development process, and can directly intercept and implement the simulation service with the TestTool tool set to verify the display of the client UI interface.
Claims
1. An automated testing method based on Windows underlying API without a service network, which implements client UI automated testing based on Windows underlying API in a serviceless network environment. It is characterized in that The following steps are involved: Step 1: Define the objects to be tested in the operation layer, each of which has properties and operation methods defined by the Windows underlying API function; A TestTool tool set is defined in the interpretation layer. The TestTool tool set has at least an interception function, a parsing function, and a tampering function; Step 2: The tester performs effective operations on the client under test, and the tester's operation behavior triggers the operation layer to obtain the object under test; Step 3: The operation layer automatically analyzes and calls the Windows underlying API function related to the object under test obtained in step 2; Step 4: The operation layer parses the underlying API function obtained in step 3 to determine whether there is a service request behavior. If so, the attributes, operation methods and request parameters of the current object under test are fed back as an operation behavior message. If not, the attributes and operation methods of the current object under test are fed back as an operation behavior message. Step 5: The TestTool toolset intercepts the operation behavior message of the current object under test fed back by the operation layer based on the interception function. After the operation behavior message is intercepted by the TestTool toolset, the parsing function of the TestTool toolset is triggered; Step 6, the TestTool toolset parses the operation behavior message and determines whether there is a service request behavior. If there is a service request behavior, the tampering function of the TestTool toolset is triggered and the process goes to step 7. If there is no service request behavior, the process goes to step 10 after generating a return result based on the intercepted operation behavior message. Step 7: The tester chooses to tamper with the service request or not. If the tester chooses to tamper with the service request, the process proceeds to step 8. If the tester chooses not to tamper with the service request, the process proceeds to step 9. Step 8: Define return data for different service requests in the interface document, obtain corresponding return data from the interface document according to the current request parameters, use the return data as the return result, and proceed to step 10; Step 9: Define return data for different service requests in the interface document. After obtaining the corresponding return data from the interface document according to the current request parameters, the tester tampers with the return data, modifies the specific content of the return data, and uses the modified return data as the return result, and proceeds to step 10; Step 10. The TestTool toolset feeds back the returned results to the client under test. The client renders the data based on the returned results to form the display results. Then the tester writes the display results in the corresponding automated test cases and uses assertions for automated judgment, thereby achieving the MOCK automated testing effect.
2. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that The measured object is a standardized control or a non-standardized control.
3. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that In step 5, the intercepted operation behavior message is temporarily stored in the TestTool tool set.
4. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that In step 6, if the operation behavior message includes the request parameter, there is a service request behavior, otherwise, there is no service request behavior.
5. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that In step 9, the modified returned data is correct data or erroneous data.
6. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that In step 9, the test case defines the specific modification content of the returned data.
7. The automated testing method based on Windows underlying API without service network as claimed in claim 1, It is characterized in that The specific data and data type of the returned result are defined by the tester through the TestTool toolset.
