Basics and types of testing
Tags: functional, nonfunctional, unittest, performance
Published: 2023-10-23 12:59:22

**In this blog, we’ll see the basics of testing. We’ll also cover some of the differences between functional and non-functional testing and some of the types of both functional and non-functional testing. **

**Importance of Testing**

Human errors can cause a defect or failure at any stage of the software development life cycle. It makes the software more reliable and easier to use. A thoroughly tested software ensures reliable and high-performance software operation compared to without testing the software.


**Functional and Non-Functional Testing**
Firstly, we will discuss functional testing and its types and an example of functional testing.

- **Functional Testing**
In functional testing, we make sure that the functionality of the software meets the business requirements. We prepare tests to specifically focus on the business use cases. This means we prepare a set of inputs and the expected outputs and test the software/application for accurate results. 

Functional testing mainly focuses on the software program for user interface, APIs, database, client/server connection, and many other features. Functional testing can be performed manually or through automation.

Functional testing mainly focuses on recognizing the test input of test data based on the requirements. Calculating the predicted results by using the input data and executing the test cases. Finally, compare the real and predicted results.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i2fcyjmtm0ccjs7o1pq0.png)

** Types of Functional Testing**

1. Unit Testing
Unit testing is the “white box” approach to testing the functionality of the code against the requirements. We write tests to check if the written code works correctly. As a result, we can cover the defects and report those at the earliest phase of the Software Development Lifecycle.

As soon as a new feature is developed, we can write the unit tests in parallel to check that the feature works as expected even in unexpected scenarios. Unit testing can be done by developers/testers.

Unit testing will be done to validate the smallest possible unit of code such as a function or any conditions.

2. **Integration Testing: **

Integration testing is a method of testing how different units or components of a software/application interact with each other. It is used to identify and resolve any issues that may arise when different units of the software are combined. Integration testing is typically done after unit testing. We will verify that the individual modules and components work as efficiently after the integration as they do independently.
3. **System Testing: **
 We will test the whole application (complete/integrated software is tested) by a tester. We verify all the desired outputs for a specific set of inputs.

The order of the testing is firstly we perform the Unit testing, Integration Testing, and then System Testing. It is a type of Black-box testing. With the help of a Software requirement document along with the test cases, this testing will happen. the system testing will be done from the perspective of the end user whether the requirements are matched.

**4. Acceptance Testing: ** 
It is a level of software Testing in which software is tested for user acceptance.
→ It can be done by QA or clients.
  UAT is done at the client side where software is actually used. 
→ Alpha Testing: Done by the tester in the company in the presence of the customer.
→ Beta Testing: done by the customer to check software is okay and satisfies the requirement. 
Note: We covered some of the important types of testing. Apart from the above, we have some other functional testing techniques like regression testing, sanity, smoke testing., etc.

Example for the functional testing:

To understand the different types of functional tests, here’s a test scenario for different kinds of functional testing techniques.

Test Scenario:

An online student portal on which 
1. The user logs in with their Register No and password. The login page has two text fields for Register No and password. It also has two buttons – Login and Cancel.
2. After successful login it should have a home screen. On the home screen, the attendance tracker and list of holiday options should be there.  
- Attendance tracker - The tracker has every month's attendance and average attendance throughout the year.
- List of holidays - This is a PDF file with the list of holidays in the current year.

Unit testing:
Here, I am explaining by taking an example for the first functionality.
module1:
Tc1: With the correct register no and password 
TC2: With the incorrect register number and correct password
TC3: With the correct register number and incorrect password
TC4: With the incorrect register number and incorrect password

In the above test cases, only TC1 should pass, for the remaining test cases, it should through the appropriate error.

Integration testing:
Assume that after login functionality, the developer has developed the only home screen.

Here we will verify after successful login it is redirecting to the home screen. We will open the portal in different browsers, in incognito mode, and check whether the user is able to log in and access the home screen.

In the integration testing, we should concentrate more on the new addon functionality that causes any errors/defects to an existing functionality.  
System testing:
- Here we will execute all the test cases (positive and negative) after deployment for every module with respect to SRS. 
- Here we will check if any texts or buttons are placed in the right place.  
- Also, we will concentrate on whether their loading icon is placed (UI should communicate to the user to wait/process icons when there is a delay in fetching the data/while opening another tab.

- **Non-Functional Testing**
We generally execute the non-functional testing after functional testing. In non-functional testing, we focus on the system such as performance, usability, reliability, and scalability. It ensures that the user gets the best experience while using the software. Non-functional tests are as important as functional tests since they help us understand how the system behaves under certain circumstances.

Non-functional testing targets the expectations of the customer. Non-functional testing can improve the product's reliability, performance, manageability, and accessibility.

Types of Non-functional tests:

- **Performance testing: ** Performance testing, is a non-functional testing technique performed
to determine the system parameters in terms of responsiveness and stability under
various workloads. Performance testing measures the quality attributes of the system,
such as scalability.

**- Response time testing: **
Response Time Testing measures the time taken for one system module/API/Node to respond to the request of another.

**Load Testing: ** Load testing is carried out to determine the behavior of a system under extreme load

**Stress Testing: ** Stress Testing is done to check the robustness of the system under the
varying loads.

**Scalability Testing: ** Scalability Testing can be done to check the performance of a
software application or system in terms of its capability to scale up or scale down the
number of user request loads.

Note: Other Non-Functionality Testing types of Volume Testing, Security Testing, Localization Testing., etc.
Example:
With the same example as functional requirements.
Non-functional requirements from the customer:
1000 active users, loading speed: 1 sec, Fetching the data: 2 secs.

We will test through tools like J-meter, postman., etc. the above testing required.

For the active users, we will perform the performance testing and load testing by increasing the active users from 10 to 1000 and calculating the average time. 

To test the loading speed, we will note when the request happened and when we get a response for the respective action performed by the user.

We will test how much time it is taking to fetch the attendance over 3 months/6 months.

**Conclusion: **

In this blog, we learned the purpose of functional and non-functional testing. We also learned various types of functional and non-functional testing. Lastly, we explored the functional and non-functional testing techniques with examples.
Functional testing is performed using the functional specification provided by the client and verifies the system against the functional requirements.
Non-functional testing checks the Performance, reliability, scalability, and other non-functional aspects of the software system.