The qmtest create creates a new
extension instance. For example, this command can be used to
create a new test or resource. For a list of the kinds of
extensions supported by QMTest, run qmtest extensions.
The kind
must be one of these extension kinds.
If the --id
option is provided then
the new instance is created in the test database. The argument to
the --id
option gives the name of the
instance. Otherwise, the extension is written as XML to the
filename specified by --output
option, or
to the standard output if no --output
is
specified.
The descriptor specifies an extension class and (optionally)
attributes for that extension class. The form of the descriptor is
class
(attributes
),
where the attributes are of the form
attr
=
"val
". If there
are no attributes, the parentheses may be omitted.
The class
may be either the path
to an extensing extension or a QMTest class name in the form
module.class
. If the
--id
option has been provided, QMTest
will look for an existing extension in the test database named
class
. If the
--id
option has not been provided, QMTest
will look for an XML file named class
.
In either case, if an existing extension cannot be found, the
class
is interepreted as the name of an
extension class.
The attributes used to construct the extension instance come
from three sources: the attributes in the extant extension (if the
class
is the path to an extension
file), the --attribute
options provided
on the command line, and the explicit attributes provided in the
descriptor. If multiple values for the the same attribute name
are provided, the value used is taken from the first source in the
following list for which there is a value: the rightmost attribute
provided in the descriptor, the extension file, or the rightmost
--attribute
present on the command
line.
The create command accepts these options:
-a
name=value
,
--attribute
name=value
Set the target class argument
name
to
value
. The set of valid argument names
and valid values is dependent on the extension class in use.
-i
id
,
--id
id
Add the extension instance to the database, using
id
as the name of the instance.
-o
file
,
--output
file
Write the extension instance to
file
.
This command:
qmtest create -a format=stats -o rs
result_stream text_result_stream.TextResultStream(filename="rs")
creates a file called rs
containing an
instance of TextResultStream
.
This command:
>
qmtest create --id=simple -a program=testprog test command.ExecTest
creates a test named "simple" that executes the program
testprog
:
This command:
>
qmtest create --id=copy test simple
creates a copy of the "simple" test, naming the new version "copy".