1. Aim: Implement TDD for their given case study
2. Objectives: From this experiment, the student will be able to,
● Learn to study software development process that relies on the repetition of a
very short cycle
● Learn software test driven development tobringquality software
3. Outcomes: The learner will be able to,
● An ability to match the industry requirements in the domains of software
development.
● An ability to have leadership and management skills to accomplish a common
goal.
4. Hardware / Software Required: Any Text editor, Open source tool
5. Theory:
Test-driven development (TDD) is a software development process that relies on the
repetition of a very short development cycle: first the developer writes an (initially
failing) automated test case that defines a desired improvement or new function, then
63
produces the minimum amount of code to pass that test, and finally refactors the new
code to acceptable standards.
1. Add a test
In test-driven development, each new feature begins with writing a test. To write a
test, the developer must clearly understand the feature’s specification and
requirements. The developer can accomplish this through use cases and user stories to
cover the requirements and exception conditions, and can write the test in whatever
testing framework is appropriate to the software environment.
2. Run all tests and see if the new one fails
This validates that the test harness is working correctly, that the new test does not
mistakenly pass without requiring any new code, and that the required feature does not
already exist. This step also tests the test itself, in the negative: it rules out the
possibility that the new test always passes, and therefore is worthless. The new test
should also fail for the expected reason. This step increases the developer’s confidence
that the unit test is testing the correct constraint, and passes only in intended cases.
3. Write some code
The next step is to write some code that causes the test to pass. The new code written
at this stage is not perfect and may, for example, pass the test in an inelegant way.
That is acceptable because it will be improved and honed in Step 5.
At this point, the only purpose of the written code is to pass the test;
4. Run tests
If all test cases now pass, the programmer can be confident that the new code meets
the test requirements, and does not break or degrade any existing features. If they do
not, the new code must be adjusted until they do.
5. Refactor code
The growing code base must be cleaned up regularly during test-driven development.
New code can be moved from where it was convenient for passing a test to where it
more logically belongs. Duplication must be removed. Object, class, module,
variable and method names should clearly represent their current purpose and use, as
extra functionality is added. As features are added, method bodies can get longer and
other objects larger. There are specific and general guidelines for refactoring and for
creating clean code. By continually re-running the test cases throughout each
refactoring phase, the developer can be confident that process is not altering any
existing functionality.
Repeat
Starting with another new test, the cycle is then repeated to push forward the
functionality.
64
6. Procedure:
Develop at least 1 TDD based on their case study from above description .
7. Conclusion:
Test-driven development offers the ability to take small steps when required. It allows
a programmer to focus on the task at hand as the first goal is to make the test pass.
Exceptional cases and error handling are not considered initially, and tests to create
these extraneous circumstances are implemented separately
8. Viva Questions:
● What is Test driven development?
● How to apply TDD to any project?
9. References:
1. www.amazon.com › Books › Computers & Technology › Programming
2. www.eecs.yorku.ca/course…/2003…/KentBeck_TDD_byexample.pdf
3. searchsoftwarequality.techtarget.com › … › Programming
4. technologyconversations.com/…/test-driven-development-tdd-example
StudyMumbai.com is an educational resource for students, parents, and teachers, with special focus on Mumbai. Our staff includes educators with several years of experience. Our mission is to simplify learning and to provide free education. Read more about us.
GET INSTANT HELP FROM EXPERTS!
- Looking for any kind of help on your academic work (essay, assignment, project)?
- Want us to review, proofread or tidy up your work?
- Want a helping hand so that you can focus on the more important tasks?
Hire us as project guide/assistant. Contact us for more information
Leave a Reply
You must be logged in to post a comment.