Why Do We Need Framework for Test Automation?

Today we bring you an interesting topic “Test Automation Framework” and “Why do we need framework for test automation?”

The simple answer: For the same reason, we carry a map when commuting and we draw a blueprint before building a house.

Not convinced?

Let us try to find the answer to why test automation framework– through thorough deliberation.

Automation is tricky- not just technically but also economically. It is best suited for areas where there is a substantial amount of tests that have to be repeated across multiple test cycles. And always, automation testing happens in addition to manual testing or complements it- but cannot, does not and should not replace it altogether.

why test automation framework

Now, we testers know that the success of any testing endeavor- manual or automation– depends mainly on thorough planning. Typically, we are to spend 1/3 of the entire testing effort on planning- it’s the standard. This planning usually involves 2 main areas- managerial information like dates, schedules, milestones, people information etc., and technical testing related information on – Deliverables, how many cycles, tools, data etc. For an automation project, a framework is everything- a technical implementation guideline, as well as the managerial part of it.

The three technical entities (resources) in an automation project are roughly:

  1. Code- script
  2. Data
  3. Objects and their definition on the AUT

The economical (expenditure-wise in addition to the manual testing team’s presence) ones are:

  1. Tool – licensing. This might also include licenses for additional Add-ins required for the specific AUT on hand
  2. Specialized man power
  3. Time- effort in terms of man hours
  4. Infrastructure (could be anything, starting from the physical space you provide for an automation tester to work from.)
  5. Test Management tool if using any

In an industry where it is tough to get the buy-in for testing itself (although this has come a long way from where it used to be), it is going to be exceedingly difficult to prove the importance of automation, unless a sure result can be promised. In other words, we better figure out all the details and assure success or not venture into automation at all. This is where a solid framework can be the foundation that we need to set foot on solid ground and make sure that we don’t fall.

We are not going to go into the economic aspects in depth, because we get it. There is an X amount of money put in and we need to make sure that it stays a successful investment.

Why Test Automation Framework?

Let’s try to understand the technical part better:

We all know that, a good automation script should launch the AUT, supply the data, perform the operation, iterate/repeat itself as directed, validate and close the AUT, report results and finally, exit. Yes, it is a tall order!

Once we create a script that does all this, it reduces the execution and reporting time (especially if linked to a test management tool) to a few milliseconds as opposed to minutes or even hours. There is no overlooking or a typographic error etc., and overall efficiency is improved.

However, imagine how long it will take to write a perfect script that does it all. How long would it take to understand the test objective, come up with a solution, implement it in code, customize, debug and finalize?

------------

As you see, the real time consuming factor is the test script creation. The more efficient and time-effective the automation scripts- the better the chances of success.

An example here:

1) Gmail.com page is the AUT.

2) Features to test:

  • Compose email
  • Create contacts
  • Receiving an email

3) Automation testers- assuming each one is working on one feature

Yes, this is a little bit of an over simplified example. But, personally I feel that there is no concept on earth that cannot be broken down into easy-to-understand pieces. After all, the earth itself is made of tiny atoms.

Now, roughly, the scripts should have code that performs the operations as below:

  1. Compose email : Gmail.com launch->Login authorization->Compose email->Write the contents, add attachments(email parameters)->Send email->Logout
  2. Create contacts: Gmail.com launch->Login authorization->Select contacts->Create contact->Save->logout
  3. Receive email: Gmail.com launch->login authorization->check email->read email-> logout

All the above scripts have to be tested for multiple users with multiple parameters in each operation.

It is clear from the above representation that the following components are recurring/ repeating:

  1. Gmail.com launch
  2. Login authorization
  3. logout

We can significantly reduce effort and time, if we create these components only once and make them available for all the other tests to use as needed – Reusability – create once, debug once, finalize once and reuse many times.

Reusability also makes sure that if a change has to be made, it can be done in a centralized way.

For example, if the gmail.com home page changes (the first component in every script) – we don’t have to modify each script (3 times in our case). We can simply change it once (in the reusable component) and all the others scripts that use it will automatically use the centrally changed code. This reduces rework and makes sure that changes are consistent over all.

Also, automation scripts recognize the elements on the AUT based on the definitions/properties they store of them. This is yet another major asset for an automation script. If many scripts are accessing the same object, there is no need to duplicate it every time. A common repository with definitions of the objects can help centralize several small local repositories- again, a huge plus for efficiency.

