TIP 452: Add "stubs" Package to or Along Side of TclTest

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2017 Conference, Houston/TX, US, Oct 16-20
Send your abstracts to tclconference@googlegroups.com
by Aug 21.
Author:         Gerald Lester <Gerald.Lester@SAP.com>
Author:         Gerald W. Lester <gerald.lester@KnG-Consulting.net>
Author:         Gerald W. Lester <Gerald.Lester@gmail.com>
State:          Draft
Type:           Project
Vote:           Pending
Created:        10-Aug-2016
Post-History:   
Tcl-Version:    8.6

Abstract

This TIP proposes an enhancement to the tcltest package to add support for easy creation of test stubs, mocks and seams.

Rationale

The tcltest package allows for automated testing of Tcl code. However, doing proper automated unit testing requires that the unit under test (i.e., the method or procedure) not invoke the actual implementation of other units, but rather should invoke stub or mock units that are under the control of the test being performed as to the results they return and any exceptions they raise.

This TIP adds support for building these mechanisms, making it significantly easier to create isolated unit tests of Tcl code.

Proposal

That a framework to easily create test stubs/mocks of Tcl commands be added to the **tcltest_ package. Additionally, to facilitate the creation of automated test for legacy Tcl code. Commands supporting test seam creation and specification would also be included proposed package.

Description

It provides a fully functional implementation of the following commands:

Reference Implementation

See the tip-452 branch (http://core.tcl.tk/tcl/timeline?n=100&r=tip-452\), in particular, see http-tip-452.test for an example of using the procedures added by this package.

Origins of Reference Implementation

The reference implementation was done at SAP Labs, LLC (a subsidiary of SAP Americal, Inc.) and approved for release as Open Source under a BSD license.

Copyright

This document has been placed in the public domain.

History