Jtest logo




Contents  Previous  Next  Index

Running Jtest in Batch Mode


You can run an existing test from the command line using existing .ctp or .ptp test parameter files, or you can test a class or project for the first time and have Jtest create all necessary parameter files.

Windows

To run Jtest in batch mode on a Windows system:

  1. Set up command line Jtest.
    1. Change directories to the Jtest installation directory.
    2. Run the jtvars.bat program by entering the following command at the prompt:
      jtvars.bat
  2. Run the test from the command line by entering your command at the prompt. For tips on creating commands, see Available Command Line Options and Example Commands below.

After the test is complete, you can view the report that was generated, or-- if you tested a project-- you can view the results within the Jtest UI. To view results within the UI, launch Jtest, then open the .ptp file for the project that you tested in batch mode. Click the Results button to display the results. After the results are loaded in the Results panel, you can also generate additional types of reports by right-clicking the Report button and selecting the type of report that you want to see.

UNIX

To run Jtest in batch mode on a UNIX system:

After the test is complete, you can view the report that was generated, or-- if you tested a project-- you can view the results within the Jtest UI. To view results within the UI, launch Jtest, then open the .ptp file for the project that you tested in batch mode. Click the Results button to display the results. After the results are loaded in the Results panel, you can also generate additional types of reports by right-clicking the Report button and selecting the type of report that you want to see.

Available Command Line Options

Available command line options for jtestgui include:
Command Meaning
-help Print out list of available options.
-nogui Run jtestgui without the UI. jtestgui -nogui Simple.ctp
-nolog Do not generate log messages to stdout.
-nologo Do not show logo message.
-filter_in <regexp> Set Project Test Parameter's Filter-in field value.
To test only the examples/eval directory use:
jtestgui -filter_in examples\eval\ -test examples.ptp
-run_only <what> Run specific types of tests only. Options for <what> include:
  • static: Runs static tests.
  • static_builtin: Runs all built-in static analysis rules.
  • static_user: Runs all user-defined rules.
  • static_<XXX>: Runs only rules in the XXX category; for example, use static_UC to run only "Unused Code" rules.
  • dynamic: Runs dynamic tests
  • dynamic_auto: Runs automatic test cases
  • dynamic_user: Runs user-defined test cases.
Use -run_only help to see a list of all options for <what>.
-ctp <file>.ctp Load class test parameters file <file>.ctp.
-ptp <file>.ptp Load project test parameters file <file>.ptp.
-ctp_new <file>.ctp Create and load class test parameters in the file <file>.ctp. If file <file>.ctp already exists, it will be overwritten by this new file. Use the following options when creating a new .ctp file from the command line:
  • -class_name <name>: Sets the class test parameters' "Class Name" parameter. Indicates which class you want to test.
  • -cp: Sets the class test parameters' -cp parameter. Should specify the fully-qualified name of the path.
  • -classpath: Sets the class test parameters' -classpath parameter.
  • -sourcepath: Sets the class test parameters' -sourcepath parameter.
-ptp_new <file>.ptp Create and load project test parameters in the file <file>.ptp. If file <file>.ptp already exists, it will be overwritten by this new file. Use the following options when creating a new .ptp file from the command line:
  • -search_in <dir|jar|zip>: Sets the project test parameters' "Search In" parameter. Indicates which set of classes you want to test.
  • -filter_in <dir|jar|zip>: Sets the project test parameters' "Filter In" parameter. Indicates which particular classes you want to test.
  • -cp: Sets the project test parameters' -cp parameter. Should specify the fully-qualified name of the path.
  • -classpath: Sets the project test parameters' -classpath parameter.
  • -sourcepath: Sets the project test parameters' -sourcepath parameter.
-gtp <filename> Use Global Test Parameters in <filename>. If <filename> doesn't exist, Jtest creates one with default values. jtestgui -gtp newProjects.gtp
-report[_ascii|_html] <filename|stdout|stderr> Generate report in <filename>. Needs to be used with -test. jtestgui -report report.txt Note: If you don't specify ascii or html, Jtest uses the format specified in your Global Test Parameters.
-summary_report[ascii|html] <filename|stdout|stderr> Generate summary report in <filename>. Needs to be used with -test jtestgui -summary_report report.txt -test Simple.ctp
-detail_report[ascii|html] <filename|stdout|stderr> Generate detail report in <filename> needs to be used with -test. jtestgui -detail_report report.txt -test Simple.ctp
-retest Force retesting of all classes-- even classes tested in a previous run Note: This option is similar to the Skip classes already tested option in the Project Test Parameters. It applies to .ptp files and is used for all tests run during that jtestgui invocation. jtestgui -retest
-silent Only generate output if errors are found. Project reports only contain
-ruledir Overwrites the Global Test Parameters' rules directory parameter (specifies the location of your user-defined rules). Used only in silent mode. jtestgui -nogui -ruledir <directory name> -ptp test.ptp

To see all available command-line options, enter

jtestgui -help

at the prompt.

Note: If you are on a Windows system, you must set the environment for command line Jtest before you enter this command.

Example Commands

  • To run the previously tested MyTest test whose test parameters are saved in c:\progra~1\parasoft\jtest\tests\MyTest.ptp, then generate a summary report (summary.rpt) in the current working directory, enter the following command at the prompt:

    jtestgui -summary_report summary.rpt -ptp c:\progra~1\parasoft\jtest\tests\MyTest.ptp

  • To perform the above test in "silent mode" (without displaying the Jtest UI), you enter the following command at the prompt:

    jtestgui -nogui -summary_report summary.rpt -ptp c:\progra~1\parasoft\jtest\tests\MyTest.ptp

  • To test a single class, use the -ctp flag instead of the -ptp flag, then enter the path to the .ctp file instead of the path to the .ptp file. For example, to run the previously tested MyTest class whose test parameters are saved in /usr/users/carson/jtest/tests/MyClass.ctp, then generate a summary report (summary2.rpt) in the current working directory, enter the following command at the prompt:

    jtestgui -summary_report summary2.rpt -ctp /usr/users/carson/jtest/tests/MyClass.ctp

  • To test a class that has never been tested and that has class dependencies, use the -ctp_new, -class_name, -cp, -classpath, and -sourcepath tags. For example, to create a .ctp file for a class named Foo.class in C:\Jtest, enter the following command at the prompt:

    jtestgui -ctp_new <name of ctp file> -class_name <path to Foo.class> -cp C:\Jtest -sourcepath < path to source code if not in same dir as Foo.class>

    When this command is executed, Jtest will open with these parameters set.

  • To test a project that has never been tested before, you can use the -ptp_new flag in conjunction with the -search_in flag to specify the directory, jar, or zip that you want to test. In addition, if only certain classes should be tested in the project, the -filter_in flag can be used to indicate what classes you want to test and the -cp, -classpath, and -sourcepath flags can be used to set paths to dependencies. For example, to set up a .ptp file for Foo.jar where only some classes are tested, enter the following command at the prompt:

    jtestgui -ptp_new < name of ptp file > -search_in < path the Foo.jar > -filter_in < regular expression specifying the files to be tested > -cp < full path to dependencies > -sourcepath < path to source code>

    Note: Jtest is unable to find source code that is located within a jar file. For this example, the -sourcepath would point to the source code of the project that has been unjarred.

Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft