Where to put 'import', function defs etc.

Rowan Sylvester-Bradley rowan at sylvester-bradley.org
Sun Apr 12 15:13:52 UTC 2009


Hi,

I'm trying to use QMtest for the first time and am having some difficulties 
getting to grips with it. I hope someone can answer the following questions 
for me (or tell me where to find a tutorial explaining all this). I'm trying 
to test a remote device so all my tests send messages via the serial port 
and receive serial responses. I'm trying to use the python.ExecTest test 
class, and write all my tests in Python.

1. Where do I put 'import' statements, function definitions etc. that my 
tests need?
2. If many of my tests need the same imports and functions, is there a 
generic place to put the imports and function defs where they will be 
accessible to all tests, or do I have to put them in every test?
3. It looks as if each test in QMtest must be self contained and atomic, 
i.e. it must not depend on which tests have already been run, or in which 
order. If this is right, I don't understand how to deal with a situation 
that needs a long sequence of messages to the device under test and 
responses. The prerequisite concept doesn't seem to solve the problem, 
because (as I understand it) although it guarantees that some tests will 
have been run before the current test, it does not guarantee in which order, 
or whether other tests will also have been run, all of which will change the 
state of the device under test. If I genuinely have to make every test 
independent of what's gone before, I will have to start each test with a 
reboot, and then add commands to the test one by one - so if my test 
sequence consists of reboot, send command A, receive response A, send 
command B, receive response B, send command C, receive response C I will 
have to have tests 1 (reboot, send A receive A), 2 (reboot, send A, receive 
A, send B, receive B) and 3 (reboot, send A, receive A, send B, receive B, 
send C, receive C). If I have 100 or more steps in my sequence, this could 
be very tedious. If I could force my tests to run in sequence, I could just 
have tests 1 (reboot, send A, receive A), 2 (send B, receive B) and 3 (send 
C, receive C).
4. How do I make the execution of a test dependent on the results of 
previous tests (i.e. how do I access the results of previous tests from 
within the Python code of a new test)?
5. How do I make the sequence of tests dependent on the results of previous 
tests? E.g. if test B passes, do test C and then test D, or if it fails, do 
test E and then test F.
6. If I'm using the "Python Source Code" part of the python.ExecTest, and 
not the Python Expression section, what is the recommended way of indicating 
to QMtest whether the test has passed or failed?
7. Should or must I make every comparison of expected results with actual 
results a separate QMtest test, or can/should I have multiple comparisons 
within a single QMtest test? In the latter case there would obviously be 
multiple ways in which the test could fail, which would need to be reported.
What are "resources"? Does using these help me solve any of my problems?
8. If I want to create a new test class, where do I put the class 
definition?
9. Is there a simple example of how to add a new test class written in 
Python somewhere?

Many thanks for your help - Rowan 





More information about the qmtest mailing list