DEV Community

Thirunavukkarasu arunagiri
Thirunavukkarasu arunagiri

Posted on

Functional and Non-Functional testing with examples:

Image description

Functional Testing:

Function testing, also known as functional testing, is a type of software testing that focuses on verifying that a specific function or feature of a software application works correctly according to its specifications. The primary goal of function testing is to ensure that the software performs the functions it was designed to perform and to identify any deviations from expected behaviour.

Here are some key points about function testing:

Objective: It aims to validate that the software functions or features are working as intended and meeting their requirements.

Black-Box Testing: Function testing is typically a black-box testing method, meaning that testers do not need to know the internal code or structure of the software. Testers focus on inputs, outputs, and the behaviour of the system.

Test Cases: Test cases are designed based on the functional specifications and requirements of the software. These test cases encompass various scenarios and use cases to check the software's behaviour under different conditions.

Validation: It ensures that the software functions correctly for valid inputs, produces the expected outputs, and handles erroneous inputs gracefully by providing appropriate error messages or responses.

Test Automation: Function testing can be automated to a significant extent, making it more efficient and repeatable, especially in cases where the software has frequent updates or releases.

Tools: Various testing tools are available for function testing, helping testers create, execute, and manage test cases more effectively.

Here are some of the most common types of functional testing:

Unit Testing: Unit testing involves testing individual components or modules of the software in isolation. The goal is to ensure that each unit (e.g., functions, classes, methods) behaves as expected. Unit tests are typically automated and help identify bugs early in the development process.

Integration Testing: Integration testing verifies that different components or modules of the software work together as a whole. It checks for interactions between units to ensure that data flows correctly, and interfaces between components are functioning as intended.

System Testing: System testing is performed on the complete software system to verify that it meets its specified requirements. It focuses on end-to-end testing and ensures that all integrated components work together seamlessly. System tests often include functionality, performance, security, and other criteria.

Acceptance Testing: Acceptance testing determines whether the software meets the acceptance criteria defined by stakeholders, such as clients or end users. It can be further divided into two types:

User Acceptance Testing (UAT): Conducted by end users to validate that the software satisfies their business needs and works as expected.

Alpha and Beta Testing: These are pre-release tests where the software is tested by a select group of users (alpha) and a wider audience (beta) to identify any issues before the final release.

Smoke Testing: Smoke testing is a preliminary test that checks whether the software build is stable enough for more extensive testing. It focuses on the critical features to ensure that the basic functionality works.

Sanity Testing: Sanity testing is similar to smoke testing but is performed to verify that specific new functionality or bug fixes have been correctly implemented. It's more focused and less comprehensive than smoke testing.

Functional Regression Testing: This type of testing ensures that recent changes or updates to the software haven't introduced new defects or caused regressions in existing functionality. It involves rerunning functional test cases to identify any unexpected side effects.

Compatibility Testing: Compatibility testing checks how the software performs on various platforms, browsers, and devices. It ensures that the software works as expected on a wide range of environments.

Localization Testing: Localization testing verifies that the software functions correctly when adapted for different languages, regions, and cultures. It ensures that the user interface, date formats, currencies, and other aspects are culturally appropriate.

Globalization Testing: Globalization testing is broader than localization testing. It checks whether the software can be adapted for various cultures and regions without code changes. It focuses on the overall design and architecture.

Accessibility Testing: Accessibility testing assesses whether the software is accessible to people with disabilities. It ensures that the application is usable by individuals with various impairments, such as vision, hearing, or motor disabilities.

Security Testing: Security testing evaluates the software's ability to protect data, maintain the confidentiality and integrity of information, and resist unauthorized access or attacks. It includes various tests like penetration testing, vulnerability scanning, and more.

Here's an example of functional testing for a simple e-commerce website:

Scenario: Functional Testing of the "Add to Cart" Feature

Test Objective: To verify that users can successfully add products to their shopping cart.

Test Steps:

Open the Website: Open the e-commerce website and navigate to the homepage.

Search for a Product: Use the website's search bar to find a specific product (e.g., "Smartphone").

Select a Product: Click on a product from the search results to view its details.

Add to Cart: Click the "Add to Cart" button on the product details page.

Verify Cart Icon: Check if the cart icon in the top right corner of the website updates to show the number "1" (indicating that one item is in the cart).

View Cart: Click on the cart icon to view the shopping cart.

Verify Added Product: In the shopping cart, verify that the selected product is displayed with the correct name, price, and quantity (which should be "1").

Proceed to Checkout: Click the "Proceed to Checkout" or "Checkout" button.

Enter Shipping Information: Fill in the shipping information fields on the checkout page.

Select Payment Method: Choose a payment method (e.g., credit card, PayPal) from the available options.

Submit Order: Click the "Submit Order" or "Place Order" button.

Verify Order Confirmation: After completing the order, verify that a confirmation page or message appears, confirming the successful placement of the order.

Expected Results:

