Better Software - September 2008 - (Page 20) Test Connection It’s in the Way that You Use It by Michael Bolton People sometimes ask me what my favorite test tool is, and my answer often confuses them. They seem to expect me to name a program that automates the operation of an application, makes some process more repeatable, or allows a machine to drive as quickly as possible through an application. But if you think driving is merely about getting from one point to another, ask a New York cabbie. Rapid testers don’t think of test automation merely as something that controls a program and checks for some expected result. Instead, we think of test automation as any use of tools to support testing. So my favorite test tool changes from moment to moment, but it’s often (drum roll) my text editor. For years, I’ve used an editor called TextPad (see the Sticky Notes for a link). I’m not claiming that it’s the best editor available, but it’s my favorite. There are plenty of other text editors, and whichever one you use, if you’re happy with it, I am, too. So what do I use a text editor for? Writing. A lot of my work as a tester involves creating and editing text—taking notes, editing text, creating Fitnesse tables, building Web pages, or writing articles like this one. With my text editor, I can do these things efficiently without extra overhead like the tables, formatting and layout tools, styles, and thesauruses in sophisticated word processors. These extra features sometimes distract me or entice me to use them needlessly. As Marshall McLuhan said, “We shape our tools, and thereafter our tools shape us [1].” I sometimes use a text editor to emphasize to myself that I’m working on something temporary or preliminary. That’s not to say that a text file is never important; a commercial software company that I worked for used to track bugs and feature suggestions by using a plain old ASCII text document. For us, the cost and overhead of an elaborate test management tool wasn’t worth it when ideas could be captured concisely, compactly, and sufficiently in text. Programming. Good text editors support programming by providing syntax highlighting, which recognizes the programming language that I’m using and changes the color or font of keywords, symbols, and variables to make them more distinguishable. This improves readability and provides some cognitive hints to alert me when I’m making a mistake. More sophisticated programming environments automatically add closing parentheses, braces, or brackets when I type the opening symbol; provide context-sensitive help for the languages and libraries that I’m using; and offer very sophisticated ways to map and model larger programs. When I’m working on a large project, I find these features essential, but for a quick-and-dirty throwaway script, a good text editor is just fine. Cutting and pasting. Unlike Notepad, TextPad can mark blocks of text in columns, which allows me to open a file that’s organized as a table, grab specific blocks in columns, and manipulate them or copy them to another program. This is often handy in combination with command line redirection to supply input from a file or output from a program to a text file. In Windows, it’s also possible to extend the virtual size of the comwww.StickyMinds.com mand window, copy output from programs, and paste it into a text editor for processing. Data generation. I often use a testing technique called an input constraint attack—hurling huge amounts of text at an input field to see whether the program protects itself from buffer overflows that could compromise security or stability. To generate data quickly, I type ten characters and then hit Ctrl-A (select all), Ctrl-C (copy to the clipboard), and then Ctrl-V ten times (paste ten copies). Now I have a file of one hundred characters. Then I hit Ctrl-A, Ctrl-C, and Ctrl V ten times again; now I have a thousand characters. Repeat that cycle a few times with a final Ctrl-A, Ctrl-C, and Ctrl-V, and I have a million or ten million characters on the clipboard, suitable for pasting into an input field, an application, or a Web page. Try it! The results are often fascinating—data corruption, strange behavior, or a crash. Danny Faught and James Bach’s PerlClip tool [2] has more features for this task, but a text editor will do many useful things in a pinch. Searching and replacing. Sometimes I’m looking for words, strings of words, or patterns of characters inside log files, Web pages, XML pages, commadelimited files, or binary files. Sometimes I want to replace strings of text with something else, or delete markup 20 BETTER SOFTWARE SEPTEMBER 2008 ISTOCKPHOTO http://www.StickyMinds.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.