Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Unit testing is the first and also the micro level of testing.

It involves testing individual modules or


units to make sure they are working properly. It helps in verifying internal design, internal logic,
internal parts and also error handling.

The main goal of Unit Testing is to segregate. It isolates the smallest piece of the testable software
from the remainder the code and determines if or not it behaves exactly as we expect.

In many cases, it is executed by the developers themselves before handling the software over to
Testing Team.

The Unit can be a line a code, a method or a class or some sort of program or a part of app program.
So, it can be anything we want.

Smaller the unit test the better. Smaller tests give us much more granular view of how our code is
performing at basic level.

Tests can run very fast when the units are smaller.

A Benefit - it can run every time a piece of code is changed so that way we can resolve if there are
any errors very quickly. Since, we divide the code into modules here, we can use the code and
testing becomes much easier and efficient and the product is well versed in the market.

Algorithm

1.Start writing of test

2.Add test to the test suit

3.then, run the unit test

If the test passes, we add 1 more test or add it to the next level of testing.

in case of test fails, necessary changes should be made and run the unit test again.

If it fails again, repeat the cycle until the code is perfectly working and result meets our requirement.

4. Suppose, After the changes made, test passes then we can add it to the test deck and move it on
to next level of testing.

Benefits of Unit testing in Software development site

 Makes coding process more agile and simple - when we add more and more features to
software, we sometimes need to change the old design and the code. Its both risky and
extremely costly. Running unit tests can demonstrate code completeness.
 Improves the quality – identifies every defect that may have come up before the code is sent
further for further testing. Writing tests before coding actually makes us think harder about
the problem. Exposes the edge cases and makes us write better code. The code that we have
written is divided into modules that becomes reusable.
 Helps find software bugs easily – as unit testing is carried out by developers. It makes the
completion earlier and doesn’t impact any other pieces of code. Team minimises software
risk and avoids spending too much money and time.
 Facilitates changes and simplifies integration – Allows programmers to refactor codes and
upgrade system libraries that later date and makes sure that the module is still working
properly. Also verifies the accuracy of each unit, afterwards the units are integrated into an
app by testing parts of the app via unit testing.
 Provides documentation to developers- by encouraging better coding practices and also
leaving behind the piece of code that describe what the program is actually going to achieve.
Debugging easier and faster.
 Helps create better software designs
 Reduces testing costs – as the bugs are found early and reduces the cost of fixing that.

Properties
Easy to write – cause developers write lot different cases to cover different aspects of app
behaviour. Write that without much effort.
Easily Readable – Intent should be clear. Easy to understand which scenario is being tested
Reliable – only fail if there is a bug. Independent from external factors
Faster and Efficient – if slow might affect the final product

Best Unit Testing Frameworks


C# - NUnit – belongs to XUnit family and its written entirely in C#.

Java – Junit, TestNG – opensource unit testing framework for a test-driven environment called TDD
(supports the core concept of first testing then coding. Data is 1 st tested and then inserted in the
piece of code. It also offers annotations and test method identification.

C & C++ - EmbUnit – open source designed for software app written in C or C++.

JavaScript – HtmlUnit, Junit, TestNG – supports GUI features like forms, links, tables, etc. Offers an
open source Java library which contains GUI, less browser for Java programs. Supports also cookies,
submit methods like posts and proxy server

You might also like