Table of Contents
Test Case in Software Testing
What is Test Case?
A test case is a document developed for a particular test scenario in order to verify whether a software application is working as per the customer’s requirements or not. The document consists of a set of test data, preconditions, expected results and post conditions. Test case is derived from Test Scenario and it acts as the starting point for the test execution. it is a detailed document which contains positive as well as negative inputs.
When do we write Test Case?
- Test case can be written When the customer gives the business needs i.e., before the actual coding as it helps in identifying the requirement of the product/software.
- After requirement gathering developers start to build the project, testing team will start writing the test cases.
- Test cases are also written directly after developing the feature/finishing the development of product.
Importance /Why do we write Test Case?
Test case define the way in which the testing would be carried out. We write the test cases for the following reasons: –
- Test case ensure uninterrupted software testing.
- To validate software is defect free.
- To verify software is working as per user expectations.
- To ensure better test coverage.
- Test cases are helpful during the maintenance phase as its detailed document.
- Helps in improving the software quality.
- To decrease the maintenance and software support costs.
- It acts as a great tool for documentation and verification of the expected test results.
How to write Software Test Case?
Test cases help testers understand their test’s requirements and scope. It’s not an important part of development but makes software testers to perform better. Test case format might differ between organizations however it follows these basic parameters like: –
Step 1: Test Case ID
This field uniquely identifies a test case.
Step 2: Test Description
This describes the condition required to be checked for a given software.
Step 3: Assumptions and Pre-Conditions
The conditions or steps that must be accomplished before the test steps executions.
Step 4: Test Data
This describes the variables and their values in the test case
Step 5: Steps to be Executed
Steps to be executed by tester for the checking of the condition.
Step 6: Expected Result
This indicates the output you expected after the test case step execution.
Step 7: Actual Result and Post-Conditions
This is the output you actually receive from the system
Step 8: Status
The status of tests such as pass, fail
Same result as expected = Pass
Different results = Fail
Steps for writing functional Test Case Functional test case include:
- Description of the function
- Preconditions for being able to test it
- Steps required to test
- Expected result
Best Practices for Effective Test Case Writing
A well -written test cases are easy to execute and maintain. best practices to follow while creating test cases are:
Keep It Simple and Easy to Understand
Create test cases that are as simple as possible the test case summary, description, test steps, expected results, etc should be written in a clear and concise way. These should be easily understandable by the different stakeholders in testing.
Include End User Perspective
Create test cases that meet customer requirements and is easy to use and operate by the end user.
Use Correct Naming Conventions
Follow a uniform nomenclature in test cases. It makes easy for stakeholders to identify and understand its objective
Provide Test Case Description
A proper test case description is vital for users to understand what is being tested and how.
Include Assumptions and Preconditions
Include all the assumptions and preconditions that are applicable for the test case.
Give the Steps Involved
Provide the steps involved in the execution of the test cases.
Give Details of The Test Data
Include details of test data used in testing. It should be diverse and as close to real-time usage as possible.
Make It Reusable and Modular
Ensure that there is no conflict among test cases. If there is interdependent test case clearly mention them in the test document.
Assign Testing Priority
Prioritization of test cases so that high priority test case is executed first.
Provide The Expected Result and Post Conditions
Provide the expected result for every step of the test case and post conditions that should be verified after the execution of the test case.
Who Writes Test Case?
Test case normally written by testers but in some organizations writing unit and integration tests cases involves developers also.
Example 1 –
|
||||||
VERSION NO: | TESTED BY:XYZ | |||||
VERIFIED BY:ABC | DATE:dd/mm/yy | |||||
MODULE NAME:LOGIN PAGE | ||||||
TEST_ID | TEST DESCRIPTION | TEST PROCEDURE | TEST DATA | EXPECTED RESULT | ACTUAL RESULT | STATUS |
FB_LG_01 | Enter URL of Facebook | 1.open Facebook website | www.facebook.com | Login page should be displayed | Login page displayed | Pass |
FB_LG_02 | Enter a valid username and password | 1.Enter valid username 2. Enter valid password 3.click a login button |
username:xyz@gmail.com password:***** |
should be able to login | login successful | pass |
FB_LG_03 | Enter valid username and invalid password | 1.Enter valid username 2. enter invalid password 3.click on login button |
username:xyz@gmail.com password:********** |
should not allow to login. A popup showing invalid username/password | Login unsuccessful | pass |
FB_LG_04 | Enter invalid username and valid password | 1.Enter invalid username 2. enter valid password 3.click on login button |
username:ABC@gmail.com password:***** |
Login unsuccessful popup showing invalid username/password | Login unsuccessful | pass |
FB_LG_05 | Enter invalid username and invalid password | 1.Enter invalid username 2. enter valid password 3.click on login button |
username:ABC@gmail.com password:********* |
Login unsuccessful popup showing invalid username/password | Login unsuccessful | pass |
FB_LG_06 | to create new account: Enter first name and surname | 1.enter first name 2.enter surname |
First name :abc surname :xyz |
should be able to enter data | data entered successfully | pass |
FB_LG_07 | enter email address or mobile number |
1. enter valid email id | email id: abc@gmail.com phone number: 3216549870 |
should verify email or number | verified email or number | pass |
FB_LG_08 | Re-enter the email address or mobile number |
1. re-enter valid email id or mobile number |
email id: abc@gmail.com phone number: 3216549870 |
should reject different mail id or password |
rejected different mail id and password |
pass |
FB_LG_09 | enter valid password | 1. enter a password | 12345 | should only accept password | accepted password | pass |
FB_LG_10 | enter DOB | 1. enter a DOB | January-14-2000 | should accept dates | dates accepted | pass |
FB_LG_11 | enter gender and click create account button |
1.enter gender 2.click create account button |
male or female | should be able to select gender | able to select gender | pass |
FB_LG_12 | enter 6-digit security code and click enter |
1. enter the security code 2.click enter |
xxxxxxxx | should display Facebook news feed |
displayed Facebook newsfeed | pass |
FB_LG_13 | enter message on What’s on your mind? label |
1.click on that label 2.enter message 3.click on post button |
hello | should be able to post message | message posted | pass |
FB_LG_14 | enter input in Add photo/video section | 1. click on add photo/ video 2.browse an image/video 3. click post button |
should only accept image and video formats | accepted only image and video formats | pass | |
FB_LG_15 | click the down arrow symbol from top right side |
1.click down arrow button | should open a small dialogue box |
small dialogue box opened | pass | |
FB_LG_16 | click logout button | 1. click logout button | should redirect to Facebook login page |
redirected to Facebook login page | pass |
Example 2 –
GOOGLE CHROME |
||||||
VERSION NO: | TESTED BY:XYZ | |||||
VERIFIED BY:ABC | DATE:dd/mm/yy | |||||
MODULE NAME:SEARCH | ||||||
TEST_ID | TEST DESCRIPTION | TEST PROCEDURE | TEST DATA | EXPECTED RESULT | ACTUAL RESULT | STATUS |
GC_SR_01 | Launch Google Chrome | 1. open chrome browser from the desktop | should open chrome browser | chrome browser opened | Pass | |
GC_SR_02 | Enter a word in the search bar | 1. open chrome 2.enter data 3.click the search button |
books | 1. On clicking the search button, it should redirect user to search results. | Redirected to search results | pass |
GC_SR_03 | check voice input available | check the UI | microphone icon should be present |
microphone icon is present | pass | |
GC_SR_04 | check the microphone | 1. Press the microphone icon in the Google 2. record voice input “books” |
audio input books | On clicking the search button, it should redirect user to search results. | Redirected to search results | pass |
GC_SR_05 | check if it accepts sentences | 1. Enter the text ‘software testing books’ in the search text box. 3. Click the Search button |
software testing books | On clicking the search button, it should redirect user to search results of software testing books | Redirected to search results | pass |
GC_SR_06 | check visibility of long search text | 2. Enter lengthy sentence in the search text box. 3. Press the Enter key |
should accept lengthy search keyword | lengthy keywords accepted | pass | |
GC_SR_07 | check whether invalid inputs accepted | 1.Enter text special characters ‘@#$%^’ in the search text box. 3. Press the Enter key |
!@#$$^*^$# | 1. Search results should give the message Suggestions: a. Make sure that all words are spelled correctly. b. Try different keywords. c. Try more general keywords. or 2. show message ‘did not match any documents’ . |
Result as expected | pass |
GC_SR_08 | check google image accepts image file | 1. click google image from top right corner 2. click on camera icon 3. upload image 4. click search button |
image file | 1.should be able to upload image 2. should display results related to search |
Result as expected | pass |
GC_SR_09 | check sign in/sign out possible | 1. click on add google account 2. Sign in with a valid email id and password |
should redirect to user login page | redirected to login page | pass | |
GC_SR_10 | Sign in with invalid user id and password | 1. click on add google account 2. Sign in with an invalid email id and password |
should show error message | error message showing invalid email id and password | pass | |
GC_SR_11 | check if specific country is displayed | look country name on the left bottom side of the Google Home page. | should display the current location according to country name should reflect in left bottom side of Google Home page. | location visible on left bottom side | pass |
Test Management Tools
Some of the popular tools for the test management process are
- Zephyr Scale (Paid)
- TestCaseLab (Paid)
- Qtest (fFee)
- Test Rail (Free)
- PractiTest (Paid)
- Qase (Free)
Software Test Case Template
Let’s look at a basic test case template for the login functionality.
The Test case template contains the header section which has a set of parameters that provides information about the test case such as the tester’s name, test case description, Perquisite, etc. The body section contains the actual test case content, such as test Id, test steps, test input, expected result, etc.
In the given template below it’s clearly identifiable that the section from module name to test scenario is the header section while the table that lies below the test scenario (from test case id to comments) is the body of the test case template.
Here a test case template for login functionality has been created with its parameters and values
Tools for Writing Software Test Cases
There’s no right or wrong place to document your test cases, but there are many tools that help make the process of writing test cases more effective and efficient. For example, test cases have traditionally been written in a spreadsheet. Many testing teams still opt for this approach. It’s fairly flexible, you can create your own process and method of tracking test cases, but it can also be extremely time-consuming, and clunky.
Using above details and guidelines you can create your own Software Test cases of your projects. You can provide your feedback if you have any doubts in the comment box.