Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Run a python test script with RQM

 i have a python script containing a function add(X1,X2) and return X1+x2.


i write a python test script (add_test.py) to which calls my function to test.

import pytest
import pythondemo


def test():
    value1 = 4.0
value2 = 4.0
    result = pythondemo.add(value1, value2) %%function to test
    assert result == 8.0

My goal is to run the script add_test.py through RQM through command line adapter and observe the behaviour like in pytest. 

i am able until now to do a connexion to RQM with command line adapter. 

My concern is to write the batch file which calls and executed my python test script (add_test.py) to pass through Command field, how do write such a batch file? i am not an expert. 

Which argument is passed through the argument field? In my case is it value1 and value2?

0 votes



3 answers

Permanent link
You can call the python script directly without creating a DOS wrapper.

You can call is the same way you do on the command line:
    python c:\python-scripts arg1 arg2

Just make sure you exit with
SystemExit(int verdict)
    
To provide a verdict to to ETM

0 votes


Permanent link

 Writing a batch or shell script is no rocket science. I would suggest to search the internet for tutorials like https://www.tutorialspoint.com/batch_script/index.htm and do them.


The code below is an example I wrote based on the help and the article mentioned by Subhajit.

The first line just prints Test, the second prints all parameters passed. The rest of the lines create some files and links that are returned and hooked up to the test result.

You could put your call of the python script into the example below and play around with it.

echo Test
echo %*

set > c:\Temp\SetEnv.txt

echo SomeDocument=C:/shared/SomeDocument.txt >> %qm_AttachmentsFile%
echo SetEnv=c:/Temp/SetEnv.txt >> %qm_AttachmentsFile%
echo Jazz.net=https://jazz.net >> %qm_AttachmentsFile%
echo Google=https://google.com >> %qm_AttachmentsFile%

echo CustomAttributesFile is %qm_CustomAttributesFile% > c:\Temp\Files.txt
echo CustomPropertiesFile is %qm_CustomPropertiesFile% >> c:\Temp\Files.txt
echo ExecutionVariableFile is %qm_ExecutionVariablesFile% >> c:\Temp\Files.txt
echo AttachmentsFile is %qm_AttachmentsFile% >> c:\Temp\Files.txt
echo Files=c:/Temp/Files.txt >> %qm_AttachmentsFile%

0 votes


Permanent link

 1st create a .bat file and use it to run the python script. Do it with out RQM.

To run the script using RQM, please check

1 vote

Comments

thanks for you reply,


i wrote this article before, but the contain of the batch file myTestTool.bat is not shown so that for someone like me who has no idea on how to write a batch file, can use it as input to see how it uses the python script to test. Also, the relationship between the Arguments arg1 arg2 arg3 and the myTestTool.bat is not clarified. Are they the input parameters to pass to the python function to test which seems to be called in myTestTool.bat?

mike

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: May 03 '21, 4:30 p.m.

Question was seen: 2,049 times

Last updated: May 05 '21, 11:23 p.m.

Confirmation Cancel Confirm