1.Define the environment variable required by the test.

In the example (Test2.java), the test case SampleStringValue() checks if the sampleValue that is passed in equals Hello.

The harness requires the sampleValue environment variable to run the test. Because the value for sampleValue cannot be known ahead of time, it must be provided in the configuration interview by the user.

The decodeArg(String[],int)method decodes the argument and passes the value to the sampleValue environment variable. The harness uses the -stringValueargument in accordance with the executeArgs argument entry in the test description file.

2.Specify the environment value using the test description entry.

The test description file (index.html) can use either the executeArgs or context to identify the environment variables required by the test. In our example, the environment variable is called sample.string.value.

The following is an example of using the executeArgs argument (also see

SimpleTestSuite/tests/sample/pkg2/index.html).

<tr>

<td scope="row"> <b>executeArgs</b> </td> <td> -stringValue $sample.string.value </td> </tr>

As an alternative, you can use the context field. If you use the context field in the test description, the argument in the decodeArgs(String,int) method must be changed accordingly with -sample.string.valueused as the argument.

The following is an example of using the context field.

<tr>

<td scope="row"> <b>context</b> </td> <td> sample.string.value </td> </tr>

3.Write the configuration interview class.

The Framework provides a basic configuration interview that defines parameters common for all Java ME technology test suites. If your test suite requires additional parameters, you must create a sub-interview and link it to the Framework interview.

In the SampleInterview example, the test requires an additional parameter. The following steps describe how to create the sub-interview that adds the additional parameter to the configuration.

30 Java ME TCK Framework Developer’s Guide • July 2007

Page 50
Image 50
Sun Microsystems 1.2 manual Define the environment variable required by the test, Write the configuration interview class