views:

462

answers:

3

I would like to know how test automation tools like winrunner, QTP etc work. Whether these tool use any test API provided by windows or they depened on IPC and events. I could not figure out how they work. For me QTP record and play feature seems to be a magic.Any guidance will be highly appreciated?

A: 

Hi,

I dont know much about QTP. But if you wanted to know the internals then you can download the open source projects like Watin- for dotnet and Watir- for ruby and see whats happening inside. Both are used for web test automation. And the code is freely available..

If you are looking for Unit testing frameworks like Nunit. they are attribute driven.. Nunit identifies the classes by "TestFixtures" and methods by "Test" attributes. It scans the entire application for these test methods and trigger the tests.

Cheers

Ramesh Vel

Ramesh Vel
Hi, I am not looking for unit testing frameworks. I am interested in knowing how to write applications like QTP. Essentially I want to know how QTP record your actions in a windows applications or web applications and replay them. Writing these applications is like writing debuggeres. I also want to know whether windows provides any API to know the control in a window of other applications. Sorry for the confusion.
raj
A: 

I guess they're using Win32 Hooks.

edit: here is an example of defining hooks in .NET.

pascal
A: 

Actually WatiN is not bad place to start. It is not exactly unit testing framework. It may look like one at firs sight but it is used to write functional test. It is totally up to you if you run them like unit tests. I was writing the same test using WatiN in two ways (functional test that was simulating user actions on the web page):

1) Writing script in Powershell at running from command line like any other PS script. It was fun, although you need to write lots of code for reporting, exception handling, and other.
2) Writing unit test in MSVS in C# using C# Unit Test from MSVS project type. This actually was fun because you would just run it in MSVS like unit test but you have environment support for code writing, reporting, running etc.

So if you want to start with something take a look at WatiN, especially as WatiN has dedicated recorder that records actions and outputs code in C#. Looking at internals of library and tool would give you some start.

Just one thing to mention - it is web only. Desktop is totally different. With web you have hook into IE you can query html document for objects, checking browser state and so. With desktop it may be more difficult. You need to hook into application, maybe via mentioned Win32hooks. Maybe try with Microsoft Scripting Host.

yoosiba