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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Gerald Lester

 TIP #452: ADD "STUBS" PACKAGE TO OR ALONG SIDE OF TCLTEST
===========================================================
 Version:      $Revision: 1.3 $
 Author:       Gerald Lester <Gerald.Lester_at_SAP.com>
               Gerald W. Lester <gerald.lester_at_KnG-Consulting.net>
 State:        Draft
 Type:         Project
 Tcl-Version:  8.6
 Vote:         Pending
 Created:      Wednesday, 10 August 2016
 URL:          http://purl.org/tcl/tip/452.html
 WebEdit:      http://purl.org/tcl/tip/edit/452
 Post-History:

-------------------------------------------------------------------------

 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. Howver,
 doing proper automated unit testing requires that the unit under test
 (i.e., the method or procedure) not invoke the actual implmentation 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 package implementing the framework to easily create test
 stubs/mocks of Tcl commands be added to the *tcltest/ package.
 Additionaly, to facilitate creation of automated test for legacy Tcl
 code, commands supporting /test seam/ creation and specification would
 also be included proposed package.

 DESCRIPTION
-------------

 To use Test Seams, the contents of the *TestSeam.tcl* file should be
 placed early in your initialization prior to any Test Seams being
 defined, or the *ttu* package loaded, or the contents of the
 *TclTestUtilties.tcl/ file being sourced in.

 The file *TestSeam.tcl* provides a "stub" implementation of the
 *::ttu::Seam/ command.

 The file *TclTestUtilties.tcl* should only be sourced in when executing
 actual Tcl Test. It provides a fully functional implementation of the
 following commands:

     * *::ttu::TestSetup* - Defines which procedures/commands are
       stubbed out and how they should behave for each invocation. This
       should only be called once per test.

     * *::ttu::AddStub* - Adds a procedures/commands to the list that
       are stubbed out.

     * *::ttu::SaveVars* - Saves the values of variables to be restored
       later. This should only be called once per test.

     * *::ttu::AddVars* - Add a variable to the list of variables to be
       restored later

     * *::ttu::CallCount* - Returns a dictionary sorted list of the
       stubbed out procedures and how many times they were called.

     * *::ttu::TestCleanup* - Restores saved variables and stubbed out
       procedures.

     * *::ttu::SortedArrayData* - Return the values of an array as a
       list of key-value pairs sorted by the keys.

     * *::ttu::CallProc* - Call the real implementation of a stubbed out
       procedure.

     * *::ttu::Seam* - Test seam definition and injection (aka enabling)

 REFERENCE IMPLEMENTATION
==========================

 See:
 <URL:http://chiselapp.com/user/gwlester/repository/TclTestUtility/index>

 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
 licence.

 COPYRIGHT
===========

 This document has been placed in the public domain.

-------------------------------------------------------------------------

 TIP AutoGenerator - written by Donal K. Fellows

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Harald Oehlmann
Am 06.06.2017 um 22:49 schrieb Gerald Lester:
>
>  TIP #452: ADD "STUBS" PACKAGE TO OR ALONG SIDE OF TCLTEST

Thank you, Gerald, great work !

Just as I am curious: does a change in tcltest require a TIP ?

Thanks,
Harald

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Donald G Porter-2
In reply to this post by Gerald Lester
On 06/06/2017 04:49 PM, Gerald Lester wrote:
>   TIP #452: ADD "STUBS" PACKAGE TO OR ALONG SIDE OF TCLTEST

Transcript of some chat with Gerald:

dgp Is there a tip-452 branch in Tcl's fossil repos?
dgp If not, could one be made please?
gwlester Add add the code into tcltest package?
dgp I do not understand what the TIP proposes.  If I see
         an implementation, perhaps that will make things clear to me.
gwlester I assumed it should be discussed prior to adding the code in.
gwlester The reference implementation is at
http://chiselapp.com/user/gwlester/repository/TclTestUtility/home

gwlester It is mentioned in the TIP
dgp The tcltest package supplies a set of commands, documented
         here:
http://www.tcl.tk/man/tcl8.6/TclCmd/tcltest.htm

gwlester Yes
dgp I *think* you wish to add to that set
dgp But the TIP is confusing to read with references to some other
         package.
gwlester This is a proposed extension to them -- or it could be a "side"
         package
dgp ok, then I need clarity on which you seek.
gwlester I.e. side package to also be included with Tcl distro
dgp Add to tcltest?  Or bundle a 3rd party package
gwlester First off, I seek the wisdom of the TCT as to which they feel
         is the best path
gwlester If added to tcltest, then a small edit to change the namespace
         would be all that is required.
dgp Neither path is trivially easy.
dgp Adding the commands to tcltest is probably easi*er*.
dgp They only make sense as a complete set?
gwlester Fairly much so, at least to me.
dgp The bundling path has a big obstacle -- it's TEA based, and TEA
         doesn't handle packages written entirely in Tcl well at all.
dgp That would be a great and hugely consequential thing to fix.
dgp But I can understand you being annoyed at having to fix our
         infrastructure as a price of admission.
dgp The other way seem to be "just" a matter of expressing how the
         new commands fit into the existing set.
gwlester I'll take your word that fixing TEA for Tcl only packages is a
         large effort (one that may be worth it in the long run)
dgp A branch of tcltest.n showing what modified docs would look
         like might be the most helpful first step.
gwlester But I'm doubtful that I'd have the bandwith to understand what
         would have to be done to TEA.
dgp In the realm of niggling standard keeping, we'd want new public
         commands of tcltest to be all lower case.
dgp do you mind if I copy this transcript over to TCLCORE?
gwlester Can you validate with the rest of the TCT about creating the
         branch -- I'd hate to be "yelled" at for doing it if other TCT
         members feel strongly that is not the way to go
gwlester Please, I was going to ask you to please validate with the rest
         of the TCT on what they want done.
dgp ok. Thanks.

--
| Don Porter            Applied and Computational Mathematics Division |
| [hidden email]             Information Technology Laboratory |
| http://math.nist.gov/~DPorter/                                  NIST |
|______________________________________________________________________|

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Tcl-Core mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/tcl-core
Loading...