Lightweight UI Testing Automation developed with. NET

Source: Internet
Author: User
Tags reflection
James McCaffrey
Download the code in this article: TestRun0501.exe (0000kb)
Content on this page
Application to be tested
Test automation script
Operate the application to be tested
Check application status
Discussion
Manual user interface testing is the most basic software testing type. Most software engineers use this type for the first time. In conflict with this, automated user interface testing may be one of the most technically challenging test types written. The Microsoft & reg;. NET environment provides you with many automated methods for writing automated user interface tests. A common and useful method is to record the keys, move the mouse, and click, and then play back in the application to ensure that it is executed as expected. (For details about this method, see the Bugslayer column of John Robbins in MSDN & reg; Magazine March 2002. This issue of the MSDN Magazine's Paul DiLascia column also explains how to use. NET to send this type of input to another application .) In this month's column, I will explore another way to compile Lightweight UI testing automation for. NET applications.
The best way is to start with a screen snapshot. Figure 1 shows that I have a virtual application to be tested. It is a color synthesizer application that allows users to type a color in the text box control, and then type or select a color in Combobox. Click the button to display a message in Listbox, indicates the result of the two colors "mixed. In Figure 1, red and blue generate purple based on the application. UI testing automation is a console application that starts a form to be tested, simulates a user's mobile application form, defines and adjusts the size of the application form, and sets the value of the text box and Combobox control, click the button control. Test automation checks the Result status of the test application, verifies that the Listbox control contains the correct message, and records the "pass" result. The screen snapshot in Figure 1 is captured before the Test Automation simulation user clicks close test application File | Exit.
Figure 1 automated form UI testing
In the following sections, I will briefly introduce the virtual applications I have tested and explain how to use reflection and System. windows. forms. the Application class starts the Application form in the test automation program and introduces how to use System. the methods in the Reflection namespace simulate user operations and check the application status, and describe how to expand and modify the test system to meet your needs. I think that no matter what role you play in the software production environment, the ability to quickly write Lightweight UI testing automation can greatly improve your skills. In addition, even if you are using an existing framework (such as Nunit), these same technologies can be integrated into your own unit test management and related.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.