Keyword-driven Automated Testing

May 16th, 2010 § 5 comments

Is it really possible for non-programmers to create automated tests?

Keyword-driven test design is a popular approach in testing teams in big corporations, where the skill levels of QA people are vastly different and most of them are not programmers. The problem of QA managers in such organizations who want to invest in test automation is how to best utilize their available resources. I think that now almost everyone realizes that capture and replay tools fail to create useful and reliable tests, so another approach is needed.

Keyword-driven frameworks rely on a library of small standalone reusable and parametrized building blocks, that represent simple and atomic actions of the application under test. Those are usually developed in a scripting language by the test automation developers. Then those building blocks (or keywords) can be used in some graphical or table-driven interface as reusable actions by testers to create automation without coding. In a way this is very similar to the action-word scripting approach that most automation tools provide (like QTP or the table view in the Selenium IDE).  The difference is that the keywords that the testing tools provide out of the box (usually things like 'click_button' and 'type' are both very generic (in the sense that they can be used in any application) and very narrow (in the sense that they do very small things like clicking a web button or typing text in a textbox). The successful keyword-driven approach requires keywords that are defined in the semantic level of the tested application (like for example 'login' or 'register_user').

Here is a quote from my favorite testing book
Lessons Learned in Software Testing: A Context-Driven Approach

“In contexts that require many nonprogrammers to create automated tests, we believe this is one of the better solutions One drawback of this approach is that you can't write a test unless supported keywords already exist for the tasks you require. Defining and implementing the task functions can become a major undertaking.”

You can build such a framework in-house, using for example excel tables to contain the test scripts with  the keywords and their parameters, or try to use the keyword capabilities of some of the commercial tools on the market (like the reusable actions in QTP). JSystem is an open source test automation framework oriented towards API testing that can also interface with Selenium for creating  keyword-driven UI tests.

While keyword-driven sounds wonderful, it is not a magical methodology that will solve all automation problems and cure world hunger.  I worked on a keyword-driven project while I was an employee of a big corporation. We had an elaborate in-house tool, that could compose the keywords into larger blocks of actions, which were also reusable in tests. The project was a failure. The library of keywords became so huge that no one could figure out which keyword should be used in which context. The tool did not have control flow mechanisms. You could not do loops or if-then-else constructs, which  meant only very simple straightforward test scenarios were possible. The tests were breaking too often and the maintenance effort was higher in my opinion, compared with traditional scripting automation (if done well).

I would like to hear from you about your experiences with keyword-driven automation.

New Selenium RC Release

February 24th, 2010 § no comments yet

Actually for the last two days there were two new releases of Selenium - 1.0.2 and 1.0.3 (released on the next day following 1.0.2 to fix some issues). The most important feature in the new release for me is Firefox 3.6 support. If you are a Mac fan you will be glad to know that OS X Snow Leopard is now supported too.

When it comes to  tools I use for work I usually prefer to wait a little before upgrading, so that any potential problems that might be there are discovered by other people and not by me (the quick release of 1.0.3 seems to confirm that this is actually a good idea). On the other hand my previous experience with upgrading test automation tools shows that I sometimes run into problems no one else has found.

So this time I decided to upgrade to 1.0.3 early and I will blog about my experience.

By the way, there is also a new official Selenium blog.

How do you test your web services?

December 12th, 2009 § 1 comment

Service oriented architecture is not something new or cool anymore. From enterprise software to web sites, software exposing its functionality via web services is becoming increasingly common.
The question is how to test those services. One option is to use a unit testing framework and create tests calling the services in any programming language you are familiar with (Java + Junit, C# + Nunit, etc). Whether such tests can be called unit, functional or even integration tests is not that important, but this approach is probably best suited for developers creating tests themselves. It is also not quite convenient for ad-hoc or exploratory testing.
A lot of commercial Java application servers such as SAP NetWeaver provide built-in web-based tools for browsing and testing the deployed services on the server. Using such tool is a good option for ad-hoc testing, because usually the services are readily accessible in it without any need for additional configuration. If you don't have access to something like this or if you need more flexibility, like maybe saving the test parameters and creating whole test suites, you might want to look at SoapUI. This is a tool for web service testing that has a free (open source) version and a commercial 'Pro' version with additional features. The most useful 'pro' feature for me is the form-based interface for entering the input parameters for the service call. SoapUI allows you to create whole scenarios consisting of services called in sequence and exchanging data between them. It even has some performance / load testing features.
SoapUI seems to be the most popular tool for web service testing, but it has its quirks and is not always as robust as I would like it to be.  I am curious if  anyone knows something better out there.

Failed Automation Projects

May 13th, 2009 § 2 comments

"Do not automate buggy software."

I was thinking about the failed automation projects I’ve been involved in during the last few years and I seem to find a pattern. All those projects were very, very buggy. I realize now that you should only aim to automate functionality which is fairly stable, so that you do not expect to see a test failure in more than about 1 of 10 test runs. If you see that your tests are failing 50% of the time, then automation is not the cure for your problems. Try to find out why this is happening in the first place.

 

HP’s Center of Excellence

April 22nd, 2009 § no comments yet

Centralization leads to mediocrity at best.

center

Today I went to a seminar, organized by HP to promote their offerings in the quality management area. What struck me most was the 'Center of Excellence' notion.  Basically the idea is that (big) organizations should centralize their quality-related activities into one unit (boldly named Center of Excellence), in order to reduce costs.  HP is willing to support you in this endeavor with software and consulting. They even came up with their own maturity model which ranks organizations on one of several levels - the lowest called for some reason 'Manual Testing' and the highest  of course being 'Center of Excellence'.

Somehow I don’t buy into this.  I realize that cost saving measures are in vogue now, but my experience shows that centralization leads to mediocrity at best, not excellence.

Lesson 114 – Test tools are buggy

April 9th, 2009 § no comments yet

"Testers get indignant when they realize that the quality tools purchased at a serious price are themselves full of bugs. Indeed, test tools are often buggier than comparable (but cheaper) development tools. Plan to test your tools and spend time finding workarounds for bugs."

The quote comes from one of the best books on software quality I have read - Lessons Learned in Software Testingby Cem Kaner, James Bach and Bret Pettichord.  Be sure to read it if you haven't already.
I can not agree more with the authors. I spend a lot of my time in test automation trying to find workarounds for issues with the tool. Some of those issues can be considered 'functional idiosyncrasies', but most are just plain and simple bugs. During my work in the field of software quality I have noticed that users are normally quite tolerant of bugs, unless the bugs block them from doing their jobs. So for me there are two kinds of bugs in the test tools - those you can find a workaround for and those you can not.
If the tool is flexible enough and you know how to use it, most of the time you can make it do what you want - like for example using keyboard shortcuts and the clipboard to read the text from an unsupported GUI control. This is one advantage of tools that offer the flexibility of a real programming language for scripting.
There are also such things, for which you can not do much except waiting for the vendor to provide you a fix, and this can take long time. A few years ago I tried to upgrade to the latest TestPartner version (it was 5.2.3 back then). After the upgrade I found that all my automated scripts were causing random crashes in Internet Explorer. I just stayed with the old version until 5.6 came out, where this problem was fixed.

Record/Playback Does Not Work…

March 16th, 2009 § 2 comments

Record/Playback does not work, but we all know this, don't we?


877158_old_tape

If you have ever had anything to do with UI test automation, you should know about recording.  It is an ability that most tools (commercial or open source) have - you start the recording session in the tool and then just happily click through the test scenario on the application you are testing.  Meanwhile the tool sits silently and records your actions, getting ready to replay them automatically when you want to. The ability to record the UI interactions is a marketing highlight for most automation tools. There are even some tools, where recording is the only way you can create test scripts.

On the surface it can really look like the best way to automate - you will be testing manually anyway,  so why don't just record your tests to replay them at a later stage? Unfortunately the view that test automation is something as simple as pressing the record button has spread widely, mostly fueled by the hype of the tool vendors.

If you do not have any hands-on experience with test automation, you might miss a very important fact about the whole thing - it is not only about creating the  scripts.  In fact the actual script creation rarely takes more than 20-30% of the time you invest in automation. Here is a rough outline of all the things you have to do:

  • Prepare the test environment
    With automation you want to have a very consistent environment, with known data and configuration, where you execute your tests. Sometimes this is not possible  - maybe  you have to test in a live system, or you don't control every part of the system landscape.  In such cases you can succeed only if you create smart automated tests that can anticipate and cope with all the expected changes in the environment. I will write more about this topic in the future, but for now let's just say that recording is not smart at all.
  • Create the test scripts
    This is the actual thing that recording addresses. It might seem that it is a very efficient way of creating test scripts, however in reality it is not. You will make errors while recording (like misclicks or mistypings). Correcting those errors in recorded scripts is most often difficult or even impossible.  Also if you limit yourself to just repeating recorded sequences, you will not benefit from all the good things that automation can offer compared with manual testing (like data-driven tests for example).
  • Execute the scripts
    Or maybe I should say try to execute the scripts. My experience shows that unless you are testing something that has a very simple UI, recording tools often fail to create working scripts out of the box, even if you have managed to ensure absolutely consistent environment for the test execution. Recording lacks the intelligence to understand what you are doing and what your actual intentions are in a complex UI.
  • Analyze the results
    In case you are executing recorded scripts, you will be hoping desperately that they pass successfully. In case something goes wrong (which will be most of the time), you will have extremely hard time trying to understand if it was a bug in the product, an issue with the test script or maybe a change in the application UI.
    The time spent in analysis of test results is probably the greatest time-waster in test automation and you can optimize this only by having proper logging on a higher semantic level than UI interactions. Again this is something that I intend to write about.
  • Update your scripts
    Software changes and you will either have to adapt your tests or throw them away. With recording it is mostly about throwing away. It is true that most of the tools now provide some ways to cope with simple changes in the UI, but those are still very limited. For example if a caption of a button changes from 'New' to 'New...',  in most cases you will be able to adjust your scripts. With the good tools you will have to add the '...'  only in one place, no matter how many times you click the button in your test.  However,  imagine that this button is replaced by a context menu.  Most  tools will let you somehow change this in their recorded scripts, but you will have to do this change every single place where the button was clicked in your scenario. Most probably you will just want to re-record it from scratch.

If you plan to do any serious automation, do not base the choice of your tool on how well it handles record and playback. In my opinion writing tests using the scripting language (and doing it right) is the only way to make UI automation really work.
I find recording only useful when I am testing with a new UI technology or a new automation tool and I want to quickly find out how it recognizes  a particular UI control.  In such cases recording a few mouse clicks and then looking at the generated script can be useful.

Where Am I?

You are currently browsing the Rants category at Test Automation Blog.