Part 1bdetailed tests, keywords and showed that the Test Editor is essentially a GUI for a file structure. To create keywords to be used in Test Editor, simply create a keyword file and put it in the keywords folder. When loaded Test Editor will load all keywords it finds at the specified path. We learnt the structure of Tests objects, how they are stored and how they are loaded into to the test grid. Now, I would like to digress with some theory.
If you are not interested in test automation project management and are only interested in doing the practical steps in this series, then please continue to the next post. This post is aimed at new test automation projects, or QA developers new to test automation. However, if you can add anything then please don’t hesitate.
If you’ve spent any time reading up on test automation, either in books or on the internet, you will have seen the phrase,
“proper test automation is NOT record-playback. data-driven test frameworks are the way to go!”
Very true, but why exactly? Record-playback produces brittle tests, yes, but i doubt any failed record-playback test project carried out any sort of upfront analysis before recording a single test. I believe that this is the main reason why any test automation project may fail. A test automation project has to be managed correctly. Progress should be transparent and the test automation team should be just as accountable as any other team in the software development lifecycle.
Here’s a high level list of the minimum activities that I believe should be undertaken in any TRADITIONAL test automation project,
- Create test automation project plan – High level
- Identify the scope of test automation
- Identify business processes
- Create keyword files
- Update project plan
- Develop business process functions & utility functions
- Create tests
- Execute tests
- Review results
- test framework, test maintenance
An agile test automation effort is unlikely to follow the above. It is more likely that in an agile team, a QA Developer will work closely with the testers to help identify areas where test automation can gain quick wins using any method that is, easily available, quick to implement and as cheap as possible. The test automation efforts are done in short repeatable bursts. Also, a lot of agile test automation efforts relate to low-level testing like TDD, automated unit / integration tests and tests that will be integrated into Continuous Integration(CI). The traditional test automation project usually targets integration / regression cycles. In any type of project CI and running tests after a nightly build should be a top priority.
The activities may overlap. The degree of overlap is proportional to the size of the team. For a 1 person team, there may be no overlap. As the team increases in size, it may be that activities are staggered; Business process functions may be developed whilst keyword files are still being created. You may also decide to repeat the above steps for each business process area one at a time, or simultaneously, if you have the resource.
1. Create Test Automation Project Plan
What we want to do here is breakdown the areas of functionality in your target application. These are your business process areas. Next, for each business area we want to identify suitable tests to be automated. This can be achieved using any or all of the following,
- Analysing a set of manual tests
- Analysing requirements specification documents
- Analysing the target application
- Being proactive and talking to BAs and manual testers
Once we have a list of tests for each business process area, we need to evaluate each tests automation suitability. You’re looking to automate tests that are repetitive, reusable and target core functionality. These 3 things alone can help you prioritise the order of test creation. Actually, this same process can be applied to prioritising keyword creation. Think of rating each test / keyword / business process area out of ten for each category (Let’s call this a PRIORITY INDEX),
| Keyword | Repetitive | Repeatable | Core | Total |
| Fight_Login | 10 | 10 | 10 | 30 |
| Flight_FaxOrder | 2 | 8 | 4 | 14 |
| Flight_AddOrder | 8 | 9 | 10 | 27 |
You get the idea. We do Login first. The general theme I adhere to when performing analysis is to break everything down into their smallest component parts. This helps especially with complex applications that I may not initially understand.
Tests that may not be suitable for test automation may include tests that are not performed very often, hard to maintain and/or very complex. Let automated tests do the boring, easy, repetitive stuff and leave the interesting stuff for the manual testers. 100% test automation coverage sounds cool, but breath easy manual testers. You will never be replaced.
So your initial project plan should contain level 1 estimates for work to be carried out. As you can see above the plan may take days to do, or even weeks. Spend time here. Your project needs to start on a solid footing. Before you go near any test tool you should be very clear on what it is you and your team will be working towards. Working towards, because you will be working to a plan that you can track, update and broadcast progress of.
Doing this analysis will also highlight how work may be divided up when it comes to delegating work to test automation team members.
Questions you might like to ask at this point,
- Does the project have CI in place? If not get the ball rolling to get it in place.
- Your assets need to be stored in source control. Do you have access? if not, get it.
- Ask your developers about including your tests in a nightly build script
- Do you have access to a test lab to execute your tests? If not request the required hardware, VMware now as it may take some time to organise.
- Do you have access to Defect Management software? if not get your project set up in your companies tool of choice.
- Do you have the required licences for any test management / tool software that you have chosen?
2. Create Keyword Files
By the time you get to this stage you should have a decent plan that lists all required keywords. Each keyword required should come with the required parameters it needs to perform it’s function. These parameters can be changed in this phase, but remember to update the plan.
A keyword file for the flight application login keyword may look like this,
<?xml version="1.0"?>
<Keyword>
<Name>Flight_LO_Login</Name>
<Description>Logs into QTP sample flight application</Description>
<ReturnValue>None</ReturnValue>
<Category>Flight</Category>
<Param>
<name>Username</name>
<description>Username</description>
<type>String</type>
<defaultValues>admin</defaultValues>
</Param>
<Param>
<name>Password</name>
<description>Firstname</description>
<type>String</type>
<defaultValues>MERCURY</defaultValues>
</Param>
</Keyword>
We haven’t touched on the QTP side of things yet. Look at the Name of this keyword; Flight_LO_Login. What’s going on? The naming conventions for keywords and tests is something you need to consider. In this example, I’ll break down this naming convention,
Flight_LO_Login
| Flight |
Target Application Identifier (maps to target application assets location) |
| LO |
Object Repository Identifier (object repositories may be loaded dynamically |
| Login |
VBScript Identifier (Uses whole name to work out location) |
So when this Keyword is encountered by the QTP driver script it knows what assets to load and what to execute by parsing the keyword name.
There are numerous approaches to naming conventions. This is just the one I’ve chosen for this project.
3. Update Project Plan
By rights you should already have updated the plan by the time you get to this step. When you initially created the plan you may have included estimates for how long this work will take. You should always keep an eye on the accuracy of your estimates. You started creating keywords in order of priority and after creating say ten, you will have some actual times to compare against your estimates. maybe you were able to create keyword files quicker than expected or maybe the initial parameters you gave to some keywords needed more analysis and so you took longer. if it took you longer then adjust your plan. This may be adjusting estimates, extending milestones or adding extra resource.
4. Develop Business Process Functions & Utility functions
Right, lets get coding!
You will now have in front of you a list of keywords that require implementing. Remember,
Keyword = Business Process Function = A specific action that applies to your target applications functionality
These keywords will have been prioritised using any method you choose, or using the priority index I showed above. The repeatable rating is useful in that if we do more of those early on then this will give us early quick wins. Some people say that test automation can be a huge upfront effort and takes a long time before you start to see any ROI. Well, if you prioritise correctly then you can start to see results with as little as 10% coverage. Do the easy, repeatable BPFs first.
You will find that your BPFs may rely heavily on utility functions. It is likely that as you start to create BPFs you will require a piece of functionality that helps your BPF do its job. Think of utility functions as private methods and your BPF as the public method. You will require navigation utilities, error handling, reporting, formatting, logic utilities. These need to be created either upfront in a prioritised way, or in tandem with creating BPFs. Whichever suits you best. Probably the most important utilities will be the data utilities. These utilities will fetch the lists that you would like to reference in your keyword parameters (see previous post).
5. Create Tests
At this point you have created keyword files and the corresponding VBScript to execute when the keyword is parsed by the driver script. The keyword files have been stored in the keywords repository known by Test Editor and so are available to be used during test creation. You have a prioritised list of tests to create. If possible, start by trying to create a set of tests that may be used as a sanity pack (smoke tests); a small set of tests that touch the core parts of your target application. Once you have this you can start executing it after builds. The beginning of your ROI.
6. Execute Tests
The exciting bit!
At this stage you might start becoming familiar with the quirks of your target application. Problems with tests not doing what they are supposed to, may cause you to do quite a bit of investigation and perhaps identifying issues with BPFs or identifying new utility functions that may be required. Or, your tests will run beautifully and you will be filled with a warm glow.
7. Review Results
Check failures to see if defects are as a result of the target application or your tests. If they are a real defect then raise a bug. When you log your bug note the automated test that should be executed when the bug is fixed. If you can automate the process of executing automated tests when a bug is fixed, then even better.
After a while managers may (will!) start becoming interested in metrics. So be prepared to write utilities to extract information they require, if metrics is something that cannot be easily extracted from your test management or defect management software.
8. test framework, test maintenance
You will always find ways of enhancing your test automation framework. Create a backlog and prioritise work accordingly.
Test maintenance is a funny one to me. Maybe I’ve been lucky or maybe, just maybe, it’s because I invest a reasonable amount of time in carrying out thorough analysis upfront that results in me not having to spend a lot of time performing test maintenance. I read a lot about people saying that test maintenance is extremely labour intensive and I can see why. Tests may be brittle due to too much static data, references to hard-coded data that is dynamic, keywords not aligned with business process etc.
Ideally, if you are using your automated tests for regression tests, they should not change. Ensure your tests are version controlled.
Ok that’s a very high level view on some of the things I think may be beneficial when getting involved in a software test automation effort. It doesn’t list all techniques, but may point you in what I think is the right direction.
Next we’ll start looking at the test tool side of things.
Create Test Automation Framework – Part 1b