Red Gate forums :: View topic - Abstracting Test logic by inheriting VirtualClient
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
ANTS Load
ANTS Load forum

Abstracting Test logic by inheriting VirtualClient

Search in ANTS Load forum
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.
Jump to:  
Author Message
Ian1971



Joined: 01 Oct 2004
Posts: 33

PostPosted: Tue Oct 05, 2004 4:30 pm    Post subject: Abstracting Test logic by inheriting VirtualClient Reply with quote

I just wanted to share with people a method I have found which enables me to abstract my test logic into a seperate class that can be inherited by my various browserClient classes.
I'm sure people are already doing this but it took me a short while to get working so if its going to save anyone else some time, here is what I did.
I created a new class which is called VirtualClient (if you don't call it this it doesn't work). this class inherits from Control.VirtualClient (just like normal browserClients do).
I can then create in this class all my various test functions, such as LogIn, LogOut, AddProduct etc.
I can then create my browserClient1 class, which inherits from my new VirtualClient class (instead of Control.VirtualClient as they normally do)
Now, within the browserClient1 class I can call all my test functions (as well as access all the normal VirtualClient objects).

This makes it much easier for me to work as I am not duplicating code in each browserClient class and it is much easier to read and maintain.

Cheers
Ian
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6646

PostPosted: Tue May 17, 2005 10:27 pm    Post subject: Reply with quote

Hi Ian,

That's the recommended approach. The only drawback is that your limited to one class full of functions that you can use from the load test script. Good enough, though!
Back to top
View user's profile Send private message
Ian1971



Joined: 01 Oct 2004
Posts: 33

PostPosted: Wed May 18, 2005 12:51 pm    Post subject: Reply with quote

I've extended this further into what I think now works quite well for me. The problems I kept running into was that the load test scripts were quite brittle (i.e. basically required extensive rewriting when a page changed). What I set out to do (and what I hope I've achieved) is a way of more simply updating my scripts.
Its a bit hard to explain briefly but what I have basically ended up with is a WebForm base class that is inherited and extended by specific types of web form in my application e.g. ProductWebForm. I then also have a tester base (which has to be called VirtualClient) which contains all my utility and debugging functions. This is inherited by my actual test classes e.g. ProductTester which contains the actual test logic and these classes call my various webform classes passing in themselves as VirtualClient objects.
The good thing now is that when for instance my Product page changes I only need to alter my ProductWebForm class rather than make changes in every class that was calling the product page.
I have also managed to get it working outside of the ANTS load shell, but still using the ANTS objects (by passing in a WebClient object) which means I can debug the whole thing in the visual studio IDE and step through the script code. As a nice side effect this also means I can use sourcesafe better with my test scripts. When it comes to do the actual load testing I just copy each class into the ANTS load project and I am away.

My wish list for ANTS would definately include making it more easily extendible and easier to debug. I have finally arrived at something I am happy with but I think if the object model had been created and documented with the thought that people could extend it then I would have saved a lot of time experimenting.
My ultimate tool would go further. It would have ASP.NET specific functionality allowing it to interact with the web application in a similar way to NUnitAsp but with load testing functionality. I think this would make writing scripts a lot easier and also make the scripts a lot simpler to change when controls change on the page.

Anyway, enough rambling
Cheers
Ian
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies. All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group