At each step, the corresponding action should work without errors.
The cart icon should update to "1" after adding a product.
The product in the shopping cart should match the product details, and the quantity should be "1."
The checkout process should proceed without any issues.
An order confirmation should be displayed at the end.

Pass Scenario:

The test is considered to have passed if all the steps are executed without any errors or deviations from expected behaviour, and the final order confirmation is displayed.

Fail Scenario:

The test is considered to have failed if any of the steps encounter issues, such as not being able to add a product to the cart, incorrect information in the shopping cart, errors during the checkout process, or the absence of an order confirmation.

Functional testing helps ensure that essential features of the e-commerce website, like adding products to the cart, work correctly, providing a smooth user experience and preventing potential issues that could negatively impact customers.

Non-Functional Testing:

Non-functional testing, also known as quality attribute testing, is a type of software testing that assesses the non-functional aspects of a software application. Unlike functional testing, which focuses on whether the software functions correctly, non-functional testing evaluates how well the software performs, its reliability, scalability, usability, and other characteristics that do not pertain directly to its functional behaviour.

Non-functional testing is essential to provide a well-rounded view of a software application's quality and performance. These tests help identify issues related to performance, security vulnerabilities, usability problems, and more. They are typically conducted alongside functional testing to ensure a comprehensive evaluation of the software's capabilities and characteristics.

Non-functional testing is critical to ensure that a software application not only meets its intended functionality but also delivers a high-quality user experience.

Here are some common categories of non-functional testing:

Performance Testing: Performance testing evaluates how well the software performs under various conditions, such as high user loads, heavy data volume, and stress. Types of performance testing include:

Load Testing: Measures the software's performance under expected user loads.

Stress Testing: Determines the software's stability and robustness under extreme conditions.

Scalability Testing: Assesses the application's ability to scale with increased user loads.

Reliability Testing: This type of testing checks the software's ability to perform consistently and reliably over time. It involves testing for fault tolerance, failure recovery, and error handling.

Usability Testing: Usability testing assesses how user-friendly the software is and whether it meets the needs and expectations of its intended users. It includes aspects like user interface design, navigation, accessibility, and overall user experience.

Security Testing: Security testing focuses on identifying vulnerabilities and weaknesses in the software's security measures. It includes tests like penetration testing, vulnerability assessment, and authentication testing.

Compatibility Testing: Compatibility testing ensures that the software works correctly on various platforms, browsers, and devices. It addresses issues related to operating system compatibility, browser compatibility, and mobile device compatibility.

Scalability Testing: Scalability testing assesses the software's ability to handle increasing workloads and data volume while maintaining performance and responsiveness.

Maintainability Testing: Maintainability testing evaluates how easy it is to maintain and update the software. It assesses factors like code readability, modularity, and the ease of making changes.

Backup and Recovery Testing: This type of testing assesses the ability of the software to back up data and recover from data loss or system failures.

*Here's an example of non-functional testing *

Performance testing:

Scenario: Performance Testing of an E-commerce Website

Test Objective: To evaluate the performance of an e-commerce website when subjected to different types of load and stress conditions.

Test Types:

Load Testing: This type of performance testing assesses the website's response time and behaviour under expected load conditions. Here's how load testing might be conducted:

Test 1 - Normal Load: Simulate a normal user load on the website by having a certain number of users browse products, add items to their carts, and proceed to checkout. Measure response times and ensure the website handles this load without performance issues.

Test 2 - Peak Load: Simulate a peak user load, perhaps during a festive sale day, to see how the website responds. Measure response times, verify that the server doesn't crash, and monitor resource utilization.

Stress Testing: Stress testing evaluates the website's behaviour under extreme conditions to determine its breaking point.
For example:

Test 3 - Stress Load: Gradually increase the user load until the system reaches its breaking point. Observe how the system behaves when it's overloaded, including error handling and recovery.

Scalability Testing: Scalability testing assesses the system's ability to scale and handle increased loads gracefully:

Test 4 - Scalability: Start with a small load and gradually increase it. Observe how the system scales, whether additional resources are allocated, and whether performance remains acceptable as the load grows.

Expected Results.

In normal load conditions, the website should respond quickly, with acceptable response times.
During peak load, the response times may increase slightly, but the system should remain responsive and not crash.
Under stress load, the system may show signs of slowing down, but it should not crash or produce critical errors.
During scalability testing, the system should effectively allocate resources to handle increased load without performance degradation.

Pass Criteria:

The website should meet the expected results without severe performance degradation or system failures. It should gracefully handle different load levels, demonstrating its scalability and robustness.

Fail Criteria:

The test fails if the website crashes, becomes unresponsive, or produces critical errors under any of the test scenarios.
Performance testing, in this case, is a crucial non-functional test to ensure that the e-commerce website can handle different levels of load, including peak load and stress conditions, without compromising user experience or system stability. This testing helps identify performance and provides insights into system behaviour under varying loads.

Top comments (0)