Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction 
2.
What Is Test Case Design?
3.
When do we write a test case?
4.
Why we write the test cases?
5.
Test Case Template
6.
Test Case Design Techniques
6.1.
Boundary Value Analysis
6.2.
Equivalence Class Partitioning
6.3.
Decision-Based Table Testing
6.4.
State Transition Testing
6.5.
Error Guessing Testing
7.
Example of a Test Case Template
8.
Types of Test Cases
9.
Process to Write Test Cases
10.
Frequently Asked Questions
10.1.
What is a Test Design Technique?
10.2.
What are the 7 Principles of Testing?
10.3.
What are the Three Common Types of Tests?
11.
Conclusion
Last Updated: May 21, 2024
Easy

Test Case Design In Software Engineering

Introduction 

In this blog, we will discuss Test case design in Software Engineering and we will also different techniques of test case designing. But before looking into test case designing we should first look at why test case designing is required in software engineering?. If we want to improve the quality of software testing then we need a solid test case design approach. Test design is a part of the entire testing life-cycle that is often overlooked but is crucial for successful testing and, as a result, software application quality. The cornerstone of testing is test design, which guarantees that the test strategy is successful, consistent, and repeatable. Due to the impossibility of exhaustive testing, this step is critical for ensuring maximum testing coverage with the least amount of test conditions and effort.

Test Case Design In Software Engineering

What Is Test Case Design?

The test design phase aims to create test scenarios and test cases that can be run on the application being tested (AUT). The test execution step executes the test cases completed during the test design phase. It's reasonable to argue that test cases constitute the foundation of Software Testing. As a result, they must be well-designed, simple to comprehend, and, most essential, give 100 percent functional coverage to prevent flaws from spreading to higher levels. The test case design approaches provide a systematic approach to test case production in this scenario. A test case suite created at random will lack quality and coverage, resulting in defect leaking.

When do we write a test case?

  • Before developing a feature: Ensures the feature meets requirements and functions correctly.
  • After identifying bugs: Validates that the bug is fixed and doesn't reoccur.
  • During code refactoring: Confirms that existing functionality remains intact.
  • When adding new functionality: Ensures new features integrate seamlessly without breaking existing code.
  • Before releasing a product: Ensures comprehensive coverage and readiness for production.

Why we write the test cases?

  • To ensure code quality: Helps maintain high standards and reduces bugs.
  • For documentation purposes: Provides a clear understanding of the system's behavior.
  • To facilitate maintenance: Makes it easier to update and refactor code with confidence.
  • To enable automated testing: Allows for continuous integration and delivery.
  • To improve collaboration: Enhances communication among team members by clarifying expectations and requirements.

Test Case Template

A test case template is a document that contains an orderly set of test cases for various test scenarios that are used to determine whether or not the program has the expected functionality.

A test case template for determining whether an application correctly changes a user's username is given below.

use case template

The above-given test case template is used to check if a software application is successfully changing the username or not. 

Test Case Design Techniques

The critical test case design methodologies are listed below. Software testers should utilize these approaches sparingly and use their knowledge of which techniques are appropriate for their testing situation.

  1. Boundary Value Analysis (BVA)
     
  2. Equivalence Class Partitioning
     
  3. Decision-Based Table Testing
     
  4. State Transition Testing
     
  5. Error Guessing Testing 

Boundary Value Analysis

BVA is a method that involves testing the test data's bounds. Maximum, minimum, inside or outside borders and error values are all included. This method is predicated on the likelihood that developers would make errors while working under certain constraints. In essence, many mistakes occur around the edges of the input domain rather than in the middle. Its working concept is that if a system works for these specific boundary values, it will function for any value between the two

For example: A text field allows input from 1 to 100 as a test case.

Boundary values analysis test cases - 0,1,2 and 99,100,101

Equivalence Class Partitioning

Another black-box testing approach is equivalence class partitioning. The input domain is divided into several classes or divisions using this approach. This is predicated on the assumption that software will react consistently for test data from the same classes. As a result, testing for one input per class ensures that all other potential inputs in that class are covered. The test cases for each class are then created.

For example: Consider a password field in a software application that accepts a minimum of 7 characters and a maximum of 12 characters.

After analyzing the above situation we can make 3 partitions: 0-6, 7-12, 13-17

Decision-Based Table Testing

A decision table often called a cause-and-effect table, is a tool for creating test cases. It gave you a tabular representation of the inputs and predicted results to see how the system reacts to various input combinations. It offers a systematic technique to construct test conditions and improves test coverage when input is used to determine the software's conclusion.

For example: The development of software that guarantees that only genuine persons get the covid-19 vaccination.

Rule - 'Only anyone over the age of 60, or anybody over 45 with a history of diabetes or hypertension, should be permitted to get vaccinated.'

Decision-Based Table Testing


Also read  V Model in Software Engineering

State Transition Testing

The program is assumed to have a limited number of states in this method. The reactions to the actions of the users determine whether the Application Under Test (AUT) is in one state or another. This method enables the tester to enter action-based input conditions, allowing them to test the AUT's behavior. To assess system behavior, both positive and negative input values are offered.

