1 / 26

t-unit: Tcl Unit Test Package

t-unit: Tcl Unit Test Package. Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University. Final Presentation Introduction Updated: 25-Nov-2006. Introduction.

suchi
Télécharger la présentation

t-unit: Tcl Unit Test Package

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. t-unit: Tcl Unit TestPackage Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

  2. Final Presentation Introduction Updated: 25-Nov-2006 Introduction • Understand how Agile Software practices can be used in a scripting language environment • How Agile practices can be applied in an industry that is big on up-front design • Create a project that is open source Loyola Marymount University

  3. Final Presentation Related Work Updated: 25-Nov-2006 Related Work • Many key players in the Agile movement • Kent Beck • Extreme Programming • Martin Fowler • Refactoring, Continuous Integration • Andrew Hunt and David Thomas • The Pragmatic Programmer • Tcl Scripting Language • Created by John Ousterhout in early 1980’s at Berkeley Loyola Marymount University

  4. Final Presentation State of SW Development Updated: 25-Nov-2006 State of Software Development • Need to get away from plan-driven approach • Can’t see the complexity of the software ahead of time • The culture must be ready for change! • Start with a vision and a set of principles that defines what needs to be accomplished • From these principles we can derive a set of working practices Loyola Marymount University

  5. Final Presentation Agile Culture Updated: 25-Nov-2006 Agile Culture • Disciplined in approach and goal focused • Responsible for one’s work • Leaders that can help others succeed • Highly collaborative team that can embrace differences between personalities and roles and strive for success • Feel comfortable communicating with the team • Keep the product simple to solve only the problem at hand • Courage to speak up when things are going bad Loyola Marymount University

  6. Final Presentation Agile Principles Updated: 25-Nov-2006 Agile Principles • Continual Refinement • Enhances the ability to change with the customer’s needs • Working Product at All Times • The goal of software developers is to ship software. Keep the software as close as possible to a shipping state. • Continual investment in and emphasis on Design • Design decisions and changes are made every day by every member of the team • Extends the life of the product • Value defect prevention over defect detection • Prevent defects to save yourself the headaches later on Loyola Marymount University

  7. Final Presentation Agile Practices Updated: 25-Nov-2006 Design and Documentation • Keep the design simple • Design and code for what is needed today • Consider designing reusable software for future projects • UML offers a wide variety of tools to document the design • Since Tcl is a scripting language, a sequence diagram can typically be used when designing a module • Extraction software such as JavaDoc can be useful for documenting software • Tcl has its own documentation utility known as AutoDOC • Developed by Andreas Kupries in 2001 as an extension to the language Loyola Marymount University

  8. Final Presentation Agile Practices Updated: 25-Nov-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

  9. Final Presentation Agile Practices Updated: 25-Nov-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 • Using these coding conventions in conjunction with the AutoDOC utility makes Tcl source code well commented and easy to read Loyola Marymount University

  10. Final Presentation Agile Practices Updated: 25-Nov-2006 Paired Programming • Paired programming involves two people sitting at one computer where each person can sit comfortably and work can get done. • Keep one another on task • Refine the system • Come up with ideas • When one partner is stuck the other can take over, lowering the stress level • Hold each other responsible for following the other practices the team is following • Downsides of Paired Programming • Watching another person type can be painful • Many companies consider paired programming a waste of a resource Loyola Marymount University

  11. Final Presentation Agile Practices Updated: 25-Nov-2006 Code Reviews • Code reviews in conjunction with paired programming allow for the whole team to own the code • Allow for the team to learn and share ideas about the project • There are downsides of code reviews without paired programming • Typically logic errors are missed • A combination of paired programming and code reviews will lead to better defect prevention Loyola Marymount University

  12. Final Presentation Agile Practices Updated: 25-Nov-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 • Putting in the most important features first, the software could theoretically be released to the customer if they decide that some of the features initially envisioned are no longer necessary Loyola Marymount University

  13. Final Presentation Agile Practices Updated: 25-Nov-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 • An Ant build can be created for this • A single source repository keeps the necessary items for a build together Loyola Marymount University

  14. Final Presentation Agile Practices Updated: 25-Nov-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

  15. Final Presentation Agile Practices Updated: 25-Nov-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 • Most can only be applied to Object Oriented Languages • Sample refactorings for scripting languages: • Add a parameter • Consolidate Conditional Expression • Extract Method Loyola Marymount University

  16. Final Presentation Agile Practices Updated: 25-Nov-2006 Unit Testing • Prevents defects from ending up in software • Gives confidence that the product is behaving as expected • Tcl had two unit test frameworks available: • tcltest – does not use the xUnit framework • TclTkUnit – does not report results sufficiently • “t-unit” was developed to be a better unit test framework for Tcl Loyola Marymount University

  17. Final Presentation Agile Practices Updated: 25-Nov-2006 t-unit • Provides an automated unit test framework • Modeled after the “JUnit” Java test suite • All calls are “asserts”; e.g.: • “assertEqual” checks for equal results • “assertTrue” checks for result of boolean TRUE • . . .and so on. . . Loyola Marymount University

  18. Test Case Pass + reason: String user Fail Test Result File Expression t-unit “Class” Diagram Updated: 25-Nov-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

  19. TUnit Process Model Test Case File Description Updated: 27-Oct-2006 Final Presentation Test Case File Description Updated: 25-Nov-2006 Sample Test Case 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 • Usage notes: • Vertical bars required as shown • Whitespace required as shown • Optional third parameter (not shown) allows tailoring of response message for each assertion • Either parameter (or both parameters) may be a Tcl “list” data type • List can contain a procedure name and its arguments • Allows testing of procedures, not just values (real strength of this package) • Enclose lists in curly braces within test file, or define globally prior to running t-unit (may be defined as part of automated test suite) • List may comprise a procedure and its argument list Loyola Marymount University

  20. Final Presentation Agile Practices Updated: 25-Nov-2006 Use Available Tools • A wide variety of tools at our disposal • Text editors that offer syntax highlighting • Office suites for presentations and UML documents • Configuration Management (CM) System • Keep track of every change in source code and documentation • Allows for continuous integration to be seamless • Subversion, CVS • Eclipse Open Development Platform • Text editor • Build and unit testing • Integrated GUI for CM Loyola Marymount University

  21. Final Presentation Agile Practices Updated: 25-Nov-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 – creates tcl projects with t-unit included • Tcl Package Creator – creates packages within the project • Tcl File Creator – creates tcl files with AutoDOC comments in place • Tcl File Editor – allows for syntax highlighting, auto indentation, and content assistance (i.e. completion of commands) • Preferences menu • Namespace Explorer – lists packages and files within each package; can be used to verify that Tcl coding standards are being followed • Execution of t-unit scripts • A set of unit tests is also available to test the TUnit plug-in • Demonstration Loyola Marymount University

  22. Final Presentation Agile Practices Updated: 25-Nov-2006 TUnit Extension • The Eclipse Dynamic Languages Toolkit (DLTK) project was created to develop a framework for tool vendors, researchers, and end-users who rely on dynamic languages such as Tcl • 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 • TUnit extension was born • Offered to create this part of the plug-in using the t-unit package • Demonstration Loyola Marymount University

  23. Final Presentation Future Research Updated: 25-Nov-2006 Future Research • Over time, more practices will be added to Agile to make the development process even more seamless • The future of TUnit and the TUnit extension is still up in the air • TUnit has been released as version 1.0.0 • No bugs reported to date via the Google Code repository • TUnit extension could see additional revisions • The Eclipse DLTK project is interested in adding the tcltest framework to the TUnit extension • Code is written to do this fairly easily • Looking at a date in January 2007 Loyola Marymount University

  24. Final Presentation Future Research Updated: 25-Nov-2006 Conclusions • Agile is not going away but getting stronger • More and more it is being accepted as a valid process for creating software • Not all the practices need to be followed: come up with a set that fits the team’s needs Loyola Marymount University

  25. Final Presentation Future Research Updated: 25-Nov-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 • The source code is located in Loyola Marymount’s CVS for now but could move into the Eclipse DLTK repository next year • Could not use the Google repository because the Eclipse Public License is not available • Can also download the project at the TUnit homepage Loyola Marymount University

  26. Questions or Comments Loyola Marymount University

More Related