C H A P T E R 24 |
Classless Card Files |
To define test-related data, such as properties and required files, for the test classes defined in one directory, you use the special source file comments described in Test Class and Case Comment Blocks. To make such test-related information applicable to a collection of classes whose .java files reside in different directories, you can define the information in a card file located in a common parent directory that directly contains no classes. Declaring data that applies to a family of classes in a card file minimizes coding and can simplify maintenance, for example, when the name of a required file changes.
Note - Although you can also define card files at the class level, source file comments are recommended instead. See Writing Card Files Manually for details.
Do not accidentally create a classless card file in a directory that contains test classes. By default, your card file is replaced by one generated from the source file comments. |
Card files are optional. When present, with one exception, a card file must be named package.card, where package is the name of the package associated with the same directory. For example, consider the package com.hypotheticaltestco.uitests. The card file in the directory named packWorkDir/src/client/com/sometestco/uitests/ must be named uitests.card.
The exception is a card file in a directory associated with no package, such as packWorkDir/src/client/com/sometestco/. Such a card file must be named default.card.
The definitions in a card file apply recursively to classes defined in all subdirectories, unless overridden by a definition in a subordinate directory’s card file or a comment in a class source file. See Precedence for details.
In general syntax, a card file is a Java programming language properties file. For a technical description of property file syntax, see http://java.sun.com/j2se/1.5.0/docs/api/java/util/
Properties.html#load(java.io.InputStream)
However, there are two differences:
.requires=/x .requires=/y
In a card file, .requires has two values, /x and /y.
You can define a property in a card file with the following syntax:
.property PropertyName=DefaultValue
.property MaxDistance=12
You can add the property attributes scope, readonly, and doc as described in @card.property.
You can specify the values used to compute the default severity of test failures as in the following examples:
.attribute functionality=value .attribute impact=value
See @card.attribute for details.
You can specify keywords that testers can use to filter (subset for execution) tests in subdirectories. The syntax is:
.keyword=keywordList
keywordList is a space-separated list of keywords. For example:
.keyword=interactive security
To see the current list of keywords and their definitions, launch the harness and create or open a work directory. Choose Configure > Edit Configuration or Configure > New Configuration. In the Test Selection section of the interview, answer Yes to Specify Keywords? The More Info pane displays the current list of keywords.
If tests in different subdirectories require files to run, such as media samples or libraries, you can define them in an common ancestor card file. Specify ordinary required files similar to this example:
.requires=resources/my_resource1 .requires=resources/my_resource2
By the rules in Naming, Scope, and Syntax, this example is logically equivalent to the following, which cannot be expressed in a standard properties file:
.requires=/my_resource1,my_resource2
Path names in .requires entries are relative to packWorkDir.
For required zip or JAR files, use .ziprequires, for example:
.ziprequires=lib/my-lib.zip .ziprequires=lib/my-lib2.jar