Login   /   Register

Writing QTP tests in Visual Studio

Rate this article
     1 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 51 votes, average: 5 out of 5
Loading ... Loading ...
February 7th, 2009 by Yaron Assa

Google Search Results

You arrived here after searching for the following phrases:

Click a phrase to jump to the first occurrence, or return to the search results.

Background

It’s no secret I’m not a fan of QTP’s code-editor - it lacks intellisense, meaningful autocomplete, code folding, and many other “Must” features; And while QTP 10 will improve the situation, the IDE’s core problems will remain. In addition to the IDE’s shortcomings, QTP’s reliance on VBScript cripples it in many key areas such as object-oriented programming (tests, actions and GUI classes could inherit from one-another), debugging capabilities (ever wanted to skip a few lines while debugging), threading, live monitoring, error handling, and much more.

After a few years of passively complaining about these problems, I’ve decided to act, and see if I could somehow write my QTP tests in Visual Studio .Net. If I managed to pull that off, I would solve both the IDE problems (Visual Studio provides a wonderful – though not perfect - IDE, even in its free Express versions), as well as the deeper programming problems (.Net languages are fully fledged object-oriented language, with rich error handling, debugging, and other cool features).

In addition to these obvious benefits, additional perks await in Visual Studio. For example, hiding the automation code from snoopy clients (you could just compile the entire test into an executable form); built it .net extendibility, and more.

There are significant downsides as well (which may make the whole operation not worth your while) – adding another layer of code always causes problems and complexities; you cannot do this via QC; QTP’s automation agent randomly goes crazy and hangs the entire system, you’ll have to learn complex code techniques in order to take advantage of the inherent benifits in .Net; etc.

Having said that, I think it’s an idea worth exploring, even if only as an interesting adventure.

The content you are accessing is for registered users only
Registeration is FREE, quick and private.
You can either Register or Login if you have already registered

From a proof of concept to a viable framework

While all this is fine as a proof of concept, the technique fails miserably as a general framework – it requires a separate variable slot for each GUI object, has no error handling for launching QTP (what if there’s an unsaved opened test?), has no methods for reaching child objects or expressing object hierarchies, and is generally inadequate for serious use.

As I’ve mentioned earlier, it is possible to build a more robust and sophisticated bridge that will provide cover all these issues and more. This was just meant as a simple, straightforward proof of concept.

On a personal note – I’ve been working with a fully fledged bridge for several weeks, and have been written some of my tests in Visual Studio, and the results are spectacular. If you have the necessary programming skills, I recommend the experience, even if only to open your mind to greater possibilities. Are you ready to step through the looking-glass?

Enjoy.

Posted in QTP Hacks, Yaron Assa's Blog

22 Responses to “Writing QTP tests in Visual Studio”

  1. barak3d Says:

    [-]

    Very cool! hope to see more examples about this in the future :)

  2. snigdha_123 Says:

    [+]

    Useful one. http://funandknowledge.blogspot.com/2009/01/to-retrieve-column-names-from-database.html http://sqlqueriescollect... ...

  3. BoydPatterson Says:

    [+]

    Fortunately for those who do not want the complexities of building a bridge between Visual Studio and QTP, there is still Test Des... ...

  4. Yaron Assa Says:

    [+]

    I would like to support what Boyd Patterson has said. TDS is an amazing IDE for QTP and Winrunner, which provides ample features, ... ...

  5. Meir Bar-Tal Says:

    [-]

    And for those who can’t afford purchasing VS or TDS, there’s the open source SharpDevelop.

  6. swiontle Says:

    [+]

    Yaron, your very last paragraph says that you have developed in VS "a fully fledged bridge" and "have been written some of my test... ...

  7. sachxn Says:

    [-]

    Yaron:

    Very interesting..this really gives respite from the daily mundane tasks…..

  8. Yaron Assa Says:

    [+]

    swiontle - Right now my code is implemented in a proprietary project, so I can't share it. If you have some focused questions I'l... ...

  9. swiontle Says:

    [-]

    Thanks so much Yaron! Appreciate it!

  10. zfisherdrums Says:

    [+]

    Good idea. I've all but abandoned QTP due to many of the shortcomings you noted, but continue to read your article because of the ... ...

  11. Yaron Assa Says:

    [-]

    Hey zfisherdrums,
    Can’t you use the obfuscater for that (render the code unreachable?).

  12. zfisherdrums Says:

    [+]

    Yes, that was my intent: obfuscation needs to be considered where security/intellectual property is a concern. But we cannot simpl... ...

  13. Yaron Assa Says:

    [-]

    OK zfisherdrums, Thanks a lot for the clarification!

  14. swiontle Says:

    [+]

    Hey everybody, since we are on this topic of using .NET to write automation tests, is there any tool out there that will let me do... ...

  15. fengxl Says:

    [-]

    看不懂

  16. jimmyjin Says:

    [+]

    Hello, Yaron, Very interested in this article, and I just had a try. I can achieve what you described in this article, but can't ... ...

  17. gaurang1309 Says:

    [+]

    This is awesome..!!!!! And this is what just in my back of mind, is it possible to make a bridge in between .net and qtp at any l... ...

  18. jkrohn Says:

    [+]

    Swiontle, Don't stress about the "testing" role stigma. As testers such as the ones in this forum prove automation to be a viable... ...

  19. swiontle Says:

    [+]

    jkrohn, thanks so much for the encouragement. They also have given me CM responsibilities on VSTS 2008. That's been a real chall... ...

  20. nagupva Says:

    [-]

    It is very good.

  21. daveSm Says:

    [-]

    Look like some one building the bridge already
    http://jqtp.blogspot.com/

  22. stack Says:

    [-]

    daveSm — I’ll believe it when I see it. :)

Leave a Reply

You must be logged in to post a comment.

This article was viewed 1370 times