- 29.1 Three Grains of Rice
- 29.2 Understanding Has to Grow
- 29.3 First Day Automated Testing
- 29.4 Attempting to Get Automation Started
- 29.5 Struggling with (against) Management
- 29.6 Exploratory Test Automation: Database Record Locking
- 29.7 Lessons Learned from Test Automation in an Embedded Hardware-Software Computer Environment
- 29.8 The Contagious Clock
- 29.9 Flexibility of the Automation System
- 29.10 A Tale of Too Many Tools (and Not Enough Cross-Department Support)
- 29.11 A Success with a Surprising End
- 29.12 Cooperation Can Overcome Resource Limitations
- 29.13 An Automation Process for Large-Scale Success
- 29.14 Test Automation Isn't Always What It Seems
29.3 First Day Automated Testing
Jonathon Lee Wright, United Kingdom
Consultant and speaker
In the past decade, I have dealt with a number of ways of creating testware frameworks and found advantages and disadvantages in each of the following approaches:
- Modularity driven
- Keyword driven
- Data driven
In 2009, I was tasked with automating the testing of a new package for the New Zealand Lotteries Commission. The requirements phase had only just been completed, and the scheduled testing was looking very tight—less than a month (the schedule was imposed on us by marketing, who had already overcommitted their advertising!).
With just 2 months until the release would be delivered, this was an opportunity to adapt the testware frameworks I had used before, combining them with the latest technologies to develop what I refer to as a hybrid (keyword-/data-driven) automation framework.
Not only would this meet all the requirements set by the business, but more important, it would allow us to start the development of the testware framework immediately.
29.3.1 Initial Investment
The inherent problem with the hybrid approach is the large initial investment in time and effort to design the testware framework. Consequently, it was important that the development of this framework be treated as a legitimate project in its own right with its own planning, design, development, and testing phases together with the necessary resources. Table 29.1 shows our estimates for the effort required to create 100 test scenarios.
Table 29.1 Simple Calculations for Initial Testware Preparation Effort
In essence, the hybrid approach would take roughly twice as long as the previous automation approach, which in turn would take twice as long to automate than the preparation for manual testing.
29.3.2 What Is to Be Automated?
Given the limited time available and the increased initial effort required, it was critical that we identified the optimum test coverage. To avoid developing unnecessary test components, we used the MoSCoW method:
- What must be automated?
- What should be automated?
- What could be automated?
- What won’t be automated?
This method allowed us to focus our efforts on those test components that were necessary and would give the greatest value by assessing the associated business risk, reusability, usage, complexity, and feasibility of each test component.
The test components were regarded as individual jigsaw pieces, but we kept in mind what was needed to complete the entire puzzle.
Business process modeling (BPM) was used within the centralized test management tool (Quality Centre) to represent the individual puzzle pieces (test components); mapping the pieces revealed the workflow through the system.
Figure 29.1 shows how one BPM may only include 5 puzzle pieces but enable more than 20 different paths through the system under test (SUT), with each path having a different business risk and impact assessment.
Figure 29.1 Business process model of the SUT.
This made it easier to decide which automation modules to develop first by starting small and automating only the most critical business processes—keeping it as simple as possible while recognizing that the test coverage could be increased as the framework matured over time.
The decomposition of the workflows into a high-level model visualizes and enables an agile approach to the framework development. The development’s build order and resource focus becomes obvious.
Each path through the system represents an agile feature, which may be in or out of scope depending on time and resources. Another benefit of this approach is that the model becomes an artifact that may be shared between the test framework and target application developers.
29.3.3 First Day Automated Testing
The key to first day automated testing is to create a dynamic object repository based on a combination of fuzzy logic and descriptive programming supporting the design and development of test scenarios before the actual delivery of the SUT.
Traditionally, because of the dependency on building the object repository, test automation is carried out at the end of the software development lifecycle once the SUT is delivered. However, because we had only a single month in which to execute testing but a full 2 months before the SUT was delivered, it seemed logical to develop the testware framework beforehand while the application was still in development.
126.96.36.199 Business-Level Keywords
To allow the creation of test scenarios ahead of the SUT delivery, a high-level keyword approach was used to represent:
- Specific BPM and business process testing (BPT) modules
- Specific/collections of user stories
- Assigned work items
- Queries against the test asset database
Using high-level business-level keywords, such as Login.Process, allows complexity hiding and reusable encapsulation. Login.Process contains a number of low-level keywords, such as Enter Username Text and Press Login Button.
The collection of application keywords represents natural domain-specific languages that translate into a number of lower-level actions performed before and after the core event. This included checking that the pretest and posttest conditions were met and the actions and reactions, including any popup/error recovery, were processed correctly.
Using this approach meant we had a foundation upon which to design and develop reliable, domain-specific, and reusable test scenarios before the release of the SUT.
Writing the test scenarios (manual or automated) as business-level keywords combined with natural language made it accessible to application domain experts, business analysts, and developers. The test language was self-validating and human readable, which removed the requirements to educate the end user in the tool. The verbs and nouns in the domain-specific language were written in natural language using context-sensitive validation. This improved the utilization of resources by encouraging joint collaboration between multifunctional teams while supporting behavior-driven development (BDD).
The Scrum team was made up of a number of multidiscipline team members (business analysts, testers, and developers) sharing the various roles of the test design phase without any previous automation experience. This allowed teams to collaborate and share test assets such as BPM/BPT modules, user stories, and work items. They could also run queries against previously created test scenarios and reuse shared test cases and steps.
The flexibility of having the test scenarios stored in a database also allowed for full/partial fallback support for legacy manual testing because the test data could be easily extracted into a traditional test scenario format. It was easy to read because of the use of natural language combined with valid test data that could be easily used in manual test execution.
In summary, this approach of managing centralized test assets to generate sanitized test scenarios validated against business rules provided ready-to-use tests and data in the correct format. This was evidenced by the ability to generate tests featuring over 10,000 ticket number combination states covering all possible combinations of ticket types and amounts (this excluded specialized test runs such as boundary and negative tests, which were run separately) before the SUT had even been written.
29.3.4 Problems and Solutions
We found problems stemming from procedures not being followed consistently. For example, changes to the functionality of reusable test components’ jigsaw pieces were not being checked in correctly. This was caused by not having an enforceable gated check-in procedure and consequently resulted in limited reusability of some of the test components. The problem was solved by enforcing the check-in procedures in the Configuration Management tool.
It became apparent when the testware framework entered the execution phase and was distributed across a pool of remote test clients generated by a virtual machine (VM) dispenser that there was limited direct visibility into the test execution status.
While it was relatively easy to identify primary core modules failing on startup, more subtle changes to reusable test components were much harder to spot. The requirement for a test asset loader to validate the current SUT build against the test asset database before execution could have prevented this.
Without the ability to monitor runtime failure, especially controlled failure (i.e., scenario recovery), a significant amount of execution time was wasted. For example, a discrete change to a test component could cause a false-positive error, which in turn caused the testware framework to repeatedly retry the current test scenario before attempting to continue through the remaining test cases. What was needed here was a suitable real-time dashboard that could provide notifications regarding the SUT health as well as progress of test client execution.
We solved this problem by devising a way to flag the overall status of a test set—In Progress, Ready, Repair, or Blocked—to keep the tester informed. This would affect the current test run and associated test client VM’s state where, for example, a Blocked status did not allow the test run to be continued until the necessary pretest conditions were met (e.g., the Lotto product draw had been successfully processed).
29.3.5 Results of Our First Day Automation Approach
This approach worked extremely well, and we realized a good return on investment (ROI) for the additional effort in developing the framework.
Once the release was delivered, the execution was run constantly, day and night. This was made possible by having dedicated resources available during the day to deal with basic debugging of failed scripts and execution. Developers based in another time zone were also available in the evening to maintain the framework and provide additional support for improved test coverage.
Overall, this approach was found to work well in this case study by demonstrating its innate advantages, reflected in what I like to call the approach: Hybrid Keyword Data-Driven Automation Framework.
- Hybrid: Utilizing the best technologies and resources to do the job.
- Keyword: Creating simple and robust test scenarios written in business-level keywords combined with natural language.
- Data: Effective use of dynamic business data to provide an input source.
- Driven: Reusable component modules and libraries to provide reliable processing of generic actions, objects, and events.
- Automation: That is collaborative, distributed, and scalable.
- Framework: Independent of application, technology, or environment under test.
The best aspects of these proven approaches demonstrate how they have evolved over the past decade; this echoes some of the progress toward leaner and more agile business methodologies. They are in a constant state of evolution—just as the underpinning technologies evolve over time.
A significant benefit was that the framework had the ability to support multiple browsers, platforms, and technology stacks under a unified engine with the capability to deal with generic object classes as well as application-specific classes.