CHARACTERISTICS OF AUTOMATED TEST CASES
12.13 CHARACTERISTICS OF AUTOMATED TEST CASES
The largest component of test case automation is programming. Unless test cases are designed and coded properly, their execution and maintenance may not be effective. The design characteristics of effective test cases were discussed in Chapter 11. A formal model of a standard test case schema was also provided in Chapter 11. In this section, we include some key points which are pertinent to the coding of test cases. The characteristics of good automated test cases are given in Figure 12.5 and explained in the following.
1. Simple: The test case should have a single objective. Multiobjective test cases are difficult to understand and design. There should not be more than 10–15 test steps per test case, excluding the setup and cleanup steps. Multipurpose test cases are likely to break or give misleading results. If the execution of a complex test leads to a system failure, it is difficult to isolate the cause of the failure.
2. Modular: Each test case should have a setup and cleanup phase before and after the execution test steps, respectively. The setup phase ensures that the initial conditions are met before the start of the test steps. Similarly, the cleanup phase puts the system back in the initial state, that is, the state prior to setup. Each test step should be small and precise. One input stimulus should be provided to the system at a time and the response verified (if applicable) with an interim verdict. The test steps are building blocks from reusable libraries that are put together to form multistep test cases.
3. Robust and Reliable: A test case verdict (pass–fail) should be assigned in such a way that it should be unambiguous and understandable. Robust test cases can ignore trivial failures such as one-pixel mismatch in a graphical display. Care should be taken so that false test results are minimized. The test cases must have built-in mechanisms to detect and recover from errors. For example, a test case
Simple Modular
Robust Characteristics and reliable
Reusable
Maintainable Documented Independent and
self-sufficient
Figure 12.5 Characteristics of automated test cases.
398 CHAPTER 12 SYSTEM TEST PLANNING AND AUTOMATION
need not wait indefinitely if the SUT has crashed. Rather, it can wait for a while and terminate an indefinite wait by using a timer mechanism.
4. Reusable: The test steps are built to be configurable, that is, variables should not be hard coded. They can take values from a single configurable file. Attention should be given while coding test steps to ensure that a single global variable is used, instead of multiple, decentralized, hard-coded variables. Test steps are made as independent of test environments as possible. The automated test cases are categorized into different groups so that subsets of test steps and test cases can
be extracted to be reused for other platforms and/or configurations. Finally, in GUI automation hard-coded screen locations must be avoided.
5. Maintainable: Any changes to the SUT will have an impact on the auto- mated test cases and may require necessary changes to be done to the affected test cases. Therefore, it is required to conduct an assessment of the test cases that need to be modified before an approval of the project to change the system. The test suite should be organized and categorized in such a way that the affected test cases are easily identified. If a particular test case is data driven, it is recom- mended that the input test data be stored separately from the test case and accessed by the test procedure as needed. The test cases must comply with coding stan- dard formats. Finally, all the test cases should be controlled with a version control system.
6. Documented: The test cases and the test steps must be well documented. Each test case gets a unique identifier, and the test purpose is clear and under- standable. Creator name, date of creation, and the last time it was modified must
be documented. There should be traceability to the features and requirements being checked by the test case. The situation under which the test case cannot be used is clearly described. The environment requirements are clearly stated with the source of input test data (if applicable). Finally, the result, that is, pass or fail, evaluation criteria are clearly described.
7. Independent and Self-Sufficient: Each test case is designed as a cohesive entity, and test cases should be largely independent of each other. Each test case consists of test steps which are naturally linked together. The predecessor and successor of a test step within a test case should be clearly understood. It is useful to keep the following three independence rules while automating test cases:
• Data value independent: The possible corruption of data associated with one test case should have no impact on other test cases.
• Failure independent: The failure of one test case should not cause a ripple of failures among a large number of subsequent test cases.
• Final state independent: The state in which the environment is left by a
test case should have no impact on test cases to be executed later. We must take into consideration the characteristics outlined in this section
during the development of test scripts. In addition, we must obey the syntax of the test case defined in the next section while implementing a test case.
12.14 STRUCTURE OF AN AUTOMATED TEST CASE