Sanity testing plays a key role early in the SDLC by allowing teams to address functional issues before moving on to deeper testing, ultimately improving software quality and saving time.
Overview
What is Sanity Testing?
Sanity Testing is a type of software testing performed after smoke testing to verify that minor changes or bug fixes haven’t introduced new defects.
Purpose of Sanity Testing
The purpose of Sanity testing is to ensure the core functionality remains intact before proceeding with more extensive testing.
Attributes of Sanity Testing
- Narrow and Deep Focus
- Subset of Regression Testing
- Unscripted
- Not Documented
Benefits of Sanity Testing
- Rapid Problem Detection
- Early Rejection of Faulty Builds
- Identification of Missing Dependencies
- Focused Verification
- Quick Feedback Loop
- Effective in Time-Constrained Scenarios
- Risk Mitigation
- Cost-Effective
In this guide, you will learn all about sanity testing in detail, covering its attributes, features, working, objectives, benefits, implementation, and more.
What is Sanity Testing?
Sanity Testing is a type of software testing performed after smoke testing to verify that minor changes or bug fixes haven’t introduced new defects. Its purpose is to ensure the core functionality remains intact before proceeding with more extensive testing.
Sanity Testing or Surface Level testing is a type of testing which is performed on the stable build of the software. It is a quick and basic test (or set of tests) to ensure that the code changes made are working properly without any bugs. It is a subset of Regression testing and is usually executed after the software product has passed the Smoke test.
Features and Attributes of Sanity Testing
To understand the fundamentals of sanity testing, it’s essential to recognize its key attributes and components. Here are some crucial aspects of sanity testing:
- Narrow and Deep Focus: Sanity testing is characterized by its targeted approach, concentrating on specific components to ensure their proper functioning after changes.
- Subset of Regression Testing: It acts as a subset of regression testing, primarily focusing on less critical parts of the application. Sanity testing verifies whether new features align with the requirements.
- Unscripted: Typically, sanity testing is conducted in an unscripted manner, allowing testers to explore functionalities without predefined test cases.
- Not Documented: This type of testing is often informal and may not be documented, emphasizing its quick and adaptive nature.
- Conducted by Test Engineers: Sanity testing is performed by test engineers who assess the software’s stability and readiness for further testing.
- Simple: Easily designed and performed.
- Comprehensive: Covers the basic assessment of how software behaves.
Objectives of Sanity Testing
The main objectives of Sanity testing are:
- Defining the planned features works as expected.
- Saving time, complexity, and costs in case the sanity test fails for a build.
- Ensuring that the new updates don’t change the software’s existing functionalities.
- Validating the accuracy of the newly added components and features.
Read More: How to test UI components?
Process of Sanity Testing
The Sanity testing process has the following steps:
1. Identification
In this step, newly added features and components are detected. Also, the modification presented in the code is detected while bug fixing.
2. Evaluation
These newly implemented components and attributes are analyzed and modified to check whether they work as intended as per the given requirements.
3. Testing
A smaller section of the newly linked components is tested deeply. The test will fail if these newly introduced components do not fulfill their requirements. If it meets the need, the Sanity test is passed. Next, System testing is performed thoroughly to ensure that these functionalities do not interfere with the previously installed system and application components.
When should Sanity Testing be conducted?
Sanity Test should be performed in the following cases:
- If there is a minor change in the code.
- When the build is received after a number of regressions.
- After bug fixes.
- Before production deployment.
Frequency to perform Sanity Test
The frequency of performing Sanity Testing will rely on the Software Requirement Specification (SRS) and the software development stage. However, here’s a general frequency at which Sanity testing can be conducted:
- After every build: Sanity testing can be done as and when a new build is received to verify if the new code has affected the core functionality, before moving forward with extensive testing.
- Before Regression Testing: You can perform sanity tests before executing a full regression suite to ensure build stability.
- In Agile/ Continuous Integration environments: If your team follows Agile or CI/CD practices, sanity tests can be automated. They can be triggered daily or whenever a new build is received to verify if the basic functionality is intact.
How to Perform Sanity Testing
Here are the steps to perform sanity testing:
- Analyze the Change: Before you start testing, go through the release notes, bug fix list, or change log. Analyze what has been changed or fixed and which modules or features were affected.
- Spot Critical Functionality: Once the changes are analyzed, accordingly decide the core functionalities or modules that require quick verification. Don’t go for full coverage, focus on the affected areas.
- Prepare Test Cases: Sanity testing may not require detailed documentation. However, you can note down the basic test scenarios to verify successful login, proper navigation of pages etc.
- Execute the Tests: Execute the chosen test cases either manually or via automation.
- Analyze Results: If your tests pass, you move forward with deep testing. However, if they fail, you will have to reject the build and send it back for fixes.
Read More: How to Write Test Cases for Login Page
Different Ways to Perform Sanity Testing
Sanity testing can be performed in two different ways:
- Manual Sanity Testing: In this method, the QA team manually executes test cases or exploratory checks. Here, the focus is on verifying the functionalities that were fixed or updated. Manual sanity testing does not require detailed documentation. It is ideal for small projects and early-stage startups.
- Automated Sanity Testing: In this approach, the core functionalities are validated via automated scripts. They are usually integrated into CI/CD pipelines. This method saves time and reduces the risks of human errors during repetitive checks. Automated testing is best suited for Agile and DevOps environments and in projects that has frequent builds and deployments.
Sanity Testing Example
Consider you developing an online Food ordering app, and you want to offer a 10% discount on New Year (1st January) for your members having an elite membership.
Sanity testing will verify the following:
- Elite members get the discount on the 1st January.
- Members, who add the elite membership to their food orders on the 1st, also get the discount.
- Non-elite members do not get the discount on the 1st January .
- No member receives that rebate before and after the 1st January.
- Other discount coupons can not be clubbed together with this 10% discount.
- Elite members, who opt for other deals, do not get the New Year deduction.
Sanity testing does not verify other areas of the app, like delivery tracking or restaurant reviews. That is done by Smoke testing and Regression testing, which happen before and after Sanity testing.
If Sanity testing fails, the app is sent back to the developer for troubleshooting. However, if it succeeds, the app is sent for thorough System testing.
Sanity vs Smoke: Differences
Sanity testing and smoke testing are key software testing methods. Smoke testing checks a new build’s overall stability and critical functionality, while sanity testing verifies specific features after changes to ensure they work correctly. Smoke testing has a broader scope, whereas sanity testing is focused and targeted.
Feature | Sanity Testing | Smoke Testing |
---|---|---|
Purpose | To verify that specific functionalities work correctly after changes or bug fixes. | To ensure that the overall build is stable enough for further testing. |
Focus | Targets specific components or features that have been modified. | Checks the basic functionality of the entire application. |
Execution | Conducted without predefined test cases, often informally. | Can be executed manually or automated, typically with a set of predefined test cases. |
Scope | Narrow scope, focusing only on areas impacted by recent changes. | Broad scope, encompassing the application’s core functionalities. |
Stability Requirement | The software must be relatively stable for testing. | The software can be stable or unstable; it serves as an initial check. |
Documentation | No formal documentation or test scripts are typically created. | Test documents and scripts are often generated for future reference. |
Testing Phase | Usually conducted after smoke testing to validate specific fixes. | Performed after each new build to verify overall stability. |
Type of Testing | Subset of regression testing. | Subset of acceptance testing. |
Read More: Sanity Testing vs Smoke Testing
Sanity Testing Tools
Here are the best Sanity Testing tools you can use:
- Cypress: This modern end-to-end testing framework facilitates quicker sanity testing of web applications, especially single-page applications (SPAs). It is a developer-friendly tool and runs directly in the browser.
- Selenium: The popular open-source framework, Selenium, can be used to build automated sanity test scripts and run them on various browsers to validate core functionalities after every build.
- Playwright: Playwright is a good option for cross-browser sanity checks and supports various browsers like Chromium, Firefox, and WebKit.
- Appium: Appium is an open-source tool for mobile applications. It enables the automation of sanity tests on Android and iOS devices. Appium is a great option if you want to ensure that mobile-specific features don’t break after a new build.
Read More: Best Test Automation Frameworks
Benefits of Sanity Testing
Sanity testing offers several advantages that enhance the efficiency and effectiveness of the software testing process:
- Rapid Problem Detection: It helps in quickly identifying defects in the core functionality of the software, ensuring that critical issues are addressed early.
- Time Efficiency: Sanity testing can be completed in a shorter time frame since it typically does not require extensive documentation or formal test cases.
- Cost-Effective: Compared to other testing methods, sanity testing is less expensive and resource-intensive, making it a budget-friendly option for evaluating new builds.
- Early Rejection of Faulty Builds: If significant defects are found during sanity testing, the project can be rejected early, saving time and effort that would otherwise be spent on regression testing.
- Identification of Missing Dependencies: It assists in spotting missing objects or dependencies that may affect the application’s functionality, reducing the risk of issues in later testing phases.
- Focused Verification: Sanity testing verifies specific functionalities to ensure they work as expected after changes, allowing teams to concentrate on the most critical areas of the application.
- Quick Feedback Loop: This testing method provides immediate feedback on the software build’s overall functionality, enabling teams to swiftly address any critical issues.
- Increased Confidence: By confirming that essential functions are operational before proceeding to more extensive testing, sanity testing boosts confidence in the software’s quality.
- Improved Productivity: Sanity testing allows developers and testers to focus on more complex testing scenarios by validating critical functionalities early, thus enhancing overall productivity.
- Effective in Time-Constrained Scenarios: In situations where testing time is limited, sanity testing helps ensure that the most important functionalities are operational without requiring extensive testing efforts.
- Risk Mitigation: Early detection of issues through sanity testing helps mitigate risks associated with software releases, contributing to a smoother deployment process.
- Supports Agile Practices: Sanity testing aligns well with agile methodologies, facilitating quick iterations and continuous integration by providing timely validation of changes.
Challenges and Solutions of Sanity Testing
Sanity testing, though a helpful approach, does come with a few challenges like:
- Limited Scope: Sanity tests might not identify all the potential issues in an application. It sometimes delivers false positives, i.e, the application might seem to work properly, but in reality, it will break or fail in other test environments.
- Time Constraint: Sanity tests are usually conducted under strict time constraints, making it difficult to test an application properly.
- Limited Test Environment: In sanity testing, not all the test cases or scenarios are covered. Instead, only a few selected cases with recent changes or fixes are considered. This will be done in a limited, controlled environment, which may not reflect real-world software setup.
Solutions
You can address the above challenges of the sanity test with the following solutions:
- Make it a point always to create a test plan and then analyze the Software Requirement Specification (SRS) of applications before conducting sanity testing.
- First, align the sanity test with a test strategy. You can combine rigorous testing with a sanity test or regression testing. This will help you conduct tests to understand how the application functions accurately.
- Document the testing process, detect the bug or errors and notify the development team to address the issue before the application is releases.
Read More: How to find Bugs in Software?
Test on Real Devices for Accurate Results
Sanity testing is essential for determining whether further testing is necessary for a software application, helping to save time and effort by quickly identifying critical issues. It provides immediate feedback on the release status, enabling teams to plan subsequent actions efficiently. To achieve accurate results, it’s important to test on real devices and browsers, as this simulates actual user conditions and effectively uncovers bugs. BrowserStack Live facilitates rapid sanity testing for web applications.
Benefits of using BrowserStack Live for Sanity Testing
Here are the core benefits of using BrowserStack to perform Sanity Testing:
- Extensive Device Coverage: Access over 3500+ real device-browser combinations to ensure comprehensive compatibility across various platforms.
- Real-World Testing: Simulate actual user environments to identify potential issues and verify that critical functionalities perform as expected.
- Rapid Testing Experience: Eliminate the need for physical devices, enabling quick assessments of your software’s functionality and stability.
- Immediate Feedback: Receive quick updates on the status of your application, allowing for efficient planning of subsequent testing actions.
- Mobile App Testing: Conduct thorough sanity tests on real iOS and Android devices with BrowserStack App Live, ensuring new features and bug fixes function correctly.
- Streamlined Process: Optimize your testing workflow, saving time and effort while enhancing the quality of your software.
By leveraging BrowserStack Live, you can ensure your software performs optimally in real-world scenarios, leading to a better user experience.
Sanity Testing Best Practices
Here are the best practices of sanity testing that you can follow:
- Ensure you test features related to the recent bug fixes or code changes. Do not waste time on unrelated modules.
- Automate your sanity tests for repetitive checks, especially in CI/CD pipelines. This will save time and reduce human errors.
- To avoid false positives, ensure you run your sanity tests in a stable, reliable environment.
- Maintain an updated sanity test set to align with new changes and evolving functionalities.
Conclusion
Sanity testing focuses on determining whether more testing is necessary for a software application. It is crucial because it saves a lot of time and effort when any issue in the system is discovered. Sanity tests also give a quick update on the progress of the release so that the next set of actions can be planned accordingly.
However, it is important to test on real devices and browsers, taking real user conditions into account for more accurate test results. This will help in identifying how the app function in real-world conditions, especially in finding bugs. BrowserStack Live helps in performing a quick Sanity test for web apps on 3500+ real device-browser combinations. While BrowserStack App Live allows you to perform Sanity testing on mobile apps across real devices on iOS and Android platforms.