t-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University
2 Introduction Understand how Agile Software practices can be used in a scripting language environment Develop a unit test framework for Tcl and a plug-in for Eclipse to have a central location to develop Tcl projects Create a project that is open source Final Presentation Introduction Updated: 05-Dec-2006
Loyola Marymount University3 Related Work Final Presentation Related Work Updated: 05-Dec-2006 Kent Beck – Extreme Programming Explained
Loyola Marymount University4 Related Work Final Presentation Related Work Updated: 05-Dec-2006 Martin Fowler – Continuous Integration, Refactoring
Loyola Marymount University5 Related Work Final Presentation Related Work Updated: 05-Dec-2006 Andrew Hunt and David Thomas – The Pragmatic Programmer
Loyola Marymount University6 Related Work Final Presentation Related Work Updated: 05-Dec-2006 John Ousterhout –Tcl Scripting Language
Loyola Marymount University7 State of Software Development Final Presentation State of SW Development Updated: 05-Dec-2006 Need to get away from plan-driven approach Start with a vision and a set of principles
Loyola Marymount University8 Agile Principles Continual Refinement Working Product at All Times Continual investment in and emphasis on Design Value defect prevention over defect detection Final Presentation Agile Principles Updated: 05-Dec-2006
Loyola Marymount University9 Design and Documentation Keep the design simple UML offers a wide variety of tools to document the design Extraction software such as JavaDoc can be useful for documenting software Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University10 The Customer Always have the customer's input when creating software Responsible for the requirements Ability to pick which features are most important, and therefore, should be developed first Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University11 Coding Conventions Makes the code easy to read, especially if a new team member arrives Ray Johnson of Sun Microsystems created a Tcl style guide for the Tcl programming language Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University12 Paired Programming Paired programmers are only 15% slower than two independent individual programmers, but produce 15% fewer bugs. - Dr. Laurie Williams NC State University Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University13 Paired Programming Final Presentation Agile Practices Updated: 05-Dec-2006 There are downsides to paired programming
Loyola Marymount University14 Code Reviews A combination of paired programming and code reviews will lead to better defect prevention There are downsides of code reviews without paired programming Typically logic errors are missed Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University15 Iterative and Incremental Development “Plan a little, do a little, learn a little.” By developing the software incrementally, the software can stay in a releasable state Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University16 Continuous Integration Frequent integration insures that modules that must fit together will Automate the build with unit tests to detect errors as soon as possible A single source repository keeps the necessary items for a build together Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University17 Sample Test Target <!-- < Define the test target (runs the unit tests) Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University18 Refactoring Refactoring can improve the structure of code without changing its behavior Martin Fowler wrote a whole book on refactoring and offers wide variety of refactorings available Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University19 Unit Testing Prevents defects from ending up in software Gives confidence that the product is behaving as expected “t-unit” was developed to be a better unit test framework for Tcl Final Presentation Agile Practices Updated: 05-Dec-2006
20 Sample Test Case TUnit Process Model Test Case File Description Updated: 27-Oct-2006 t-unit::assertEquals | PASS| OK t-unit::assertEquals"hello“"hello”| PASS| OK t-unit::assertEquals"hello“"world“| FAIL| NOT_EQUAL t-unit::assertEquals2 2| PASS| OK t-unit::assertEquals23| FAIL| NOT_EQUAL t-unit::assertEquals | PASS| OK t-unit::assertEquals | FAIL| ARG_MISMATCH t-unit::assertEqualsTRUETRUE| PASS| OK t-unit::assertNotEqualsTRUEFALSE| PASS| OK t-unit::assertNotEquals“hello”“world”| PASS| OK t-unit::assertEqualsList{1 2 3}{1 2 3}| PASS| OK t-unit::assertEqualsArrayA1A2| PASS| OK t-unit::assertEquals [samplePackage::addOne 1] 2| PASS| OK Final Presentation Test Case File Description Updated: 05-Dec-2006 Make the appropriate assert call What the user is testing Expected result Expect pass or failure Return value from assert call
Final Presentation “Class” Diagram Updated: 05-Dec-2006 File Test Suite Report «creates» «examines» Procedure Package Under Test Expression «calls» «input, expected» Test Case + reason: String Test ResultPassFail «result» {complete, discrete} Package t-unit t-unit::assertXXXX «abstract» t-unit::testHarness «calls» t-unit::assertEquals t-unit::assertEqualsReal t-unit::assertEqualsList t-unit::assertEqualsArrayt-unit::assertNotEquals t-unit::assertFalse t-unit::assertTrue «test function» «reads» «writes» user «runs»
Use Available Tools Final Presentation Agile Practices Updated: 05-Dec-2006
Loyola Marymount University23 TUnit TUnit is a plug-in for the Eclipse IDE. TUnit makes use of the t- unit package that was developed for the Tcl programming language. Features: Tcl Perspective Tcl Project Wizard Tcl Package Creator Tcl File Creator Tcl File Editor Preferences menu Namespace Explorer Execution of t-unit scripts A set of unit tests is also available to test the TUnit plug-in Final Presentation TUnit Updated: 05-Dec-2006
Loyola Marymount University24 Demonstration Final Presentation Demonstration Updated: 05-Dec-2006
Loyola Marymount University25 TUnit Extension The Eclipse Dynamic Languages Toolkit (DLTK) Xored Software Inc. was behind the plug-in and they are developing the project in Russia Eclipse DLTK did not include a unit test framework as part of the plug-in Final Presentation TUnit Extension Updated: 05-Dec-2006
Loyola Marymount University26 Demonstration Final Presentation Demonstration Updated: 05-Dec-2006
Loyola Marymount University27 Future Research The future of TUnit and the TUnit extension is still up in the air TUnit extension could see additional revisions Final Presentation Future Research Updated: 05-Dec-2006
Loyola Marymount University28 Acknowledgements I would like to thank the many people who inspired and assisted me for the past couple of years. The LMU faculty for acting as a guide Especially Dr. Dionisio for dealing with me every semester I have been here BJ Johnson for the idea to create t-unit and the TUnit plug-in And my classmates for always bringing my ego back to earth Final Presentation Acknowledgements Updated: 05-Dec-2006
Loyola Marymount University29 Conclusions Agile makes development easier Design and develop for today Self testing code Automate the process as much as possible Keep the customer in the loop Not all the practices need to be followed: come up with a set that fits the team’s needs Perhaps start with unit testing t-unit and the TUnit plug-ins are being used by other Tcl developers today Recently helped a user setup their development environment Final Presentation Conclusions Updated: 05-Dec-2006
Loyola Marymount University30 Source Code TUnit has a homepage at: Project can be downloaded from here along with documentation and screenshots Source code repository for the paper, this presentation, TUnit and the TUnit unit tests at: Eclipse DLTK considering putting the extension of TUnit in their next milestone release Final Presentation Source Code Updated: 05-Dec-2006
Loyola Marymount University31 Questions? Final Presentation Questions? Updated: 05-Dec-2006