To summarize – the resources Code and Objects can be optimized by maximum reusability. When components are to be made reusable:

a) A correct order has to be followed in creating them (because if we write the code for login last, all the other scripts that need that step can’t be validated in full- same rationale applies to objects as well)

b) An identifiable (readable, with-in context) name has to be assigned

c) Stored in a location that is accessible and/or available for all the other scripts.

All this information about – What, where, how and when to implement these factors- is part of a framework.

Finally, the data. You have an option to hard code your data into the code/script- which will force you to create a new script every time a new data has to be supplied. The solution – separate the data from the code. Reuse the code to the maximum and provide the data separately. Again, where will you find the details on how to implement this decision? Framework.

Framework plays a major role in determining how to organize your automation project in order to maximize results. Apart from the above discussed areas, Framework can also guide the automation testers on how to execute scripts, where to store results, how to present them, etc.

In short, test automation framework is your overall game plan and it can take you where you want to go. So, don’t find yourself without it.

About the author: This article is written by STH team member Swati S.

I hope this article demystified automation framework for you all. Please let me know your comments and questions on this topic below.

Recommended reading

19 comments ↓

#1 Ankur

Framework is a vehicle to carry out test automation. without it hardly any automation project will succeed.

#2 gurpreet

thanks for info

#3 shireesha

There are less chances of mistakes and your work would be structured with reusability if you have a good framework

#4 NARAYAN

GOOD JOB SWATHI ON AUTOMATION FRAMEWORK , WHY DONT YOU EXPLAN WHAT FEATURES NEED TO BE AUTOMATED AND WHAT FEATURES NOT TO AUTOMATED IN ORDER TO SUCCESS PROJECT.

#5 Lien

Thank you for the info. I am learning about automation testing and has a question:

How many approaches to test automation? What are they? Advantages and Disadvantages of each method?
Which automation tool do they are applying for?

Could you please help me to answer it?

#6 amit sharma

@ Swati
hi swati can u tell me more about automation framework, why this is important and what are tools and technology used to make the framework.

#7 nakul

Nicely explained

#8 Swati Seela

@narayan: I believe that any thing that can be built into a software can be tested via automation. However, that is not the real question most of the time. It is about how often you would need that test. Otherwise, the effort is going to be one time and there will not be any real benefit.

#9 Swati Seela

@Lien:

There are many frameworks available. The following links might help answer all your questions:
http://www.softwaretestinghelp.com/qtp-tutorial-17-test-automation-frameworks/

http://www.softwaretestinghelp.com/qtp-tutorial-18-data-driven-and-hybrid-frameworks/

#10 Swati Seela

@amit sharma: For more information on frameworks, check out:
http://www.softwaretestinghelp.com/qtp-tutorial-17-test-automation-frameworks/

http://www.softwaretestinghelp.com/qtp-tutorial-18-data-driven-and-hybrid-frameworks/

However, to create a framework you will not need any tool. All you need is a plan and a way to record it.

I hope that helps!

#11 Amit Sharma

@Swati,
Thanks to helping me it is very helpful for us but i confused in some topic.
can you tell me what is the difference b/w a framework and test plan.
you use a keyword ‘way to record it’ can u explain in detail.

#12 laxmisayi

I need some help in peoplesoft testing.

can any one please help me

Thanks

#13 ramya

I fed up with ur online class. I paid the money but after two days of class I cant login into goto training session. The following message is displaying “The organizer has canceled your registration, so you cannot join this training session. Please contact the organizer with any questions.”

#14 ankit

if any one want to love automation for free mail me ankitramola73@gmail
selenium

#15 ankit

if any one want to learn automation for free mail me ankitramola73@gmail

#16 Luasg

Thank for the article.

#17 yamini

Hi

Can you please explain what is a framework and why it is needed in testing and is it using generic java programs in Eclipse?? Please provide an example as to how to write or code frameworks using Eclipse. Is any particular tool required for frameworks?? Thanks in advance!!!

#18 Eshan Sarpotdar

Hi Swati, very informative post there. Yes, its all about scripts and how it plays a key role in test automation.

#19 Shruthi

Very informative…. i had literally struggled to understand what framework means… and this article made it so easy to understand… thank you so much…

Leave a Comment