Monday, October 24, 2016

Unit Testing | David Tzemach

QA - Unit Testing


תוצאת תמונה עבור ‪unit test‬‏
Unit testing, is a process of testing the smallest available methods of code that can be tested (Units), during the testing process, the developer will use a set of inputs (Negitive and Positive) per function that will help him to understand if there are any logical errors, Failures and eventually to approve the behavior of the function against the preliminary requirements and design

A unit test are performed by the development team (Without a QA is interfering) and considered as “White” box testing. The importance of UNIT tests in the SDLC is critical, because it used by developers to validate that their functions are working correctly after creation and in any other scenario where the code is modified in advanced phases of the software development life cycle.

In addition, Unit tests are the first layer of testing used in the software testing process (Prior to component and integration tests).

Unit testing Advantages

Performed by developers
The tests are performed by developers that possess a Different state of mind from the one that testers use during the regular testing cycles (Black Box testing). 

This state of mind, will help the Eng. Team (who understands the behavior and outcomes for each testing unit) to add an additional layer of functional tests that will increase the confidence in the software prior to moving it to the next testing phase (Component).

Automated tests
The main and probably the biggest benefit in UNIT tests, is that all tests are automated, therefore the tests can be re- used when the code is modified, this will help to determine if the functionality is working as it was prior to the new code.

Simplify the debugging process
When performing unit tests, the developer will examine the functionality of the smallest testable part of code, therefore it will make it easy to debug each test in case of a failure.

Reduces Costs
It’s a known fact that the cost of software defects increases in each phase of the software development life cycle (SDLC). Unit tests are the first testing layer in the SDLC and as such it can help us to remove defects that can appear in older phases of the project.


Software Testing Phase Where Bug Found
Estimated Cost per Bug
System Test
Integration Test
Full Build
Unit Test / Test Driven Development

Increases the Confidence in the written code
Executing unit tests is a great tool for developers to gain confidence in their code, just think that each code change could be examined quickly and after the engineer already knows the previous testing outcomes. In addition, writing tests and executing them allowing the developer to gain additional knowledge about the logical structure of the code.

Unit testing limitations

Unit testing coverage
Unit tests can cover only the functional aspects of the tested code, it cannot provide any indication about other aspects such as User Interface, Usability and many more criteria’s that we need to test to validate that the software is working based on the preliminary requirements and specification.

Complexity of the test
UNIT test is used to test a small part of code, you cannot use it to test complex scenarios that you will cover on advanced phases of the SDLC.

Tests maintenance 
When working with methods that frequently changed (Like complex algorithms) the maintenance of the tests can cause massive investment both in time and money.

Unit Testing Life Cycle

Phase1: Picking the requirements
Every development starts with SRS design that determine the client/Company requirements. In this phase the developer already acknowledged with those requirements and can start the development.of the application.

Phase 2: implementing the code
There are two different approaches that developers can use, the first option is to write the code and then design the unit tests, the second option is to write the tests prior to writing the code using the Test Driven development (TDD).

Phase 3: Executing the tests
After both code and test cases are implemented, it’s now the time to run the tests and search for defects in you code.

Phase 4: Code modifications and re- execution
Based on the outcomes of the previous phase, the developer can modify the code and re-run the tests again.

1 comment:

  1. Thanks for sharing this informative content that guided me to know the details about the training offered in different technology.
    qtp training in chennai


My Presentations