How To Write Test Case For Software Testing
How To Write Test Case For Software Testing
Test cases help guide the tester through a sequence of steps to validate whether a software
application is free of bugs, and working as required by the end user. Learning how to write test
cases requires basic writing skills, an attention to detail, and a good understanding of the
application under test (AUT).
Typically, test cases for a given module or part of an application, are grouped into a test suite.
More often than not, a test session will include many test cases as there will usually be more
than one specific scenario to be tested.
A TEST CASE is a set of conditions or variables under which a tester will determine whether a
system under test satisfies requirements or works correctly.
The process of developing test cases can also help find problems in the requirements or design
of an application.
A test case can have the following elements. Note, however, that a test management tool is
normally used by companies and the format is determined by the tool used.
A good test case starts with a strong title. As a best practice, it’s good to name the test case
along the same lines as the module that you are testing. For example, if you’re testing the login
page, include “Login Page” in the title of the test case. In some cases, if the tool you’re using
doesn’t already do this, it might makes sense to include a unique identifier in the title of the test
case as well, so the identifier can be referenced instead of a long title
The description should tell the tester what they’re going to test. Sometimes this section might
also include other pertinent information such as the test environment, test data, and
preconditions/assumptions. A description should be easy to read and immediately communicate
the high-level goal of the test.
1
Test Case Notes by Deepak Mitra
You should include any assumptions that apply to the test and any preconditions that must be
met prior to the test being executed. This information can include which page the user should
start the test on, dependencies on the test environment, and any special setup requirements
that must be done before running the test. This information also helps keep the test steps short
and concise.
Test cases should be simple. Keep in mind, the person who wrote the test case might not be the
same person who executes the the test itself. The test steps should include the necessary data
and information on how to execute the test. This is perhaps the most important part of a test
case. Keep this section clear and concise, but don’t leave out any necessary details. Write the
test case so that anyone can go in and perform the test.
The expected result tells the tester what they should experience as a result of the test steps.
This is how the tester determines if the test case is a “pass” or “fail”.
Make it Reusable
A good test case is reusable and provides long-term value to the software testing team. When
writing a test case, keep this in mind. You can save time down the road by re-using the test
case instead of re-writing it.
As far as possible, write test cases in such a way that you test only one thing at a time. Do not
overlap or complicate test cases. Attempt to make your test cases ‘atomic’.
Ensure that all positive scenarios AND negative scenarios are covered.
Language:
2
Test Case Notes by Deepak Mitra
Note: This is a standard test case format. Specific fields may vary from company-to-company.
Test scenarios are rather vague and cover a wide range of possibilities. Testing is all about
being very specific.
For a Test Scenario: Check Login Functionality there many possible test cases are:
3
Test Case Notes by Deepak Mitra
Let’s create a Test Case for the scenario: Check Login Functionality
Step 2) In order to execute the test case, you would need Test Data. Adding it below
Identifying test data can be time-consuming and may sometimes require creating test data
afresh. The reason it needs to be documented.
Step 3) In order to execute a test case, a tester needs to perform a specific set of actions on the
AUT. This is documented as below:
4
Test Case Notes by Deepak Mitra
1 Check response when valid email and 1) Enter Email Email: [email protected]
password is entered Address
Password: lNf9^Oti7^2h
2) Enter
Password
3) Click Sign in
Many times the Test Steps are not simple as above, hence they need documentation. Also, the
author of the test case may leave the organization or go on a vacation or is sick and off duty or
is very busy with other critical tasks. A recently hire may be asked to execute the test case.
Documented steps will help him and also facilitate reviews by other stakeholders.
Step 4) The goal of test cases is to check behavior the AUT for an expected result. This needs
to be documented as below
1 Check response when valid email and Email: [email protected] Login should be
password is entered Password: lNf9^Oti7^2h successful
During test execution time, the tester will check expected results against actual results and
assign a pass or fail status
Step 5) That apart your test case -may have a field like, Pre - Condition which specifies things
that must in place before the test can run. For our test case, a pre-condition would be to have a
5
Test Case Notes by Deepak Mitra
browser installed to have access to the site under test. A test case may also include Post -
Conditions which specifies anything that applies after the test case completes. For our test
case, a postcondition would be time & date of login is stored in the database
Click Submit
Click Submit
This entire table may be created in Word, Excel or any other Test management tool. That's all to
Test Case Design
The test setup like a version of an application under test, software, data files, operating system,
hardware, security access, physical or logical date, time of day, prerequisites such as other
tests and any other setup information pertinent to the requirements being tested
6
Test Case Notes by Deepak Mitra
Create test cases that are as simple as possible. They must be clear and concise as the author
of the test case may not execute them.
Use assertive language like go to the home page, enter data, click on this and so on. This
makes the understanding the test steps easy and tests execution faster.
The ultimate goal of any software project is to create test cases that meet customer
requirements and is easy to use and operate. A tester must create test cases keeping in mind
the end user perspective
Do not repeat test cases. If a test case is needed for executing some other test case, call the
test case by its test case id in the pre-condition column
4. Do not Assume
Do not assume functionality and features of your software application while preparing test case.
Stick to the Specification Documents.
Make sure you write test cases to check all software requirements mentioned in the
specification document.
Name the test case id such that they are identified easily while tracking defects or identifying a
software requirement at a later stage.
7
Test Case Notes by Deepak Mitra
It's not possible to check every possible condition in your software application. Software Testing
techniques help you select a few test cases with the maximum possibility of finding a defect.
Boundary Value Analysis (BVA): As the name suggests it's the technique that defines the
testing of boundaries for a specified range of values.
Equivalence Partition (EP): This technique partitions the range into equal parts/groups that tend
to have the same behavior.
State Transition Technique: This method is used when software behavior changes from one
state to another following particular action.
Error Guessing Technique: This is guessing/anticipating the error that may arise while doing
manual testing. This is not a formal method and takes advantages of a tester's experience with
the application
8. Self-cleaning
The test case you create must return the Test Environment to the pre-test state and should not
render the test environment unusable. This is especially true for configuration testing.
The test case should generate the same results every time no matter who tests it
After creating test cases, get them reviewed by your colleagues. Your peers can uncover
defects in your test case design, which you may easily miss.