A GUI automated testing framework scheme

At present, in GUI automated testing, many software systems use record playback technology. This technique requires the tester to work through the click of the mouse and keyboard, the script records the event, and then replays it in an automated test. The recorded test scripts must be edited and debugged and inserted into verification and checkpoints. The generated script is usually hard-coded and requires testers to edit and parameterize the script. At the same time, any changes in the attributes of interface elements will affect the operation of the script, and sometimes even need to re-record the script.

1 .NET reflection mechanism

Generally, application programs (including desktop programs and Web applications) are composed of some basic interface controls. All software instructions are passed to the background processing in the form of events or messages through the controls. The essence of GUI automated testing is to provide programming means for the control elements in the GUI [2]. In the automated test tool based on GUI object recognition and control, it has been dependent on the call of Windows API function in the past. With the emergence of new programming languages ​​and platforms, many new language features have emerged. These language features can be used in the design of automated test tools. For example, the reflection mechanism is one of the technologies.

Reflection (ReflecTIon) is an important mechanism in .NET. Through reflection, you can obtain members of each type (including classes, structures, delegates, interfaces, and enumerations) in .NET at runtime, including methods, properties, events, and construction Functions, etc., you can also get the name, qualifier and parameters of each member. If you get the information of the constructor, you can directly create the object, even if the type of this object is not known at compile time. Assemblies contain modules, and modules contain types, which in turn contain members. Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object or obtain a type from an existing object, and then call the method of the type or access its fields and properties [3].

2 Overall design of the frame

The construction of the automated testing framework basically accounts for 40% of the entire automated testing workload and is an important part of the automated testing implementation. The software automation framework is essentially a collection of strategy ideas, specification files and code. This paper proposes an improved lightweight GUI automation testing framework, which can help users avoid the defects of current testing tools. The framework will have the following five characteristics: automatic search for GUI controls, automatic generation and execution of test scripts, data-driven principles, automatic verification of tests, and development using programming languages. The overall design of the frame is shown in Figure 1. As can be seen from Figure 1, the framework frees the tester from the heavy recording work and concentrates more time and energy on the design of test cases.

3 Specific development of the framework

3.1 Load the program under test

In order to test the GUI application, it is necessary to run the program under test in the test tool to make the two programs interact. Use Assembly to define and load the assembly, load the modules listed in the assembly list, and find the type from this assembly to create an instance of that type. In order for these two applications to interact, they must be implemented through a multi-threaded mechanism. The following is the core code for loading the program under test through reflection [4]:

Assembly asm = Assembly.LoadFrom (path);

Type t1 = asm.GetType (formName);

testForm = (Form) asmCreateInstance (t1.FullName);

ParameterizedThreadStart pt = new ParameterizedThreadStart (AppRun);

Thread thread = new Thread (pt);

thread.Start (testForm);

private void AppRun (Form theForm)

{

ApplicaTIon.Run (theForm);

}

speaker driver used in the helmet,Helmet Speaker,40Mm Helmet Speaker,32Ohm Helmet Speaker,Motorcycle Helmet Speaker

Helmet Speaker

Helmet Speaker,40Mm Helmet Speaker,32Ohm Helmet Speaker,Motorcycle Helmet Speaker

Shenzhen Xuanda Electronics Co., Ltd. , https://www.xdecspeaker.com

This entry was posted in on