Secrets of SuperMap iDesktop Test Automation Technology
Software testing is the process of running or measuring a software system by manual or automatic ways to verify whether the software system meets the requirements. While some software testing tasks, such as extensive low-level interface regression testing, can be laborious and time-consuming to do manually. In addition, a manual approach might not always be effective in finding certain classes of defects. Test automation offers a possibility to perform these types of testing effectively. Therefore, to improve the efficiency and quality of testing, the application of automated testing is becoming more and more popular.
SuperMap iDesktop, as a desktop GIS software, pays more attention to user interaction experience, which makes user interface (UI) interaction testing particularly important. At the same time, iDesktop has provided more than 1500 functional entries, which cannot be given adequately feedback of current quality situation only by manual testing. Therefore, UI interactive automated testing has become a necessary ways of daily software quality monitoring.
Introduction to UI Test Automation Process
According to the hierarchical automated testing theory, the output ratio of UI automated testing is considered to be lower than that of unit testing and interface testing. Why does SuperMap iDesktop still pay so much attention to UI automated testing?
That is because no matter how complex or important the internal function code of SuperMap iDesktop is, the interface interaction and the results of processing are more important for end users.
Simply relying on unit testing and interface testing cannot fully prove the usefulness of functions delivered to users by SuperMap iDesktop. SuperMap iDesktop's interface interaction is relatively stable. UI automated testing can liberate testers from a large number of simple, mechanical, repetitive tasks and improve work efficiency.
The UI test automation of SuperMap iDesktop, through the simulation of the interaction between mouse and keyboard, truly restores the scene of users using desktop (as shown in the picture below): ① Open data →② Click to open functional interface →③ Set parameters →④ Execute function →⑤ Check results.
This is also a common testing process. Especially when a new version is going to be released, testers often need to repeat thousands of such testing processes manually to ensure the availability of all SuperMap iDesktop functions. After applying UI test automation, the tester's work has changed greatly, and all the details can be automatically completed by the test script. The focus of the tester's work has changed from manual execution of the testing process to judging whether there are problems in the testing process based on the results of automated testing. When the iDesktop passes the test, it is generally considered that the function involved in the test process is fine to be promoted; if it fails to pass the test, it is necessary to check whether there is any problem in iDesktop or in the test automation script.
In SuperMap iDesktop automated testing framework, how is the testing process specifically implemented? Taking "Open Data" as an example, the process is as follows: ① Simulate the mouse clicking on the "file" on Ribbon→② Simulate the keyboard input path string→③ Simulate the "open" in the mouse clicking dialog box→④ Automatically check whether the target data source is successfully opened.
Then, data are opened automatically. The implementation can be summarized as: three times to obtain screen coordinate points, three times to click on screen coordinate points, a keyboard input character.
After the the daily manual test content, a large number of automated test cases have been formed.
Secret of Key Points
In order to manage case handily, SuperMap iDesktop applies Nunit testing tool. Combining with the feature that the positions of SuperMap iDesktop's function tools on the screen are basically established, it seems that only “Nunit Management Cases + simulation of keyboard and mouse by Windows API” is needed to complete the construction of the automation framework. However, with the increase of the number of cases, only recording the positions in the screen to complete the entire automated testing process will cost a lot. Moreover, any position change may lead to frequent modification of the content of automation cases.
How to get the positions of the clicked screen flexibly and correctly through information such as function names so that SuperMap iDesktop can correspond to right functions?
Common UI automation testing tools work in the following ways: ①record scripts →②execute scripts→③ verify results automatically. However, as the constant development of interface technology, object often cannot be recognized during the recording process, and the recorded script needs to be modified twice according to the product situation, which requires higher development ability of tester. Test automation tools can also load the test program by reflection. They can directly acquire and set various control attributes of the tested program across threads. However, they are prone to thread interference, leading to crash and other problems. The test program loaded by reflection will run as a thread of the test process. It is unable to monitor the consumption of operating system resources by SuperMap iDesktop itself, sharing the resources of the main test process. In actual manual testing, SuperMap iDesktop runs by process, so test automation by thread is not reality of interaction.
So how to solve the stability problem while maintaining SuperMap iDesktop process independence? During the long-term practice, testers found that: by transmitting control information through cross-process Socket and combining with the secondary development characteristics of desktop products, the problems of "object unrecognizability" and " crash" can be effectively solved. At the same time, it maintains the independence of the process. And it can easily collect auxiliary information such as resource consumption during operation, test coverage (using OpenCover) and so on.
To sum up, a unique UI automation testing framework of SuperMap iDesktop is formed by: Nunit management testing process + Socket inter-process communication to obtain control information + Windows API to simulate keyboard and mouse operations.
Test Automation Framework Architecture
Here is the structure of test automation framework of SuperMap iDesktop:
1. Basic interaction layer: With the secondary development of SuperMap iDesktop, add a plug-in to receive messages in SuperMap iDesktop. The plug-in receives the control location request message sent by the test site through the Socket protocol, and then the plug-in obtains the control information from the SuperMap iDesktop and notifies the test site.
2. Desktop common UI operation encapsulation: On the basis of 1, a series of commonly used operations are encapsulated into a toolset for testers to use directly, such as opening data sources, opening maps, clicking on a specific control on Ribbon, clicking on a specific right-click menu item in the workspace, etc.
3. Test cases: According to the manual test content, using the existing resourses of 1 and 2 directly, the test content can be transformed into test cases, and managed by Nunit test tool.
At present, SuperMap iDesktop based on the above-mentioned test automation technology and means can be well integrated testing. It has been proved that SuperMap iDesktop test automation framework can provide quality assurance for SuperMap iDesktop, effectively saving both human and time resources and improving testing efficiency.
We are looking for distributors, resellers, and partners all over the world. For any inquiry, please contact us at: [email protected].