For example: Consider an ATM system function in which the account is locked if the user enters an incorrect password three times.

In this system, if the user inputs a correct password in any of the first three attempts, he or she will be successfully signed in. If the user enters an incorrect password on the first or second attempt, he or she will be prompted to re-enter the password. Finally, if a user enters a wrong password for the third time, the account will be banned.

                                                         State Transition Diagram

 

In this diagram, anytime the user enters the right PIN, he is moved to the Access granted state; if he enters the incorrect password, he is moved to the next try; and if he does the same for the third time, the account is banned.

Error Guessing Testing

This strategy is based on personal experience. Its success is mainly determined by the test analyst's degree of expertise and understanding of software testing and its functionality and behavior. Using their expertise, knowledge of edge situations, and exception scenarios in the program flow, the tester predicts potential problems. The approach counts a list of potential faults or sections of the program prone to errors. For these circumstances, the tester creates test cases. As a result, the tester may utilize this method to develop test cases based on previous experience.

For example: Consider there is a software application and in that application, there is a required field where the user has to enter the mobile number and there are some constraints on that field. Constraints are that 

  1. The mobile should be numerical
     
  2. It should be of 10 digits

 

Now, here comes the use of the error guessing technique

In this technique, the tester will analyze the corner cases such as

  1. What would be the result if the field is left blank?
     
  2. What would be the result if less than 10 digits are entered?
     
  3. What would be the result if any non-numeric character is entered?

Example of a Test Case Template

Test Case ID: TC001
Test Case Name: Verify Login Functionality
Test Case Description: This test case verifies the functionality of the login feature.
Test Steps:
1. Launch the application.
2. Navigate to the login page.
3. Enter valid username and password.
4. Click on the login button.
5. Verify that the user is successfully logged in.
Expected Result: After step 5, the user should be redirected to the home page with access to authenticated features.

Types of Test Cases

  1. Functional Test Cases: These test cases validate the functional requirements of the software application, ensuring that it performs as expected.
  2. Integration Test Cases: Integration test cases verify the interaction between different modules or components of the software to ensure they work together seamlessly.
  3. User Interface Test Cases: These test cases focus on testing the graphical user interface (GUI) of the application to ensure it is user-friendly and visually appealing.
  4. Performance Test Cases: Performance test cases assess the speed, responsiveness, and stability of the software under various load conditions to ensure it meets performance requirements.
  5. Security Test Cases: Security test cases assess the security features of the application to identify vulnerabilities and ensure that sensitive data is protected.
  6. Regression Test Cases: Regression test cases are executed to ensure that new changes or updates to the software do not negatively impact existing functionalities.

Process to Write Test Cases

  1. Requirement Analysis: Understand the requirements thoroughly to identify the scope and functionalities to be tested.
  2. Test Scenario Identification: Define test scenarios based on the requirements to cover various aspects of the software.
  3. Test Case Design: Create detailed test cases for each identified scenario, including steps to execute, expected results, and any preconditions.
  4. Test Case Execution: Execute the test cases systematically, recording the actual results and any deviations from the expected behavior.
  5. Defect Reporting: Report any defects or issues encountered during test case execution, including detailed steps to reproduce the problem.
  6. Test Case Maintenance: Update test cases as needed to reflect changes in requirements or application functionality, ensuring they remain relevant and effective.

Frequently Asked Questions


What is a Test Design Technique?

A test design technique is a systematic approach used to derive test cases from requirements. It includes methods like Equivalence Partitioning, Boundary Value Analysis, and Decision Table Testing to ensure comprehensive test coverage.

What are the 7 Principles of Testing?

The seven principles of testing are:

  1. Testing shows the presence of defects.
  2. Exhaustive testing is impossible.
  3. Early testing saves time and money.
  4. Defect clustering occurs.
  5. Pesticide paradox: Repeated tests become less effective.
  6. Testing is context-dependent.
  7. Absence of errors fallacy: Finding no errors does not mean the system is defect-free.

What are the Three Common Types of Tests?

The three common types of tests are:

  1. Unit Tests: Testing individual components or modules in isolation.
  2. Integration Tests: Verifying interactions between integrated components.
  3. System Tests: Evaluating the entire system's functionality and performance as a whole.

Conclusion

In this article, we discussed what test case designing is and discussed different techniques of test case designing. It is critical to comprehend the importance of creating effective test cases to assure the success of the software testing process. We've gone through the five main strategies for creating effective test cases in a nutshell. The tester, the company, and the user will benefit from identifying and selecting the most suitable test case design approach.

Software quality must be a necessity, not an exception, for a successful software development company. Consider how software quality may affect a company's bottom line.I hope that after reading this article you have gained some knowledge about this topic of test case designing and I am sure that this knowledge will help you. If you want to learn more about such interesting topics, you can look at our platform Coding Ninjas Studio

Recommended Readings:

Thank you for reading.

Live masterclass