Skip to content

Conversation

@namsonx
Copy link
Collaborator

@namsonx namsonx commented Dec 5, 2022

Update selftest using pytest for JsonPreprocessor package

@HolQue
Copy link
Collaborator

HolQue commented Dec 5, 2022

Hi Son,

I wanted the python-jsonpreprocessor repository to support the TestTrigger mechanism. Therefore I added a TestExecutor 'executerobottest.py' to the atest folder.

#31

The execution causes the following error message:
File 'D:/RobotFramework/python39/lib/site-packages/testdata/config/07_json_format/json_format_01.json' is not existing!
It's interesting that the testdata are expected to be present within the site-packages.

This happens in all tests. Therefore all tests fail.

The atest folder already contains a script 'run.py' that also executes the test. With 'run.py' this problem does not occur. Most of the tests are passed, except "Test Sub Data Structure 06":

Test Sub Data Structure 06 :: Updated more than 1 parameter with n... | FAIL |
{'preproStructure': {'addNewPreParam': 'Adds new param', 'newStruct': {'check1': 1, 'check2': 2}, 'variable_01': '1'}, 'preproTest': {'param_01': 'Updated new value'}} != {'preproStructure': {'addNewPreParam': 'Adds new param', 'newStruct': {'check1': 1, 'check2': 2}, 'variable_01': 1}, 'preproTest': {'param_01': 'Updated new value'}}

The main difference between executerobottest.py and run.py is: run.py uses robot.run() to execute the tests, whereas executerobottest.py uses subprocess.call().

And executerobottest.py does some things more, like the handling the algebraic sign of the return value and passing command lines to the Robot Framework.

We have now two possibilities:

  1. Extend run.py by the missing features
  2. Fix the import path problem of JSON files to enable the execution of executerobottest.py

I would prefer the second option because this would make it possible to handle the test execution in every repository in the same way with the same mechanisms, like described in

https://github.com/test-fullautomation/RobotFramework_AIO/blob/develop/test/documentation/RF(AIO)-TestConcept.pptx

It would also be interesting to learn about the root cause for this deviating behavior.

@namsonx
Copy link
Collaborator Author

namsonx commented Dec 6, 2022

Hello Holger,

I already deleted 'run.py' and replaced by 'run.bat' for Windows and 'run.sh' for linux.
Currently, we just execute 'run.bat' or 'run.sh' to run selftest, and selftest now develop using python instead of robot.
Do we have any test mechanism for pytest?

@HolQue
Copy link
Collaborator

HolQue commented Dec 6, 2022

Hi Son,

for executing pytests you have to use the executepytest.py

I have updated
#31
to make this script available for you.

@test-fullautomation
Copy link
Owner

Hi both,
is your problem test execution problem solved?
Thank you,
Thomas

"${gPreproString}": "Override string param in imported file.",
"params":{
"global":{
"glob":{
Copy link
Owner

@test-fullautomation test-fullautomation Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,
where is "glob" coming from?
I was not asked for this and I did therefore not agree to this change.
I'm sorry that you need to do some rework now.

Python has a "global" keyword for global parameters:
https://www.w3schools.com/python/python_variables_global.asp

We use what users expect. Therefore "global" is the correct key here to indicate a global scope.

In addition "glob" has another meaning in english language.

Thank you,
Thomas

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Thomas,

Due to the "global" is reserved keyword of Python, so some scenarios of pytest failed when I name the key of Json object is "global".
That the reason I just changed this key name of Json configuration file.

Thank you,
Son

Copy link
Owner

@test-fullautomation test-fullautomation Dec 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,
O.K. I understand your motivation. But this is no solution to make tests running.
Can not be that the test tool makes a global syntax change required.,,
Can you please discuss with Cuong if he has an idea what to do.
Thank you,
Thomas

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,
what is the status here?
Thank you,
Thomas

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Thomas,

I created new commit to use object name 'global' instead of 'glob'.
I also run this selftest on both Windows and OSD6.

Thank you,
Son

@test-fullautomation
Copy link
Owner

Hi Son,
I like the structure and way you do the testing now. This is a very good proposal.
Please look into my findings.
Thank you,
Thomas

Copy link
Owner

@test-fullautomation test-fullautomation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,

please check my findings.

Thank you,
Thomas

"${gPreproString}": "Override string param in imported file.",
"params":{
"global":{
"glob":{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,
what is the status here?
Thank you,
Thomas

@test-fullautomation
Copy link
Owner

Hi Son,
what is the status here?
Thank you,
Thomas

Copy link
Owner

@test-fullautomation test-fullautomation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,

looks good to me except of the use of "glob" instead of "global".

What is the status here?

Thank you,
Thomas

@test-fullautomation test-fullautomation self-requested a review January 9, 2023 14:43
@namsonx
Copy link
Collaborator Author

namsonx commented Jan 9, 2023

Hi Son,

looks good to me except of the use of "glob" instead of "global".

What is the status here?

Thank you, Thomas

Hello Thomas,

I created new commit to use object name 'global' instead of 'glob'.
I also run this selftest on both Windows and OSD6.

Thank you,
Son

@test-fullautomation
Copy link
Owner

test-fullautomation commented Jan 11, 2023

Hi Son,
very nice!

How did you solve the "glob" -> "global" problem now. I didn't find the place in the changed code.

Thank you,
Thomas

Copy link
Owner

@test-fullautomation test-fullautomation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Son,
looks good to me now!
Thank you,
Thomas

@test-fullautomation test-fullautomation merged commit b89f479 into develop Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants