The Ultimate Guide to Sanity Testing
When a team working on a SaaS product hands over a new testing build containing bug fixes and new features to the quality assurance (QA) team, the QA team must assess its stability quickly before committing to extensive regression testing.
To achieve this, the QA team performs a quick surface-level check of key functionalities to ensure the build’s stability. This crucial initial check is known as sanity testing.
Sanity testing is a narrow and focused testing approach used to verify that specific functionalities work correctly after minor changes or bug fixes. It confirms that the reported issue is fixed and that no new problems have been introduced in the affected areas.
Unlike exhaustive regression testing, the sanity test cycle is limited in scope and time-efficient. It is performed when a quick confidence check is needed before further testing or deployment. This helps catch bugs in impacted areas early without extensive regression cycles.
In this guide, we’ll explore the ins and outs of sanity testing, compare it with other testing methods, outline its key functionalities, and provide practical examples to illustrate its importance.
TL;DR
- It helps prevent new issues from reaching users and ensures a smooth release.
- Sanity testing is a quick test cycle that ensures bug fixes or new features work as expected before conducting detailed testing.
- It saves time by testing only the key areas affected by the change.
Table of Contents
- What is Sanity Testing
- Comparing Sanity Testing & Other Testing Types
- Functionality of Sanity Testing
- What are the Crucial Aspects of Sanity Testing?
- What is the Sanity Testing Process?
- Examples of Sanity Testing
- Advantages of Sanity Tests
- Drawbacks of Sanity Testing
- Best Practices for Effective Sanity Testing
- Final Thoughts
What is Sanity Testing
Sanity testing is a software testing approach that determines whether the software’s core functionality works as intended after changes are made to the code. After a new code version is deployed, it is performed to confirm that the changes have not negatively impacted existing features and functionality.
It is also called surface-level testing because it emphasises checking the system’s logic without examining its complexities. Contrary to regression testing, which is performed after the release code is frozen, sanity testing is performed iteratively on each incremental build throughout the agile sprints.
Sanity testing is often confused with smoke testing, which focuses on the whole application rather than core functionality. It is the best approach when time is short and high-risk fixes need testing, whereas smoke testing is conducted when the entire application needs testing quickly.
Explore our article highlighting the key differences between sanity and smoke testing to understand the two testing approaches.
The main objectives of the sanity test cycle include:
- Verifying existing functionality: Checking that new code changes, including ones that stem from bug fixes, don’t impact existing features.
- Saving time and resources: Reducing complexity and expenses by identifying problems early.
- Ensuring stability: Assessing whether specific functionality impacted by code changes is stable enough for further testing.
- Validating new features: Verifying the accuracy and value of newly introduced features.
A sanity assessment should be carried out under the following scenarios:
- Following minor adjustments to the code.
- Following the completion of bug fixes.
- Before deploying the software to production.
Example:
Consider a SaaS-based school management platform teachers use to manage student attendance, grades, and schedules. A bug was reported where student attendance didn’t update correctly after submission. Developers fixed the issue and also made an enhancement so teachers can now mark attendance for multiple classes in one go.
Before running a complete regression cycle, the QA team performs sanity checks. They log in as a teacher, mark attendance for different classes, save it, and verify that the records update instantly. They also quickly check that the dashboard, class lists, and login features are working without performing in-depth testing.
This ensures system stability for testing further positive, negative, and corner cases.
Comparing Sanity Testing & Other Testing Types
During a release test cycle, testers perform sanity, smoke, regression, integration testing, etc, depending on the available time, resources, and scope of the new changes. Each type serves a unique purpose and helps refine the testing process. Testing teams must understand the difference between these testing approaches to use the right one in each situation.
Let’s understand what each testing type is and how it differs from sanity testing:
Testing type | Purpose | Scope | When it’s performed | Key differences |
Smoke Testing | Verifies end-to-end stability of the build before in-depth testing | Broad, covers all core functionalities of the application | Performed after the build is deployed. Specifically if testing time is limited and cannot cover all regression testing scenarios. | Smoke testing covers the whole application for stability; sanity testing focuses on specific changes/impacted areas. |
Regression Testing | Ensures that new changes haven’t introduced new bugs into existing features. | Comprehensive, covering all functionalities that might be affected by new changes. | Performed after new code changes (new features, bug fixes) are deployed to ensure nothing else is broken. | Sanity testing is a quick check for specific fixes or changes, while regression testing is more thorough. |
Unit Testing | Validates that individual components or units of code work as expected. | Very narrow, focused on individual code functions. | Performed during development by developers. | Sanity testing checks overall functionality, while unit testing focuses on isolated code segments. |
System Testing | Verifies that the entire system, including hardware and software, works as expected. | Comprehensive, involving the entire application in an environment similar to production. | Performed after integration testing, before UAT or deployment. | System testing is broader and more thorough than sanity testing, which checks specific fixes. |
Integration Testing | Ensures different modules or components of the system work together as expected. | Focused on the interaction between modules or components. | Performed after unit testing, during development, or after integrating new features. | Sanity testing is a quick check for specific changes, while integration testing focuses on interactions between modules. |
User Acceptance Testing | Validates that the software meets user requirements and is ready for release. | Broad, covering all features from an end-user perspective. | Performed after system testing, before the software is released to customers. | UAT is focused on user needs and experience, while sanity testing is focused on verifying the stability of specific changes. |
Ultimately, each testing type has a distinct and valuable purpose in the SDLC. Knowing when and how to apply each ensures a high-quality product. For example, for a new application release, sanity testing will be performed during each internal incremental release once all features are merged.
Functionality of Sanity Testing
Sanity testing is integral to the software development lifecycle for several reasons. Here’s a breakdown of its key functionalities:
Integration Check
A sanity test ensures that new code is compatible with an existing system and that recent changes or bug fixes have not negatively affected the integration of different modules or components.
It is important in complicated systems where multiple components must operate together efficiently.
Confirming Bug Fixes
Sanity testing verifies that recent bug fixes work as intended and do not introduce new issues. As a result, the specific defects addressed are fixed without introducing any new bugs.
Resource Optimization
Sanity testing saves time and resources by immediately assessing if a build or specific software functionality is stable enough for further testing after introducing code changes. Identifying key problems early on eliminates unnecessary expanded testing on unstable builds, maximizing the utilization of testing resources.
Check for Regression
While sanity testing is not as comprehensive as complete regression testing, it does contain a preliminary check for regressions to confirm that recent modifications have not negatively impacted existing functionality. This helps ensure the program’s general stability.
Iterative Procedure
Sanity testing is often done iteratively, particularly in Agile and Continuous Integration environments. This means it is done regularly to verify each incremental build, providing stability throughout development.
What are the Crucial Aspects of Sanity Testing?
Sanity testing has several key characteristics that separate it from other types of testing:
- Narrow and Deep: Sanity testing focuses on a limited set of functionalities but tests them in depth. By doing this, we make sure we’re checking specific application areas thoroughly.
- A Subset of Regression Testing: It is considered a subset of regression testing, primarily focusing on verifying that recent changes or bug fixes have not adversely affected the existing functionality.
- Unscripted: Sanity tests are usually unscripted, meaning they do not follow a predefined set of test cases. This allows testers to quickly analyze the software’s functionality based on their understanding and experience.
- Not Documented: Typically, sanity testing is not formally documented. The focus is on quick validation rather than detailed reporting.
- Performed by Testers: Sanity testing is usually performed by testers who understand the application well. Their expertise helps them identify critical issues quickly.
What is the Sanity Testing Process?
Sanity testing is a quick, high-level check to ensure the application is stable enough for more detailed testing. It’s a crucial step in the software development lifecycle to catch any major issues early on.
Here’s a step-by-step overview of the sanity testing process:
1. Identify
In this initial phase, testers identify the new functionalities, features, or bug fixes that have been added to the software. This step involves understanding the scope of changes and determining which parts of the application need to be tested.
2. Evaluate
Next, testers evaluate the impact of the identified changes on the existing system. This involves assessing the areas that might be affected by the new code and prioritizing the critical functionalities that need immediate attention.
3. Test
Finally, testers perform the actual sanity tests. This involves executing focused tests on the identified areas to verify that the new changes work as expected and do not introduce new issues.
The goal is to quickly validate the stability of the build before proceeding with more extensive testing.
Examples of Sanity Testing
Example #1: E-commerce Application
Scenario: An e-commerce platform recently fixed a bug in the checkout process that prevented users from applying discount codes.
Sanity Test:
- Identify: The tester identifies the checkout process and discount code application as the areas affected by the bug fix.
- Evaluate: The tester checks the potential impact on related functionalities, such as cart updates and payment processing.
- Test: The tester performs sanity tests by adding items to the cart, applying various discount codes, and proceeding to checkout. They verify that the discount is correctly applied, the total amount is updated, and the payment gateway functions as expected.
Outcome: The sanity test confirms that the bug fix works and that the checkout process is stable, allowing further detailed testing.
Example #2: Social Media Platform
Scenario: A social media platform has introduced a new feature allowing users to create and share “Stories.”
Sanity Test:
- Identify: The tester identifies the new “Stories” feature as the primary focus.
- Evaluate: The tester evaluates the integration of this feature with existing functionalities, such as user profiles and news feeds.
- Test: The tester performs sanity tests by creating, viewing, and deleting stories. They check if the stories appear correctly in the user’s profile and news feed and if interactions (likes, comments) work as expected.
Outcome: The sanity test ensures that the new “Stories” feature is functioning correctly and does not disrupt other parts of the platform.
Example #3: Banking Software
Scenario: A banking application has updated its interest calculation algorithm.
Sanity Test:
- Identify: The tester identifies the interest calculation module and related functionalities, such as account balance updates.
- Evaluate: The tester evaluates the impact of the new algorithm on other financial calculations and reports.
- Test: The tester performs sanity tests by checking the accuracy of interest calculations for various account types and balances. They also verify that the updated balances are reflected correctly in user accounts and financial reports.
Outcome: The sanity test confirms that the new algorithm calculates interest accurately and that the update does not affect other financial operations.
Advantages of Sanity Tests
1. Time and Effort Saving
Since sanity testing focuses on a limited set of functionalities, it can be performed quickly, saving time and effort. This is particularly useful when there are tight deadlines or limited resources.
2. No Documentation Required
Sanity tests are usually unscripted and do not require extensive documentation. This allows testers to perform quick checks without needing detailed test plans or reports.
3. Early Detection of Defects
A sanity test identifies core functionality issues quickly by focusing on recent changes and bug fixes. The early detection of defects prevents them from spreading later in the development process.
4. Cost-Effective
Sanity testing is less expensive than other testing types because it requires fewer resources and less time. As a result, it is an economical method for verifying minor changes.
5. Quick Validation
The sanity test verifies that the build is stable enough to go through more extensive testing. It helps maintain the quality of the software.
6. Prevents Regression
Sanity testing is not as comprehensive as regression testing, but it helps identify potential regressions caused by recent changes. As a result, new updates will not negatively affect existing functionality.
Drawbacks of Sanity Testing
1. Limited Scope
Since sanity testing focuses on just a few application functions, it may overlook problems in other system components. This restricted focus may result in issues being unnoticed in places that the sanity tests do not cover.
2. Unscripted Nature
Sanity tests are usually unscripted and lack documentation. This makes it challenging to repeat tests or use them as a future reference, and variations in testing might also result from the lack of clear test cases.
3. Not Comprehensive
Certain faults may go unnoticed because sanity testing may not account for all potential test cases or situations. It may miss less evident issues since it is meant to be a rapid check rather than a thorough analysis.
4. Focus on Functions
It primarily focuses on the software’s functions and commands, potentially overlooking other important aspects like performance, security, and user experience. This can result in a false sense of security about the software’s overall quality.
5. Issues in Unchecked Functionalities
Problems in functionalities outside the sanity test scope may go unnoticed, leading to potential risks in the software. This can be particularly problematic in complex systems where changes in one area might affect other application parts.
Best Practices for Effective Sanity Testing
1. Define the Scope
Clearly identify the functionalities and areas of the application that need to be tested. This allows the testing effort to focus on the most critical parts of the software, ensuring that the changes or bug fixes are validated thoroughly.
2. Use Automated Testing
Test automation can be implemented to simplify recurring sanity testing for complex applications and features. Automation can speed up testing, increase accuracy, and allow for parallel test execution, which is particularly useful in continuous integration and delivery environments.
3. Review the Results
After conducting sanity tests, carefully review the results to ensure all identified issues are addressed. This step involves analyzing the test outcomes, verifying that the fixes work as intended, and ensuring that no new issues have been introduced.
Final Thoughts
Sanity testing is a quick check to make sure that certain functions of a software work correctly after some small changes or fixes have been made. It helps catch problems early, making sure the software stays stable and saves time in the long run.
As you’ve learned the ins and outs of sanity testing, compared it with other testing methods, and understood its critical role, it’s important to integrate this process with comprehensive testing strategies.
Testlio offers extensive expertise in integrating sanity tests into broader quality assurance frameworks. We offer comprehensive testing solutions tailored to your needs. Our expert testers ensure that your software remains stable and functional through rigorous sanity testing.
Contact Testlio today to learn more about our sanity testing services and how we can help you achieve your quality assurance goals.