310 likes | 485 Views
t-unit: Tcl Unit Test Package. Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University. Final Presentation Introduction Updated: 05-Dec-2006. Introduction.
E N D
t-unit: Tcl Unit TestPackage Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University
Final Presentation Introduction Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Related Work Updated: 05-Dec-2006 Related Work Kent Beck – Extreme Programming Explained Loyola Marymount University
Final Presentation Related Work Updated: 05-Dec-2006 Related Work Martin Fowler – Continuous Integration, Refactoring Loyola Marymount University
Final Presentation Related Work Updated: 05-Dec-2006 Related Work Andrew Hunt and David Thomas – The Pragmatic Programmer Loyola Marymount University
Final Presentation Related Work Updated: 05-Dec-2006 Related Work John Ousterhout –Tcl Scripting Language Loyola Marymount University
Final Presentation State of SW Development Updated: 05-Dec-2006 State of Software Development • Need to get away from plan-driven approach • Start with a vision and a set of principles Loyola Marymount University
Final Presentation Agile Principles Updated: 05-Dec-2006 Agile Principles • Continual Refinement • Working Product at All Times • Continual investment in and emphasis on Design • Value defect prevention over defect detection Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 Paired Programming • Paired programmers are only 15% slower than two independent individual programmers, but produce 15% fewer bugs. - Dr. Laurie Williams NC State University Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 Paired Programming • There are downsides to paired programming Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 Sample Test Target <!-- < Define the test target (runs the unit tests) < --> <target name=“test” depends=“compile”> <exec dir=“${build.scripts.dir}/unitTests” executable=“tclsh”> <arg line=“unitTestsAll.tcl”/> </exec> </target> Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Agile Practices Updated: 05-Dec-2006 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 Loyola Marymount University
TUnit Process Model Test Case File Description Updated: 27-Oct-2006 Final Presentation Test Case File Description Updated: 05-Dec-2006 Sample Test Case Expect pass or failure Expected result t-unit::assertEquals 12.34 12.34 | PASS | OK t-unit::assertEquals "hello“ "hello” | PASS | OK t-unit::assertEquals "hello“ "world“ | FAIL | NOT_EQUAL t-unit::assertEquals 2 2 | PASS | OK t-unit::assertEquals 2 3 | FAIL | NOT_EQUAL t-unit::assertEquals 12345 12345 | PASS | OK t-unit::assertEquals 12345 12345.0 | FAIL | ARG_MISMATCH t-unit::assertEquals TRUE TRUE | PASS | OK t-unit::assertNotEquals TRUE FALSE | PASS | OK t-unit::assertNotEquals “hello” “world” | PASS | OK t-unit::assertEqualsList {1 2 3} {1 2 3} | PASS | OK t-unit::assertEqualsArray A1 A2 | PASS | OK t-unit::assertEquals [samplePackage::addOne 1] 2 | PASS | OK Make the appropriate assert call What the user is testing Return value from assert call
Test Case Pass + reason: String user Fail Test Result File Expression Final Presentation “Class” Diagram Updated: 05-Dec-2006 Package t-unit «runs» «calls» t-unit::assertXXXX «abstract» t-unit::testHarness t-unit::assertEquals t-unit::assertFalse t-unit::assertEqualsReal t-unit::assertTrue «creates» t-unit::assertEqualsList t-unit::assertEqualsArray t-unit::assertNotEquals Test Suite «reads» «writes» «test function» «result» Package Under Test {complete, discrete} Report «input, expected» «examines» «calls» Procedure
Final Presentation Agile Practices Updated: 05-Dec-2006 Use Available Tools
Final Presentation TUnit Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Demonstration Updated: 05-Dec-2006 Demonstration Loyola Marymount University
Final Presentation TUnit Extension Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Demonstration Updated: 05-Dec-2006 Demonstration Loyola Marymount University
Final Presentation Future Research Updated: 05-Dec-2006 Future Research • The future of TUnit and the TUnit extension is still up in the air • TUnit extension could see additional revisions Loyola Marymount University
Final Presentation Acknowledgements Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Conclusions Updated: 05-Dec-2006 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 Loyola Marymount University
Final Presentation Source Code Updated: 05-Dec-2006 Source Code • TUnit has a homepage at: http://tunitplugin.googlepages.com • 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: http://code.google.com/p/t-unit/ • Eclipse DLTK considering putting the extension of TUnit in their next milestone release Loyola Marymount University
Final Presentation Questions? Updated: 05-Dec-2006 Questions? Loyola Marymount University