Counterstrings: Self-Describing Test Data

I was at a conference some months ago when Danny Faught showed me a Perl package for manipulating the Windows clipboard. I turned it into a little tool for helping me test text fields.

It’s called PerlClip. Feel free to download it. You don’t need Perl to run it.

One of the things PerlClip does is allow you to produce what I call “counterstrings”. A counterstring is a graduated string of arbitrary length. No matter where you are in the string, you always know the character position. This comes in handy when you are pasting huge strings into fields and they get truncated at a certain point. You want to know how many characters that is.

Here is a 35 character counterstring:

Each asterisk in the string occurs at a position specified by the immediately preceding number. Thus, the asterisk following the 29 is the 29th character in that string. So, you can chop the end of the string anywhere, and you know exactly where it was cut. Without having to count, you know that the string “2*4*6*8*11*14*17*2” has exactly 18 characters in it. This saves some effort when you’re dealing with a half million characters. I pasted a 4000 character counterstring into the address field of Explorer and it was truncated at “2045*20”, meaning that 2047 characters were pasted.

I realize this is may not be a very interesting sort of testing, except perhaps for security purposes or when you’re first getting to know the app. But security is an increasingly important issue in our field, and sometimes when no one tells you the limits and dynamics of text fields, this can come in handy.

6 thoughts on “Counterstrings: Self-Describing Test Data

  1. I’ve used this tool and found it very helpful in things like field validation as suggested in the field – Requirement states that field will accept a maximum input of 200 characters. Great create a string, put it in your automation library, have your automation tool call the string to test the value. Requirement changed? Create a new string with same name!

    Also have used it for creating large quantities of data for insertion into database applications under test.
    Testing indexing in databases through creating huge strings and using find and replace to change or strip out the asterisks.
    Though for both these cases I have also enjoyed using texts from the Project Gutenberg library – ( I mean Ipsum Lorum does tend to get boring after a while.

  2. james,

    is there a way to tell perlclip to create the $allchars backwards?

    I figure out that the combination “&#” breaks the application when is used.. and some times some points of the $allchars text backwards also crash apps.

    [James’ Reply: There’s no way to do that yet. But it’s easy to tweak the code to make that happen.] 

  3. I’ve already shared this with a couple of my testing colleagues. Though it’s simple, it’s powerful. Before, we’d hold a button for a long time in a field, then copy to the point of truncation and paste the text in word and do a character count. Cave-man like, I know! Thank you for the tool! It’s in my library now.

  4. Typo,possibly? 17*2 ??

    [James’ Reply: I know it looks like one, but it isn’t. The full string was 2*4*6*8*11*14*17*20*23*26*29*32*. When that is truncated to 18 characters it will end in “2”]

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.