# Writing Reports With `writeReport`

Use the `-writeReport` command with the `-type` and `-filter` options in the command line as a separate command or as part of a series of task commands (such as run tests and audit test results). Use a web browser to view the reports.

Because the harness executes commands in their command-line sequence, you must identify the work directory before the `-writeReport` command and provide the report directory as an option at the end of the command:

> jtharness ... `-workdir` mywork-directory `-writeReport` `-type`
report-type `-filter` report-filter myreport-directory

See About the Command-Line Examples for a description of the use of > jtharness in the example.

See Command-Line Overview for a detailed description of the command line structure.

## Using the `-type` Option

When the `-type` option is not used, the harness uses the default report types last used in the GUI or `html` and `txt` if a type was not previously set in the GUI. There is a direct relationship between the names of the directories in the report directories and the report type names used in the command (`html`, `txt`, `xml for HTML`, `Plain Text`, and `XML` respectively. Include the `-type` option and a report-type argument in the command line to specify the format of the generated report.

The harness provides a set of standard format types (`html`, `txt`, and `xml`) that you can use. In addition to the standard arguments, your test suite might provide additional custom formats. If you are unsure of the additional formats provided by your test suite, you can use the Create New Report dialog from the GUI to display the list of available report formats. A direct relationship exists between the report-type arguments and those displayed in the Create New Report dialog.

## Using the `-filter` Option

When the `-filter` option is not used, the harness uses the default setting of `currentConfig`. Include the `-filter` and a filter option (`lastRun`, `currentConfig`, or `allTests`) in the command line to specify the filter used to select the test results that are reported.

Use the `lastRun` filter option (corresponds to Last Test Run in the GUI) to select test results status for all folders and tests included in the last test run even if you have exited the harness since the last test run.

Use the `currentConfig` filter option (corresponds to Current Configuration in the GUI) to select the folders and test results status specified by the current configuration.

Use the `allTests` filter option (corresponds to All Tests in the GUI) to select test results status for all tests in the work directory, including any tests that were excluded from the last test run.

## Detailed Example of `writeReport` Command

In the following example, myworkdirectory represents a work directory name that might exist on your system.

Command Options Format Example:

> jtharness `-workdirectory` myworkdirectory `-writeReport` `-type` `html` `-filter` `allTests` myreport-directory

See Formatting a Command for descriptions and examples of other command formats that you can use.

Copyright © 2002, 2009, Oracle and/or its affiliates. All rights reserved.