t-unit: tcl unit test package automated unit test package for tcl procedures final presentation...

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

Upload: sydney-oliver

Post on 12-Jan-2016

244 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

t-unit: Tcl Unit TestPackage

Automated Unit Test PackageFor Tcl ProceduresFinal Presentation

Joseph BoyleLoyola Marymount University

Page 2: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

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 PresentationIntroductionUpdated: 05-Dec-2006

Page 3: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 3

Related Work

Final PresentationRelated WorkUpdated: 05-Dec-2006

Kent Beck – Extreme Programming Explained

Page 4: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 4

Related Work

Final PresentationRelated WorkUpdated: 05-Dec-2006

Martin Fowler – Continuous Integration, Refactoring

Page 5: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 5

Related Work

Final PresentationRelated WorkUpdated: 05-Dec-2006

Andrew Hunt and David Thomas – The Pragmatic Programmer

Page 6: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 6

Related Work

Final PresentationRelated WorkUpdated: 05-Dec-2006

John Ousterhout –Tcl Scripting Language

Page 7: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 7

State of Software Development

Final PresentationState of SW DevelopmentUpdated: 05-Dec-2006

•Need to get away from plan-driven approach

•Start with a vision and a set of principles

Page 8: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 8

Agile Principles

Continual Refinement

Working Product at All Times

Continual investment in and emphasis on Design

Value defect prevention over defect detection

Final PresentationAgile PrinciplesUpdated: 05-Dec-2006

Page 9: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 9

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 10: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 10

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 11: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 11

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 12: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 12

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 13: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 13

Paired Programming

Final PresentationAgile PracticesUpdated: 05-Dec-2006

•There are downsides to paired programming

Page 14: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 14

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 15: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 15

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 16: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 16

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 17: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 17

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>

Final PresentationAgile PracticesUpdated: 05-Dec-2006

Page 18: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 18

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 19: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 19

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 PresentationAgile PracticesUpdated: 05-Dec-2006

Page 20: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

20

Sample Test CaseTUnit Process ModelTest Case File DescriptionUpdated: 27-Oct-2006

t-unit::assertEquals 12.34 12.34 | PASS | OKt-unit::assertEquals "hello“ "hello” | PASS | OKt-unit::assertEquals "hello“ "world“ | FAIL | NOT_EQUALt-unit::assertEquals 2 2 | PASS | OKt-unit::assertEquals 2 3 | FAIL | NOT_EQUALt-unit::assertEquals 12345 12345 | PASS | OKt-unit::assertEquals 12345 12345.0 | FAIL | ARG_MISMATCHt-unit::assertEquals TRUE TRUE | PASS | OKt-unit::assertNotEquals TRUE FALSE | PASS | OKt-unit::assertNotEquals “hello” “world” | PASS | OKt-unit::assertEqualsList {1 2 3} {1 2 3} | PASS | OKt-unit::assertEqualsArray A1 A2 | PASS | OKt-unit::assertEquals [samplePackage::addOne 1] 2 | PASS | OK

Final PresentationTest Case File DescriptionUpdated: 05-Dec-2006

Make the appropriate assert call What the user

is testing

Expected result

Expect pass or failure

Return value from assert call

Page 21: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Final Presentation“Class” DiagramUpdated: 05-Dec-2006

File

Test Suite

Report

«creates»

«examines»Procedure

PackageUnder Test

Expression«calls»

«input, expected»

Test Case

+ reason: String Test Result

Pass Fail

«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::assertEqualsArray t-unit::assertNotEquals

t-unit::assertFalse

t-unit::assertTrue

«test function»

«reads»

«writes»

user

«runs»

Page 22: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Use Available Tools

Final PresentationAgile PracticesUpdated: 05-Dec-2006

Page 23: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 23

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 PresentationTUnitUpdated: 05-Dec-2006

Page 24: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 24

Demonstration

Final PresentationDemonstrationUpdated: 05-Dec-2006

Page 25: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 25

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 PresentationTUnit ExtensionUpdated: 05-Dec-2006

Page 26: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 26

Demonstration

Final PresentationDemonstrationUpdated: 05-Dec-2006

Page 27: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 27

Future Research

The future of TUnit and the TUnit extension is still up in the air

TUnit extension could see additional revisions

Final PresentationFuture ResearchUpdated: 05-Dec-2006

Page 28: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 28

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 PresentationAcknowledgementsUpdated: 05-Dec-2006

Page 29: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 29

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 PresentationConclusionsUpdated: 05-Dec-2006

Page 30: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 30

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

Final PresentationSource CodeUpdated: 05-Dec-2006

Page 31: T-unit: Tcl Unit Test Package Automated Unit Test Package For Tcl Procedures Final Presentation Joseph Boyle Loyola Marymount University

Loyola Marymount University 31

Questions?

Final PresentationQuestions?Updated: 05-Dec-2006