Purpose: collection point for information regarding the tcl testsuite support code. [http://www.tcl.tk/man/tcl/TclCmd/tcltest.htm%|%official reference]: The tcltest package provides the user with utility tools for writing and running tests in the Tcl test suite. It can also be used to create a customized test harness for an extension. Tcltest is one of the packages that is bundled into the [Tcl] software core distribution. http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/tcltest.htm [PYK] 2015-04-09: One strategy for some complex tests is to set `-result` to [Donald Porter] advises "Please note that version 2.x of the tcltest package (included with Tcl 8.4) is much more flexible in the kind of matching it permits." <> Don also suggests http://tmml.sourceforge.net/doc/tcl/tcltest.html as a superior formatting of the same information. ---- Anyone have some good examples of making use of this code? A wonderful addition to this page would be instructions on how to run one particular test, using verbose mode, for the purpose of reporting test suite failures to a package developer. [[A Pythoneer has written an article--which [DGP] answers: make TESTFLAGS='-verbose tpse -file safe.test' test ---- [CL] can locate if helpful--illustrating use of PyUnit with Roman numeral conversion. CL can locate if helpful--illustrating use of PyUnit with Roman numeral conversion. maybe someone wants to steal that example ...]] [RS], off page topic: See also [Roman numbers] for Tcl routines. ---- [AK]: Most modules in [tcllib] come with .test files using tcltest for regression testing. [VI] : 2003/10/02. We at [http://www.comit.com] use Tcl (and Tk) extensively. We use Tcl for hardware testing in simulation (think multimillion-gate , multifunction asic verification). One of the major factors in our initial decision to use Tcl and our continuing to use tcl is tcltest. We use most tcltest features including constraints and are very pleased with the easy configuration of tests and the reporting. I do have gripes, but relatively minor, and since it is pure Tcl, we can change it anyways.. [davidw] 2003-10-03: I am doing some work to improve tcltest, specifically to give it an API so that you can programmatically fetch information about the test results. I would love to hear what sorts of features you would find useful - feel free to drop me email. ---- [davidw] 2003/10/03: I am doing some work to improve tcltest, specifically to give it an API so that you can programmatically fetch information about the test results. I would love to hear what sorts of features you would find useful - feel free to drop me email. ---- [[tcltest is a truly great and wonderful thing. We should make a point of explaining its virtues and uses.] ---- ''[escargo] 16 Dec 2003'' - I have started using tcltest, but I had to figure a few things out on my own in order to get started. Clearer documentation could have helped me out. The man page portion for '''-body''' says (in part), "The -body attribute indicates the script to run to carry out the test. It must return a result that can be checked for correctness." My first reading of this was confused by the meaning of ''return a result.'' My first thought was that there ought to be a '''return''' at the end of the specified body. That is not the case. Is there a conventional meaning of ''return a result'' in Tcl that is not related to the '''return''' command? '''[DGP]''' Good point. Would ''produce a result'' or ''yield a result'' be less likely to confuse? ''[escargo]'' - My background with [Icon] leads me to expect terminology like ''produce a value'' or ''produce a result'' (not to be confused with ''generate a value'' or ''generate a result'', which are semantically distinct from ''produce'' in Icon). (I can see where other people think about ''commands'' returning results, but I don't think of ''scripts'' as returning results, since they don't use the '''return''' command. Once the conceptual leap has been made, this way of thinking is no longer a problem, but the gulf has to be recognized before it can be crossed.) A second question I had (which is not addressed in the documentation for '''-body''') is, "What scope is the body code executed in?" Is it executed in the scope containing the '''test''' command that the -body option belongs to? (That would seem to be the only reasonable choice, since there are no parameters to the test command, but I suppose execution could be in the global scope.) [WHD]: The return value of a Tcl script is the return value of the last command executed in the script. Many of my tcltest cases end with a call to "set" (which returns the value of a variable) or with a call to "list" (to return a number of results at once). '''[DGP]''' All of the scripts, ''-setup'', ''-body'', and ''-cleanup'' are evaluated in the caller's scope. This is the same rule as for other control structure commands like [if] or [while]. ''[escargo]'' - Do you think of '''test''' as a control structure? '''[DGP]''' For the most part, yes. Any command that takes a script as an argument and controls something about how that script is evaluated is a kind of control structure in my view. ---- [How to write tcltest result values] [[Where to obtain ...]] ---- Back to [Tcl core extension syntax] ---- [[ [Category Package] | [Category Command] from [Tcl] ]] [[ [Tcl syntax help] | [Arts and crafts of Tcl-Tk programming] ]]