university of sunderland cse301 advanced object-oriented software developmentunit 1 test-driven...
TRANSCRIPT
![Page 1: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/1.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Test-Driven DevelopmentTest-Driven Development
CSE301
University of Sunderland
Dr. Giles Oatley
![Page 2: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/2.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
SourcesSources
• Fowler, 2000, Refactoring: Improving the Design of Existing Code, Addison-Wesley.
• http://www.amazon.com/exec/obidos/tg/detail/-/0321109295/103-4060125-0311065
• http://www.amazon.com/exec/obidos/ASIN/0130648841/103-4060125-0311065
• http://www.refactoring.com/catalog/• http://www.win.ua.ac.be/~lore/refactoringProject/index.php
• Extensive discussions on the comp.object newsgroup.
![Page 3: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/3.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
TopicsTopics
• Test-Driven Development
• JUnit
• Refactoring– Principles– Bad Smells in Code– A Catalog of Refactorings
![Page 4: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/4.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Test-Driven Test-Driven DevelopmentDevelopment
• The test-driven development is the method of software development where tests specify interfaces of implementation and all code must have passed the tests. (Wikipedia)
![Page 5: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/5.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Test-Driven Test-Driven DevelopmentDevelopment
Roughly:1. Write a test for a bit of functionality.2. Show that it fails.3. Write the code to make the test pass.
Additionally. 1. Do not write production code until there is a failing test.2. Write the simplest possible production code to get the test
to pass.3. Do not write more tests when we have a failing test.4. Do not add to a failing test.
![Page 6: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/6.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Further CommentsFurther Comments
• If you watched someone doing TDD you would see them oscillating between test code and production code once every minute or so.
• During each oscillation the programmer would add a few lines to his test code, thus making it fail (or not compile) and then add just a few lines to his production code in order to make the test pass (or compile).
• Each oscillation is so simple that it's not worth taking. • Each oscillation is so simple that the risk of error is close to
zero. • If you walk into a room of people working this way, and
chose anyone at random, a minute ago all his code would have been working.
![Page 7: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/7.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Working with JUnitWorking with JUnit
IMPORTANT TUTORIAL WORK
• Eclipse version (at least) 3.0.• Download and install the examples.• Create a JUnit project. Read the test examples provided for
ideas.• Open the properties for your project. Go to Project
References and select the JUnit project.• Create an AllTests class for your project to run your test
suite.• Create appropriate unit test classes and insert them in your
test suite.
![Page 8: University of Sunderland CSE301 Advanced Object-Oriented Software DevelopmentUnit 1 Test-Driven Development CSE301 University of Sunderland Dr. Giles Oatley](https://reader036.vdocuments.mx/reader036/viewer/2022083009/5697bfc61a28abf838ca75d7/html5/thumbnails/8.jpg)
University of Sunderland CSE301 Advanced Object-Oriented Software Development Unit 1
Eclipse and TDDEclipse and TDD
• Work through the Eclipse-JUnit tutorial at: http://www.onjava.com/pub/a/onjava/2004/02/04/juie.html