qm :: test :: test :: Test :: Class Test
[hide private]
[frames] | no frames]

Class Test
source code

         object --+        
                  |        
extension.Extension --+    
                      |    
      runnable.Runnable --+
                          |
                         Test
Known Subclasses:
classes.python.BaseExceptionTest, classes.python.ExecTest, classes.command.ExecTestBase, classes.compiler_test.CompilerTest, classes.dejagnu_test.DejaGNUTest, classes.compilation_test.ExecutableTest, classes.file.FileContentsTest

A 'Test' is run to check for correct behavior.

A 'Test' performs some check on the system being tested, and indicates whether the check was successful, or whether the check failed.

Each test class (i.e., class derived from 'Test') describes a set of "arguments". Each argument has a name and a type. The values of these arguments determine the design-time parameters for the test. For example, for a test class that executes program and checks their exit codes, the arguments might consist of the name of the program to execute, and the command-line arguments that should be given to that program. QMTest uses the arguments to prompt the user when creating a new test.

Each test class also defines a 'Run' method that indicates how to run tests in that class. The 'Run' method is responsible for actually performing the test and for reporting the results.

'Test' is an abstract class.

You can extend QMTest by providing your own test class implementation. If the test classes that come with QMTest cannot be used conveniently with your application domain, or if you would like to report more detailed information about passing and failing tests, you may wish to create a new test class.

To create your own test class, you must create a Python class derived (directly or indirectly) from 'Test'. The documentation for each method of 'Test' indicates whether you must override it in your test class implementation. Some methods may be overridden, but do not need to be. You might want to override such a method to provide a more efficient implementation, but QMTest will work fine if you just use the default version.

If QMTest calls a method on a test and that method raises an exception that is not caught within the method itself, QMTest will catch the exception and continue processing.

Nested Classes [hide private]
OutcomeField An 'OutcomeField' contains an outcome.
TestField A 'TestField' contains the name of a test.

Inherited from runnable.Runnable: ResourceField

Inherited from extension.Extension: Type, __metaclass__


Instance Methods [hide private]
  GetTargetGroup(self)
Returns the pattern for the targets that can run this test.
  Run(self, context, result)
Run the test.

Inherited from runnable.Runnable: GetAttachments, GetDatabase, GetId, __init__

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__


Class Variables [hide private]
PREREQUISITES_FIELD_ID The name of the field that contains the prerequisites on which this test depends.
_argument_dictionary A map from argument names to 'Field' instances.
_argument_list A list of all the 'Field's in this class.
arguments A list of the arguments to the extension class.
kind A string giving kind of extension is implemented by the class.
prerequisites  
target_group  

Inherited from runnable.Runnable: EXTRA_DATABASE, EXTRA_ID, RESOURCE_FIELD_ID, resources

Inherited from object: __class__


Method Details [hide private]

GetTargetGroup(self)

source code 

Returns the pattern for the targets that can run this test.

returns -- A regular expression (represented as a string) that indicates the targets on which this test can be run. If the pattern matches a particular group name, the test can be run on targets in that group.

Run(self, context, result)

source code 

Run the test.

'context' -- A 'Context' giving run-time parameters to the test.

'result' -- A 'Result' object. The outcome will be 'Result.PASS' when this method is called. The 'result' may be modified by this method to indicate outcomes other than 'Result.PASS' or to add annotations.

This method should not return a value.

Derived classes must override this method.

Class Variable Details [hide private]

PREREQUISITES_FIELD_ID

The name of the field that contains the prerequisites on which this test depends.
Value:
'prerequisites'                                                        
      

_argument_dictionary

A map from argument names to 'Field' instances.

A map from the names of arguments for this class to the corresponding 'Field'.
Value:
{'prerequisites': <<class 'qm.fields.SetField'> prerequisites>,
 'resources': <<class 'qm.fields.SetField'> resources>,
 'target_group': <<class 'qm.test.test.TargetGroupField'> target_group\
>}                                                                     
      

_argument_list

A list of all the 'Field's in this class.

This list combines the complete list of 'arguments'. 'Field's appear in the order reached by a pre-order breadth-first traversal of the hierarchy, starting from the most derived class.
Value:
[<<class 'qm.fields.SetField'> prerequisites>,
 <<class 'qm.test.test.TargetGroupField'> target_group>,
 <<class 'qm.fields.SetField'> resources>]                             
      

arguments

A list of the arguments to the extension class.

Each element of this list should be an instance of 'Field'. The 'Field' instance describes the argument.

Derived classes may redefine this class variable. However, derived classes should not explicitly include the arguments from base classes; QMTest will automatically combine all the arguments found throughout the class hierarchy.
Value:
[<<class 'qm.test.test.TargetGroupField'> target_group>,
 <<class 'qm.fields.SetField'> prerequisites>]                         
      

kind

A string giving kind of extension is implemented by the class.

This field is used in an application-specific way; for example, QMTest has 'test' and 'target' extension classes.
Value:
'test'                                                                 
      

prerequisites

Value:
[]                                                                     
      

target_group

Value:
'.*'