Do you need to test a new piece of software or hardware? You sit there, and you type in your tests, and your check the results. It gets much more difficult when you're testing something that's multiuser and interactive; do the users interfere with each other? Does it work every time? Testing systems such as this can be time-consuming (and boring!), and it's easy to overlook errors if one set of answers is subtly different to another.
Expect (based on Tcl) allows you to automate testing such as this by using two "magic" commands - send and expect - to send a string out to the item under test, and check the response. Expect doesn't have a huge user base, but it's a lifesaver for those specialist requirements that need it.
Can you type as fast as your computer can transmit information? No - you can't - so to make testing from Expect more realistic, an option to send (-h) lets the text be send at "human" speed. You can even define the foibles of your human being if you wish, for example:
set send_human {.1 .25 2 .05 1.5}
send -h "This is a message coming out as if it was typed by a typist\n"
or
set send_human {.3 .4 0.6 .1 3}
send -h "This is a lett\b\b\b\bmessage coming out as if it was typed by an engineer\n"
In our first example, there's an average gap of 0.1 seconds between characters in words, and 0.25 between characters at the word end. The figure 2 defines the "shape", which is a measure on consistency; 2 is reasonable for a typist, a lower figure indicating a much more erratic person entering data and a higher figure giving greater consistency. The absolute minimum time between characters is 0.05 seconds, and the absolute maximum is 1.5 seconds.
Can you work out what the parameters mean for our second example, the engineer?
See also
Expect - advanced training module
Please note that articles in this section of our
web site were current and correct to the best of our ability when published,
but by the nature of our business may go out of date quite quickly. The
quoting of a price, contract term or any other information in this area of
our website is NOT an offer to supply now on those terms - please check
back via
our main web site
Tcl/Tk - Tcl, Tcl/Tk and Expect - General [2429] - ()
[2474] - ()
[2504] - ()
[2681] - ()
[3192] - ()
[3286] - ()
[4206] - ()
[4434] - ()
[4460] - ()
[4616] - ()
Tcl/Tk - More on Expect [435] - ()
[1173] - ()
[1411] - ()
[1475] - ()
[1531] - ()
[2475] - ()
[3009] - ()
[3448] - ()
resource index - TclTk
Solutions centre home page
You'll find shorter technical items at
The Horse's Mouth and
delegate's questions answered at
the
Opentalk forum.
At Well House Consultants, we provide
training courses on
subjects such as Ruby, Lua, Perl, Python, Linux, C, C++,
Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer)
many questions, and answers to those which are of general
interest are published in this area of our site.