Transcribing an existing language to BNF and creating a parser for it isn’t a trivial task, but it’s not an insurmountable one either. A few years ago I started thinking about what you could do if you developed a parser for Mercury’s Test Script Language (TSL) that drives WinRunner, one of their functional test automation tools.

TSL Code Reformatter
Check test scripts for conformity to project coding standards. Reformat existing test scripts to meet coding standards.

  • Indentation, use of whitespace
  • Complexity of compound statements
  • Check for common errors or misleading code
    if (i = 1) {
    initialiseTest(); // this code should only execute when i is equal to 1, but instead executes every time.
    }
  • Use of comments

TSL Code Obfuscator
As TSL is an interpreted (rather than compiled) language, if you give someone your script you have not just given them what they need to run a test, you have given them everything they need to understand and modify your work.

There might be a market for a tool that allows a company to deliver scripts that can be proven to work but do not allow a client to modify the scripts easily. This might be useful in “payment on delivery” situations where the client is not entirely trusted.

The tool could

  • Strip all comments
  • Remove any unnecessary whitespace
  • Change all function names
  • Change all variable names

TSL Syntax Highligher
It would be nice to be able to post code-snippets on a webpage with the same font and colouring as they would have in the tool that they were written with. Converting TSL to HTML would probably be the easiest one of these projects as the parser does not have to be perfect, just “good enough”.

It would be nice to have two possible outputs for this tool.

  • Old-style HTML (pre-4.01) using <font> tags.
  • An XHTML version, where the fonts and colours have been put into a stylesheet. This type of output could also be manipulated and changed to other formats using XSLT.

TSL Code Translator
Convert existing WinRunner scripts into a format usable by another tool. This would be by far the most difficult task in the list. I wouldn’t want to be the person in charge of making this one work.

TSL Documentation Generator
I once worked on a WinRunner project where one of the deliverables was function library documentation in Microsoft Help format (*.chm), which is basically compiled/compressed html.

This was done near the end of the project but, even then, it was a pain to put together. It sucked up at least a man-week worth of time and, because it violated the Pragmatic Programmer’s DRY (Don’t Repeat Yourself) principle which says “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system”, it rapidly went out of date as the function library changed.

The obvious solution would be to have a Javadoc-like tool that allowed you to put specially marked-up comments in the source code that could be automatically extracted and turned into documentation.

But, back in the real world…

Unfortunately, none of these projects are really viable as Mercury licensing prohibits sale of third-party tools that work with their toolset.

 

Published On: May 8, 2005Tags:

6 Comments

  1. Stuart Moncrieff May 9, 2005 at 9:56 am - Reply

    Could also use it as a refactoring tool.
    eg/ change all instances of a variable name, but do not change it where it appears in a string or as a function name.

  2. Anonymous June 16, 2005 at 9:52 am - Reply

    A Mercury User-Contributed Knowledgebase article provides a tool to generate help files for QuickTest Pro function libraries.

    http:// support.merc-int.com/kba/User/QuickTestProfessional/7738.html

  3. Anonymous August 30, 2005 at 10:47 am - Reply

    It would be nice to have a little utility that would read through any user-created function libraries and automatically create calls to generator_add_function(), generator_add_category(), and generator_add_function_to_category() that would add them to the WinRunner Function Generator (F7).

  4. Jared March 15, 2006 at 9:29 pm - Reply

    Does the Mercury license prohibit you from releasing products for free?

  5. Stuart Moncrieff March 15, 2006 at 9:46 pm - Reply

    You are free to release software that works with Mercury products (as long as you didn’t reverse-engineer anything to make them), you just can’t sell products that work with Mercury tools.

    Other companies do sell products that work with Mercury tools though, so Mercury must be happy to allow this if you come to some sort of agreement first.

    Cheers,
    Stuart.

  6. Stuart Moncrieff March 15, 2006 at 10:03 pm - Reply

    I just noticed the following comment…

    It would be nice to have a little utility that would read through any user-created function libraries and automatically create calls to generator_add_function…

    Mercury has gone one step better than this and they have added a function brower to WinRunner 8.0 and above. This allows you to automatically insert functions from your function library into your script as well as browse them and jump to the function’s code in the compiled module.

    This is a great feature that I’ve been promoting whenever I deliver WinRunner training (even though it is not in the training material).

Leave A Comment