+ All Categories
Home > Documents > TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Date post: 26-Mar-2015
Category:
Upload: ariana-powell
View: 215 times
Download: 0 times
Share this document with a friend
Popular Tags:
18
TUnit Demonstration Automated Unit Test Package For Tcl Procedures June 26, 2022
Transcript
Page 1: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

TUnit DemonstrationAutomated Unit Test Package

For Tcl ProceduresApril 10, 2023

Page 2: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Requirements

• Java runtime level of at least 1.4– http://java.sun.com/j2se/1.5.0/download.jsp

• Eclipse IDE– http://www.eclipse.org/downloads/

• tclsh– http://www.activestate.com/Products/ActiveTcl/– Make sure to add bin directory to the path

Page 3: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Installation

• Extract the zipped file to the eclipse home directory– Usually C:\Program Files\eclipse

Page 4: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Verifying Installation

• If eclipse is being started for the first time, a welcome screen will appear.

• If an error occurs, this is usually a result of the Java runtime engine not being installed properly.

Page 5: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Verifying Installation Continued

From the Window menu, set the TUnit Preferences. This means the installation was a success.

Page 6: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

TUnit Perspective

A perspective determines the visible actions and views within a window. The TUnitperspective has 4 views: Navigator, Namespace Explorer, Tasks, and Console. The TUnit perspective can be opened from the upper right corner, the window menu, orby creating a new Tcl Project.

Page 7: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

New Tcl Project

Create a new Tcl Project and choose the Project name and location

Page 8: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Tcl Project Continued

The Tcl Project creates the init.tcl and global.tcl files as well as the t-unit package.

Page 9: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Namespace Explorer

Namespace Explorer looks at the tclIndex file and generates the procedure namesassociated with each package. Double clicking on the procedure name will openthe file where the procedure is defined.

Page 10: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Editor

The Tcl Editor has the following features: syntax highlighting, auto indentation, and content assistance. If other plugins are installed, *.tcl files may not use the TUnit editor. Update the file associations preferences to use the TUnit editor.

Page 11: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

TUnit Menu

Within the TUnit perspective, you allowed to create a new Tcl Package and a new Tcl File.

Page 12: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Tcl Package

Create a new package within a project. The package will include the necessary file for package and namespace declaration and init.tcl will automatically be updated.

Page 13: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Tcl File

The Tcl File wizard only requires the file name as input. But ProcedureParameters, Version, and Author name are also allowed and will beautomatically put into the comments within the file.

Page 14: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Sample Testing Script

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 | OK

Page 15: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Using the Test Harness# Put this file at the project level. # Can also run more than one set of # unit tests, i.e. make a call to # t-unit::testHarness more than once. # Below is a sample file; init.tcl is # required.

source init.tcl

t-unit::testHarness t-unit/t-unittestcases.test

Page 16: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Execute TUnit Script

Right click on the TUnit Script to execute and run it.

Page 17: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Results of a TUnit Run

Once the TUnit script finishes executing, a popup window will appearwith the results of the test. In addition, the console window displays the test results.

Page 18: TUnit Demonstration Automated Unit Test Package For Tcl Procedures January 4, 2014.

Known Issues

• This plugin has not been tested on Unix or Mac systems. Please report any errors that are seen and they will be fixed accordingly.


Recommended