How To Write Good Test Cases PDF
How To Write Good Test Cases PDF
Writing test cases is one of the key activity performed by the tester in the Software Testing Life
Cycle(STLC). But the writing effective test case is a skill & which can be done by doing in-
depth study of application for which writing the test cases and most important is the experience.
The approach for writing good test cases will be to identify, define and analyze the requirements.
“A test case is a set of conditions or variables under which a tester will determine
whether a system under test satisfies requirements and works correctly.”
Typically, test cases should be small, isolated and atomic. Test cases should be easy to
understand and steps should be executed fast. They should independent with each other &
fail/pass independently from one another. Fairly, each good test should have defined its
expected result.
Assumptions If any
Test Data Test data required for executing the test case.
Expected results How application should behave after executing the above testing steps.
You can use start writing test cases in the excel sheet. You can continue with excel or choose
open source or paid test case management tool from the variety of list. There are different test
case management tools like Quality Center, Test Director or TestLink etc. in the market, these
tools supports excel import feature, so you can import above written test case easily.
Once the test case is executed you should mark the result of test case. Many tools provide the
execution of test case step by step. If you are using excel sheet then you can simply mark the
status of test case. If the test case is failed then you should log a defect add same defect id in
the test case while executing the test case. This will really help for tracking the testing progress
& measure the quality of the application. While writing the test cases the steps should be
detailed and clear. I personally do not agree to write the large number of steps in the test cases.
First key point before start writing effective test cases is that you need to identify the testable
requirements. You need to understand the purpose of testing & you must understand the
features and user requirements.
Before start writing the effective test cases, you should first start defining the effect test
scenarios and to start defining effective test scenarios you should have better understanding of
functional requirements of an application. You must know about what all operations can be used,
so that the test scenarios & test cases can be written based on these important guidelines.
Along with the function requirements, the non-functional requirements are equally important.
Basically in non-functional requirements such as Operating system, hardware requirements,
security features to be considered and also identity additional prerequisites required for testing
like test data preparation.
For example, Consider a scenario where form accepts the user information, in such case the
proper timeout should be defined by the developer to make sure that the application should not
timed out while entering the user information into application. At the same time if the user is idle
for few time, so system should automatically logged off after the predefined delay to ensure that
security of application is not violated.
Depends of the systems requirements the test case framework can be designed. Typically, the
test cases should cover functionality, compatibility, UI interface, fault tolerance, and
performance of several categories.
It is simple and easy to understand analyze the significance of the software modules there in the
application under test. On the other hand it is also equally important to identify the integration
with internal modules. So to write good test cases you should familiar with the importance of
these & consider same while preparing the test cases.
Let’s take a simple example of Online Shopping website testing, while testing from shopping cart
to order checkout you also needs to consider Inventory Management & check if upon successful
order checkout same can be deducted from store.
At this point you have all the necessary information to start writing test cases. Here we are
talking about basic structure of test case & what all comprises in the test case. In above steps
we have prepared list of test scenarios prepared from the requirements, now we can elaborate
the test scenarios & will prepare test cases. Each test scenario may have one or multiple test
cases.
The steps in the test cases should be detailed & to the point, so new tester can easily execute
the test case with ease. The purpose and scope of test cases should be well defined in the test
case i.e. Test cases should be self explanatory. Along with detailed steps all pre-requisite test
data should be specified in the test case itself.
Test cases should be reviewed by peer members.
Test cases should have only necessary and valid steps. If single test case having too many test
steps to be performed then this may lose concentration & aim of test case. So, single test case
should have one expected result and not try to cover too many expected results. Create Test
Case with thinking of end users point of view. Don’t repeat the test cases, if same steps are
needed to execute then provide the test case id in the pre-requisite step.
Each and every test case should be traceable and it should be linked to “Requirement ID”, which
help to check the 100% coverage of requirements & this will help to identify the tester is
performing testing for all requirements and no any requirement is missed to test. One more key
advantage of doing linking “Requirement ID” to test case is, if any of the requirement gets
changed then based on this mapping we can easily do the impact analysis & change the
impacted test cases accordingly.
Test cases should be written in such a way that it should be easy to maintain. Let’s take scenario
where after completion of writing test cases the requirement gets changed, then tester should
effortlessly able to maintain the test suite of test cases.
Each test case should have unique identification number which help to link the test cases with
defects and requirements.
5. Implement Testing Techniques – Positive And Negative Test Cases
While writing test cases few test case design methods should be used like equivalence classes
portioning, boundary value analysis, normal and abnormal conditions. You should also consider
negative testing, failure conditions and error handling which could help to discover most probable
defects in the code. Don’t assume any functionality, write the test cases with reference to
requirement specification document.
Sometimes, variety of test data (pre-requisite) is required for executing the test cases like valid
data to test positive test cases, invalid data to test negative test cases, legitimate invalid data to
test boundary value conditions, illegal and abnormal data to test error handling and recovery test
cases.
Different set of test cases should be prepared for the basic performance testing like multi-user
operations and capacity testing. Also cover the test cases for Browser supports in case of Web
application testing. Test cases for Security aspects should be cover for example user permission,
session management, logging methods.
Test cases should cover the usability aspects in terms of ease of use. The test cases should cover
for overall style & color of the page & check same against the signed off mock-up designs if any
or need to check the style with overall style guidelines. Basic spellings, English grammars,
population of dependent drop-down list values should be cover under usability testing aspects.
Source:
http://www.softwaretestingclass.com/how-to-write-good-test-cases/