Introduction to Test Automation
Test automation is the use of software to control the execution of tests,the comparison of actual outcomes to predicted outcomes, the setting up of test preconditions, and other test control and test reporting functions. Commonly, test automation involves automating a manual process already in place that uses a formalized testing process.
Overview
Although manual tests may find many defects in a software application, it is a laborious and time consuming process. In addition it may not be effective in finding certain classes of defects. Test automation is a process of writing a computer program to do testing that would otherwise need to be done manually. Once tests have been automated, they can be run quickly. This is often the most cost effective method for software products that have a long maintenance life, because even minor patches over the lifetime of the application can cause features to break which were working at an earlier point in time.
There are two general approaches to test automation:
- Code-driven testing. The public (usually) interfaces to classes, modules, or libraries are tested with a variety of input arguments to validate that the results that are returned are correct.
- Graphical user interface testing. A testing framework generates user interface events such as keystrokes and mouse clicks, and observes the changes that result in the user interface, to validate that the observable behavior of the program is correct.
Test automation tools can be expensive, and it is usually employed in combination with manual testing. It can be made cost-effective in the longer term, especially when used repeatedly in regression testing.
One way to generate test cases automatically is model-based testing through use of a model of the system for test case generation, but research continues into a variety of alternative methodologies for doing so.
What to automate, when to automate, or even whether one really needs automation are crucial decisions which the testing (or development) team must make. Selecting the correct features of the product for automation largely determines the success of the automation. Automating unstable features or features that are undergoing changes should be avoided.
Code-driven testing
A growing trend in software development is the use of testing frameworks such as the xUnit frameworks (for example, JUnit and NUnit) that allow the execution of unit tests to determine whether various sections of the code are acting as expected under various circumstances. Test cases describe tests that need to be run on the program to verify that the program runs as expected.
Code driven test automation is a key feature of Agile software development, where it is known as Test-driven development (TDD). Unit tests are written to define the functionality before the code is written. Only when all tests pass is the code considered complete. Proponents argue that it produces software that is both more reliable and less costly than code that is tested by manual exploration. It is considered more reliable because the code coverage is better, and because it is run constantly during development rather than once at the end of a waterfall development cycle. Because the developer discovers defects immediately upon making a change, when it is least expensive to fix. Also, since the only code that is written is what is required to make the tests pass, the tendency to write too much code is removed. Finally, rework is safer. When code is made faster or is cleaned-up, all of the tests that passed must continue to pass or the reworked code is not working as it should.
Graphical User Interface (GUI) testing
What to Test
One must keep following points when thinking of test automation:
* Platform and OS independence
* Data driven capability (Input Data, Output Data, Meta Data)
* Customizable Reporting (DB Access, crystal reports)
* Email Notifications (Automated notification on failure or threshold levels)
* Easy debugging and logging
* Version control friendly – minimum or zero binary files
* Extensible & Customizable (Open APIs to be able to integrate with other tools)
* Common Driver (Ant or Maven)
* Headless execution for unattended runs (For integration with build process or batch runs)
* Support distributed execution environment (distributed test bed)
* Distributed application support (distributed SUT)
