Signup/Sign In
LAST UPDATED: JUNE 1, 2021

How To Write Test Cases?

Technology #Test Cases

    Are you also trying to write a good test case, but are not able to do it? If yes, then don't worry because you have ended up in the right place. This article will tell you what a test case is, and how to write a good test case.

    So, let's get started.

    What is a Test Case?

    Test Case is a document, which has a set of test data, preconditions, expected results, and postconditions, developed for a particular test scenario to verify a particular feature or functionality of your software application. Basically, it is the starting point for any test execution.

    What is the difference between Test Case and Test Scenario?

    Test Scenario is one of the typical parameters of a Test Case that uses scenarios: hypothetical stories to help the tester work through a complex problem or test system. Test Scenario is also known as Scenario test.

    These are the following key difference between a test case and a test scenario:

    • Test Case consists of a set of test data, preconditions, expected results, and postconditions, developed for a particular test scenario whereas a Test Scenario is nothing but a test procedure.
    • Firstly, a test scenario is created, and then for each scenario, different test cases are created.
    • Test Cases are derived from test scenarios.
    • Test Case represents a single action by the user whereas test scenario represents a series of actions that are associated together.
    • Test cases are a set of input and output given to the system whereas a test scenario is a thread of operations.

    Consider a test scenario to check login functionality. Three test cases arise for this problem:

    • Test Case 1: Check results on entering valid User Id & Password
    • Test Case 2: Check results on entering Invalid User ID & Password
    • Test Case 3: Check the response when a User ID is Empty & Login Button is pressed, and many more.

    How to write Test Cases in manual testing?

    These are the following steps to create a Test Case for the scenario: Check Login Functionality

    Step 1: Explain the scenario of the test case.

    Test Case# Description
    1 Check the response when a valid email and password is entered

    Step 2: Enter the test data.

    Test Case# Description Test Data
    1 Check the response when a valid email and password is entered

    Example: studytonight@xyz.com

    Password: studytonight

    Step 3: A specific set of actions is required to be performed to execute the test case.

    Test Case# Description Test Steps Test Data
    1 Check the response when a valid email and password is entered

    1. Enter Email Address

    2. Enter Password

    3. Click Sign in

    Example: studytonight@xyz.com

    Password: studytonight

    Step 4: The behavior of the test case is checked for an expected result.

    Test Case# Description Test Data Expected Result
    1 Check the response when a valid email and password is entered

    Example: studytonight@xyz.com

    Password:studytonight

    Login should be successful

    After checking both the actual and expected result, it assigns a pass/fails status.

    Test Case# Description Test Data Expected Result Actual Result Status
    1 Check the response when a valid email and password is entered

    Example: studytonight@xyz.com

    Password:studytonight

    Login should be successful Login was successful Pass

    Step 5: The test case can also have Pre-condition and Post Conditions.

    How to write a good Test Case?

    Writing a good test case is one of the key activities performed by the tester in the Software Testing Life Cycle(STLC). These are some of the steps that should be followed to write test cases:

    • Identify the purpose of the Test Case: The first key point is to identify the testable requirements, the purpose of testing, and most importantly understand the features and user requirements.
    • Effective test scenarios: Then, we need to define effective test scenarios for a better understanding of the functional requirements.
    • Define Non-Functional Requirements: It is equally important to understand and define all the non-functional requirements as well.
    • Defining the Test Case Framework: It is important to ensure 100% test coverage.
    • Structure the Test Case: Now, that we have all the required information, it is important to give them a proper structure.

    These are some of the steps that should be followed to write more effective test cases:

    • The test case needs to be simple, transparent, and easy to understand.
    • It should be valid, brief, and short.
    • It should be both traceable and maintainable.
    • It should be implemented for both the positive and negative test cases.
    • One should avoid test cases.
    • One should not assume the functionality and features of your software application while preparing a test case.
    • It must be identifiable.

    Test Case Management Tools

    These are the automation tools that help to manage and maintain the Test Cases. These are the main features of test management tools:

    • Traceability
    • Automatic defect tracking
    • For documenting test cases.
    • Protecting test cases
    • Executing the test case and recording the result.

    Conclusion:

    I hope from the above article it is clear what a test case is, what is the difference between test case and test scenario, how to write a test case in manual testing, how to write a good test case, what are some of the test case management tools, etc.

    I am the founder of Studytonight & Fullstack developer (MERN). I like writing content about ReactJS, MERN, JavaScript, Docker, Linux, PHP, Go lang, Cloud, Web development, and general Tech related content. I have 10 years of diverse experience in software development.
    IF YOU LIKE IT, THEN SHARE IT
    Advertisement

    RELATED POSTS