Test Case Design: A Guide for QA Engineers With Examples
What is Test Case Design?
The test case design is a document that Quality Analysts prepare to define the testing strategy and scope and provide other details such as testing prerequisites, test steps, postconditions, and expected results. It also covers the different variables used by the team to compare the expected and actual results and determines if the product meets the requirements. The objective is to create maximum testing coverage to identify potential defects and bugs in the software to fix.
The Different Types of Tests
Before we understand how to design a test case, it's important to know the different types of tests conducted to evaluate the performance of the software.
The tests are broadly categorized into formal and informal test cases. In formal tests, the preconditions and testing data are defined and detailed. So, the testing only validates if the outcome is as expected. The informal tests do not have any preconditions or testing data. There are no known inputs, so the output remains unknown too. QA engineers discover the outcomes as they test. Here are a few common types of tests that the QA engineers perform while testing the software.
The integration test evaluates if the different systems can communicate with each other efficiently and if they work well when combined with an application.
The UI tests help determine if the user interface is functioning as expected. These tests mainly focus on the visual elements of the web and mobile applications. The aim is to understand if the interface is easily accessible to users. For example, the QA team can check if the user can view the images or menus correctly on different devices like laptops and mobile phones. It also helps in checking cosmetic inconsistencies and grammar or spelling errors.
Usability testing can be formal or informal, depending upon the method used. The goal of usability testing is to find out the end user's perspective. It helps determine if the end-user can use the software without difficulty and complete the intended action. Usability testing helps find the issues that stop the end user from using the software.
Performance testing helps the QA engineers assess the system's performance under various conditions like stress, load, spike, and scalability. Each performance test reveals how the system will respond to different conditions in the real world. For example, the test measures the maximum number of users a system can accept before crashing.
Security tests identify the system's vulnerabilities and determine if the system can protect the data and other software assets from common types of threats and risks. Different types of security tests, such as penetration and vulnerability testing, help the QA engineers identify and solve the problem before the system is live.
Database testing involves evaluating if the database stores the data according to data privacy laws like GDPR and industry laws. It also helps test other crucial factors, such as unauthorized access to the database.
The functionality tests evaluate if a certain functionality succeeded or failed to perform the expected action within the system. For example, the QA engineers can test if the login function allows the user to log in to the system successfully.
SUGGESTED READ -
The Different Types of Test Case Design Techniques
Test case design techniques allow QA engineers to design better test cases, reduce the number of test cases to be executed, and increase testing coverage.
Specific-Based Techniques (Black Box Techniques)
These are designed based on the external features of the software, such as the requirement specification or technical design. Following is the categorization of the specific-based technique:
Boundary value analysis (BVA)
It helps to identify errors at the boundaries of the defined input values. It bases itself on the principle that if the system works well for particular values, it will work well for all values between the two boundary values.
Equivalence partitioning (EP)
In this technique, the input data partitions into several classes with equal data, and the test cases are made for each class.
Decision table testing
Also called the cause-and-effect table, in this technique, the QA engineer has to create a table of all kinds of inputs and corresponding outputs to ensure that the different functions respond to the combination of inputs and events.
State transition diagrams
In essence, this testing allows the QA engineers to test the behavior of an application under test (AUT). The engineer uses various input conditions in a sequence to determine if it changes the state of the AUT. This test case is helpful for systems having a specific workflow. For example, this approach will prompt the user to re-enter the pin correctly if they enter it incorrectly the 1st or 2nd time. On 3rd attempt, the system could direct the user to the access granted or account blocked state depending upon whether they have entered the pin correctly or incorrectly.
Use case testing
In this type of testing, the engineer executes different types of business scenarios and end-user functionalities to find a test case that can cover the entire system.
Structure-Based Techniques (White Box Techniques)
These types of test cases concentrate on the internal structure of the software. The developers test every module and minute detail of the application code while designing the test case. Following is the categorization of the structure-based technique:
Statement coverage testing
In this technique, all the executable statements in the source code execute at once. This helps calculate the number of statements executed out of the total number of statements in the source code.
Decision testing coverage
In this technique, one of the branches from each decision point is executed at least once to determine if it leads to any unexpected behavior in the application.
Condition testing thoroughly tests all the conditions in the source code to ensure that they are error-free.
Multiple condition testing
In multiple condition testing, the different combinations of conditions are tested at once to ensure 100% test coverage.
All path testing
All path testing helps find out all the possible executable paths and faults in a particular code by using the source code.
In essence, this technique is majorly based on the QA teams' experience. The testing outcome depends on the testers' skills, intuitions, and experience. Following is the categorization of the experienced-based technique:
In error guessing, the engineers predict the errors based on their experience, skills, intuition, and the available data set.
Exploratory testing proceeds without documentation, mainly because of the shortage of time. The test case design and execution occur simultaneously.
How To Plan and Design Test Cases?
Prepare the Test Environment
To run the tests in an environment, the QA engineers must prepare the environment. This means they would require testing software like test data generators, debuggers, emulators and stimulators, and stubs and drivers. They would also require hardware to run the tests. The QA engineers must document the hardware specifications and the software versions regularly to ensure a record is available for future reuse.
Determine the Scope of the Test Case
Test case design begins with determining the scope. The stakeholders need to provide the requirements for testing. These requirements could be design specifications, use cases, the usability of the software, etc. The requirements are the source of truth, and they form the foundation for designing test cases.
Design the Test Case
Once the scope is defined, and the test environment prepared, the QA engineers determine the best testing strategy for the test cases. They start creating test cases for each software requirement to ensure that it meets all the specifications.
The test case must include both positive and negative sides, i.e., it must document the software's behavior in positive and negative situations to demonstrate that the software is thoroughly tested and performs the expected behavior. The test case document must be as detailed as possible. It could be in any format but must contain information such as:
- Test case ID: It is a unique id for the test case that makes it distinguishable.
- Test description: Describes the units, features, and functionalities being tested and verified.
- Testing conditions: Describes the purpose and conditions under which the test was executed.
- The assumptions and preconditions: Describe the conditions to meet before test execution.
- Testing steps: Describe the engineer’s steps to execute the test.
- The input test data: Describes the variables and values used for testing.
- The expected results: Describes the results expected from testing.
- The actual and postcondition results: Describes the output that was derived during testing. Postconditions explain what happens when the steps are executed.
- Pass/Fail status: If the expected and actual results match, the engineer marks the status as ‘Pass.’ Otherwise, the engineer marks it as ‘Fail.’
What Are the Best Practices for Test Case Design?
Here are a few best practices that QA engineers can implement while designing a test case.
- The test case must precisely describe the steps the QA engineer must follow and the outcomes they could expect. Therefore, keep the steps simple and below 10-15. Write it in a simple language so that anybody with access to the documentation can understand the test cases. Ensure that each test case displays only one expected result. Include a unique test case ID if the same steps are followed to execute other test cases. Every test case should be easily identifiable.
- Use different testing techniques like BVA and EP to get 100% testing coverage. Even if the goal of 100% testing coverage is hard to achieve, the aim should be to test as many functionalities as possible to detect and fix bugs and errors.
- Always remember to update the test cases with new requirements. This will help other QA engineers to understand and execute them in the future and modify the document if required.
- Always stick to the scope of testing. Refer to the software requirement specification document to understand the features and functionalities to be tested. Stick to the actual requirement rather than allowing assumptions or intuitions to guide the process.
- Use an AI-powered automation tool to write and manage test cases. This will help the QA engineers to track and maintain test cases efficiently.
A Test Case Design Is Crucial for Building Good-Quality Software
Without a well-crafted test case design, the QA engineers will not be able to test the software efficiently. They will have little or no visibility on testing coverage, which could lead to poor-quality software filled with defects and bugs. QA engineers must spend enough time designing a test case to ensure that the software is safe and ready to be released in the market.