HomeTesting Concepts

What is Unit Testing?

What is Unit Testing?

<<Previous Post                              << Complete Tutorial>>                                 Next Post>>

What is Unit Testing?

Unit Testing is one of the levels of Software Testing, where the testing is performed on the isolated smallest units of Software Application programs. Unit in Unit Testing is nothing but the smallest piece of software code which is testable. Examples of a Unit in programming are methods (also known as functions, procedures), classes and interfaces. So the goal of Unit Testing is to isolate the smallest portion of application code which can be individually tested and verify all the isolated units are developed correctly.

Unit Testing & Software Testing Levels: Testing in Software Development Life Cycle is performed in four stages (i.e. Testing Levels – Unit Testing, Integration Testing, System Testing and Acceptance Testing). Unit Testing is one of the four testing levels, which is performed first during the development stage of the required Software Application. Remaining Testing Levels will be performed after Unit Testing.

Unit Testing is generally performed by the Software Developers who are involved in developing the required Application. Few times the other peer Developers will also perform the Unit Testing. Very fewer times, the independent software testing team will be assigned to perform the Unit Testing.

 

In Unit Testing, a set of valid inputs will be provided to a Unit of code to verify the expected values are returned. And also, a set of invalid inputs will be provided to a Unit of code to verify how the code is handling the failures (i.e. A proper error message should be returned).

 

Importance of Unit Testing: The below are different points which state the importance of performing Unit Testing in the Software Development Life Cycle:
  • > The cost of the defects identified and fixed during Unit Testing is very less compared to the cost of the defects which are later identified and fixed during the later high levels of testing phases.
  • > With Unit Testing, defects are identified at the early stages of Software Development Life Cycle, which result in the reduction of bug fixing cost along with time.
  • > As part of regression testing, the Unit Tests can be automated and run every time along with the UI automated, when the changes are made to the application code.
Recommendations for performing Unit Testing: The below are few recommendations which need to be followed while performed Unit Testing:
  • > Though Unit Testing can be performed manually, they are generally automated for repetitive execution of Unit Test for each and every change, as part of regression testing.
  • > Based on the programming language, Unit testing frameworks like JUnit, TestNG, NUnit etc. can be used in creating Automation Frameworks for creating Automated Unit Tests.
  • > With the help of mocking, we isolate the Units by removing their need for interacting with any external dependent methods or services by simulating their behavior.
  • > Frequent and continuous execution of Unit Testing is recommended for achieving the higher quality of the software build.
  • > Defects identified during Unit Testing must be fixed there itself, without allowing them to move into the other testing phases like Integration testing etc.

Next Steps:

  • > To learn more about Software Testing, continue to the next post (Click on the Next Post link below)
  • > Check complete Software Testing Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Arun Motoori 

<<Previous Post                              << Complete Tutorial>>                                 Next Post>>

On a mission to help the Software Testing Community in all possible ways.

 

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp