EGV - Module5 SE 102
EGV - Module5 SE 102
College
MODULE 5
Subject:
Software Engineering 2
This material has been developed in support to the College Program implementation.
Materials included in this module are owned by the respective copyright holders. AISAT College
– Dasmariñas, the publisher and author do not represent nor claim ownership over them.
This material will be reproduced for educational purposes and can be modified for the
purpose of translation into another language provided that the source must be clearly
acknowledged. Derivatives of the work including creating an edited version, enhancement or a
supplementary work are permitted provided all original works are acknowledged and the
copyright is attributed. No work may be derived from this material for commercial purposes and
profit.
Unit Test Driven Development (TDD)
Module Test Driven Development (TDD)
SE 101 Software Engineering 2 Units: 3.0 Page |1
Test Driven Development (TDD) is software development approach in which test cases are developed to
specify and validate what the code will do. In simple terms, test cases for each functionality are created
and tested first and if the test fails then the new code is written in order to pass the test and making
code simple and bug-free.
Test-Driven Development starts with designing and developing tests for every small functionality of an
application. TDD framework instructs developers to write new code only if an automated test has failed.
This avoids duplication of code. The TDD full form is Test-driven development.
The simple concept of TDD is to write and correct the failed tests before writing new code (before
development). This helps to avoid duplication of code as we write a small amount of code at a time in
order to pass tests. (Tests are nothing but requirement conditions that we need to test to fulfill them).
Test-Driven development is a process of developing and running automated test before actual
development of the application. Hence, TDD sometimes also called as Test First Development.
• TDD ensures that your system actually meets requirements defined for it. It helps to build your
confidence about your system.
• In TDD more focus is on production code that verifies whether testing will work properly. In
traditional testing, more focus is on test case design. Whether the test will show the
proper/improper execution of the application in order to fulfill requirements.
• In TDD, you achieve 100% coverage test. Every single line of code is tested, unlike traditional
testing.
• The combination of both traditional testing and TDD leads to the importance of testing the
system rather than perfection of the system.
• In Agile Modeling (AM), you should “test with a purpose”. You should know why you are testing
something and what level its need to be tested.
Advantages of TDD
Following are the main advantages of Test Driven Development in Software Engineering:
• Early bug notification.
• Developers test their code but in the database world, this often consists of manual tests or
one-off scripts. Using TDD you build up, over time, a suite of automated tests that you and
any other developer can rerun at will.
• Better Designed, cleaner and more extensible code.
• It helps to understand how the code will be used and how it interacts with other modules.
• It results in better design decision and more maintainable code.
• TDD allows writing smaller code having single responsibility rather than monolithic
procedures with multiple responsibilities. This makes the code simpler to understand.
• TDD also forces to write only production code to pass tests based on user requirements.
• Confidence to Refactor
• If you refactor code, there can be possibilities of breaks in the code. So having a set of
automated tests you can fix those breaks before release. Proper warning will be given if
breaks found when automated tests are used.
• Using TDD, should results in faster, more extensible code with fewer bugs that can be
updated with minimal risks.
• Good for teamwork
• In the absence of any team member, other team members can easily pick up and work on
the code. It also aids knowledge sharing, thereby making the team more effective overall.
• Good for Developers
• Though developers have to spend more time in writing TDD test cases, it takes a lot less
time for debugging and developing new features. You will write cleaner, less complicated
code.
References:
- What is Test Driven Development (TDD)? Tutorial with Example (guru99.com)
PERFORMANCE OBJECTIVE: After completing this activity, you should have a deeper understanding
on the basic concepts of test driven development.
TOOLS AND MATERIALS: Pen and paper
EQUIPMENT:
CRITERIA SCORING
Did I . . .
1 2 3 4 5
1. Correctly explained by answer, in a comprehensive manner?
2. Create a document without grammatical flaws?
3
TEACHER’S REMARKS: ❑ QUIZ ❑ RECITATION ❑ PROJECT
GRADE:
5- Excellently Performed
4- Very Satisfactorily Performed
3- Satisfactorily Performed
2- Fairly Performed
1- Poorly Performed
_______________________________
TEACHER
Date: ______________________