Command Line

Coverage Validator can be controlled from the command line prompt. This allows you to create scripts that you can use to run repeatable tests. This tutorial describes the available commands and provides some examples to show what can be done using the command line. Results from coverage data collection sessions can be merged to form an aggregate result. Potential uses for automated code coverage analysis are:

  • Use in the regression test suite to ensure code coverage of a certain level.
  • Use in unit testing to ensure code coverage of a certain level.
  • Quality assurance.

Command line arguments must be separated by spaces. Any command line arguments that have spaces in them must be quoted. Some of the command line arguments can only be used when other command line arguments are present. Other command line arguments are exclusive and cannot be used when other command line arguments are present.

Options for program startup

  • -injectName. The -injectName option allows the name of a process to be specified that Coverage Validator will attach to. If the process name contains spaces, the process name should be quoted. If -injectName is used, do not use -program, -injectID or -waitName.
    -injectName c:\testbed.exe
    -injectName "c:\new compiler\version2\testbed.exe"
  • -injectID. The -injectID option allows the numeric (decimal) id of a process to be specified. Coverage Validator will attach to the process with this id. If -injectID is used, do not use -program, -injectName or -waitName.
    -injectID 1032
    -injectID 753
  • -waitName. The -waitName option allows the name of a process to be specified that Coverage Validator will wait for. When the process starts Coverage Validator will attach to the process. If the process name contains spaces, the process name should be quoted. If -waitName is used, do not use -program, -injectName or -injectID.
    -waitName c:\testbed.exe

    -waitName “c:\new compiler\version2\testbed.exe”

  • -displayUI. The -displayUI option causes Coverage Validator to be displayed during the test.
  • -hideUI. The -hideUI option causes Coverage Validator to be hidden during the test.

Options for controlling other aspects of Coverage Validator.

  • -program. The -program option allows the name of an executable program to be specified. This program will be started by Coverage Validator. If the program name contains spaces, the program name should be quoted. If -program is used, do not use -injectName, -injectID or -waitName.
    -program c:\testbed.exe
    -program "c:\new compiler\version2\testbed.exe"
  • -directory. The -directory option allows the name of a directory to be specified. This directory is the directory in which the program (specified with -program) is executed. If -directory is not specified the program is run in the current directory. If the directory name contains spaces, the directory name should be quoted.-directory is only valid when -program is used.
    -directory c:\development\
    -directory "c:\research and development\"
  • -arg. The -arg option allows command line arguments to be specified that can be passed to the program (specified with -program) started by Coverage Validator. The -arg option can appear as many times as necessary on Coverage Validator’s command line. If the argument contains spaces, the argument should be quoted.-arg is only valid when -program is used.
    -arg bigCheese
    -arg "c:\program files\a program\this.exe"
  • -exportAsHTML. The -exportAsHTML option exports the session data as a HTML file when Coverage Validator has finished collecting data from the target program. If the filename contains spaces, the filename should be quoted.
    -exportAsHTML c:\results\testMacro1.php
    -exportAsHTML "c:\test results\testMacro1.php"

    Please note that if you merge the current session with another session, the exported HTML will be for the merged session.

  • -exportAsXML. The -exportAsXML option exports the session data as an XML file when Coverage Validator has finished collecting data from the target program. If the filename contains spaces, the filename should be quoted.
    -exportAsXML c:\results\testMacro1.xml
    -exportAsXML "c:\test results\testMacro1.xml"

    Please note that if you merge the current session with another session, the exported XML will be for the merged session.

  • -mergeSessions. The -mergeSessions option merges a previously loaded session (loaded using -loadSession) with the current session just recorded (by the command line arguments to -program, etc). The resulting merged session is placed in the current session.
  • -loadSession. The -loadSession option allows a previously created session to be loaded into Coverage Validator to be merged with the coverage data from the session being recorded. If the filename contains spaces, the filename should be quoted.
    -loadSession c:\results\testMacro1.mvs
    -loadSession "c:\test results\testMacro1.mvs"
  • -saveSession. The -saveSession option saves the session data when Coverage Validator has finished collecting data from the target program. If the filename contains spaces, the filename should be quoted.
    -saveSession c:\results\testMacro1.mvs
    -saveSession "c:\test results\testMacro1.mvs"
  • -saveMergeResult. The -saveMergeResult option allows the results of a session merge to be saved to a file. If the filename contains spaces, the filename should be quoted.
    -saveMergeResult c:\results\testMacro1.mvs
    -saveMergeResult "c:\test results\testMacro1.mvs"
  • -settings. The -settings option is used to specify the settings to be used for the test. If the filename contains spaces, the filename should be quoted.Settings are usually stored in the registry. If you wish to save a specific set of settings for use in a regression test, you can save the settings to a specific file from the settings dialog.
    -settings c:\settings\testMacro1.mvs
    -settings "c:\reg tests settings\testMacro1.mvs"
  • -commandFile. The -commandFile option is used specify a commandfile that command line arguments are read from. This option is provided as it is possible for command line arguments to become longer than the limited space provided by the windows command shell. If the filename contains spaces, the filename should be quoted.
    -commandFile c:\regtests\testMacro1.cf
    -commandFile "c:\reg tests\testMacro1.cf"
  • -refreshCoverage. The -refreshCoverage option is used to cause Coverage Validator to refresh the Coverage tab when a test is complete.
  • -refreshFunctions. The -refreshFunctions option is used to cause Coverage Validator to refresh the Functions tab when a test is complete.
  • -refreshFilesAndLines. The -refreshFilesAndLines option is used to cause Coverage Validator to refresh the Coverage tab when a test is complete.Any other arguments found on the command line are treated as if they had been specified using the -arg prefix. These arguments are passed to the specified program as arguments of the program. For example:
    -program c:\myProgram.exe useSQLServer

    will be treated as if it had been specified as

    -program c:\myProgram.exe -arg useSQLServer
  • -?. The -? option causes the Coverage Validator help to be printed on the standard output.
  • -help. The -help option causes the Coverage Validator help to be printed on the standard output.
  • Unrecognised arguments. If any of your program’s arguments conflict with Coverage Validator’s arguments you will need to use -arg to specify them to your program.
  • Please check the help file for a list of additional arguments.

Example 1
This example starts the application, showing no progress dialog whilst attaching to the process. The program to be executed is c:\new compiler\version2\testbed.exe. The resulting session is saved in c:\test results\testbed.cvs. All three tabs are refreshed after the session. The last tab refreshed is displayed, resulting in the Functions tab being the current tab.

-program "c:\new compiler\version2\testbed.exe" -saveSession "c:\test results\testbed.cvs" -displayUI -refreshCoverage -refreshFunctions -refreshFilesAndLines

Example 2
This example starts the application, showing the progress dialog whilst attaching to the process. The program to be executed is c:\new compiler\version2\testbed.exe, in directory c:\new compiler\testarea. A previously recorded session is loaded from c:\test results\session1.cvs. After the session is recorded it is saved in c:\test results\testbed.cvs. The session is then merged with the previously loaded session and the resulting merged session is saved in c:\test results\session2.cvs. All three tabs are refreshed after the session. The last tab refreshed is displayed, resulting in the Functions tab being the current tab.

-program "c:\new compiler\version2\testbed.exe" -directory "c:\new compiler\testarea" -saveSession "c:\test results\testbed.cvs" -displayUI -refreshCoverage -refreshFunctions -refreshFilesAndLines -loadSession "c:\test results\session1.cvs" -mergeSessions -saveMergeResult "c:\test results\session2.cvs"

Fully functional, free for 30 days