Is unit testing functional or non-functional testing?
Before we can discuss on Unit testing lets have some time to review on different between Functional and Non Functional Testing
|Functional Testing||Non Functional Testing|
|Functional Testing is a type of software testing in which the system is tested against the functional requirements. Functions are tested by providing some input and examining the output.||Non – functional testing is a type of software testing to check the performance, reliability, usability of the software application. It is designed to test the readiness of the application which is never considered by functional testing. For example How many users can log in to a website at a single time.|
|Different Types of Functional testing are Unit testing, Integration testing, Smoke testing, Usability testing, User acceptance testing, System testing, Regression testing.||Different types of Non-functional testing are Performance testing, scalability testing, Load testing, Endurance testing, Security testing, Stress testing, Compatibility testing.|
|Functional testing is a type of testing which requires information about the source code.||Non-Functional type of testing does not require information about the source code.|
Glimpse on Unit Testing:
The main objective of Unit testing is to verify small pieces of code, individual functions/algorithm, alone and combined. Unit tests are mostly written by the developer by keeping in mind that it should be fairly simple to write. A unit tests should essentially just give the function that’s tested some inputs, and then check what the function outputs are correct. Unit test and coding are dependent on each other, if the code is poorly designed, writing of unit test could be difficult.
Unit testing has a vital role in integration tests or functional tests for regression testing. By running unit test each and every bug at all level either that is in API or in code can be caught. Many times there’s been a particularly troublesome piece of code which just keeps breaking no matter how many times we fix it. So the unit test is also great for preventing regressions – bugs that occur repeatedly due to small code change.
Here are a few points by which it can prove Unit testing is a kind of functional testing:
- Code Level Testing: Testing of small piece of code can be conducted by unit testing and it’s a part of functional testing
- API Level Testing: As we know, API is also considered as a vital role in any application nowadays so unit test also can be performed on API level
- Testing of individual Function/Algorithm: Small function and algorithm testing can be performed by a unit test.
- To fix bug early in the development cycle
- To help for code reuse.
Author : Prateek