test-fullautomation / robotframework

Generic automation framework for acceptance testing and RPA
http://robotframework.org
Apache License 2.0
1 stars 0 forks source link

"THREAD" Keyword Error - 'str' object has no attribute 'test_case_errors' (framework.py) #95

Open bhd1hi opened 1 week ago

bhd1hi commented 1 week ago

An exception error occurs when running a sample test case that utilizes the THREAD keyword. The error message states: "'str' object has no attribute 'test_case_errors'". Steps to Reproduce:

Download Attached Files: Download the following files attached to this issue:

  1. voltage.py (Python keyword file)
  2. dev__bits_platform_thead_sample_v02.robot (Test case file)
  3. Log issue_95_console.log Execute Test Case: Run the test case within the devbits_platform_thead_sample_TAF.robot voltage_py.txt Note: change file extension to" .py" [devbits_platform_thead_sample_TAF_robot.txt](https://github.com/user-attachments/files/16894042/dev__bits_platform_thead_sample_TAF_robot.txt) Note: change file extension to ".robot" .robot file. Expected Behavior:

The test case should execute successfully using the THREAD keyword.

Actual Behavior:

The test case execution fails with the error message: "'str' object has no attribute 'test_case_errors'". and also another exception messages.

Additional Information:

  1. We suspect the error originates from the framework.py file within the ta_framework_2.0.0 library.
  2. The newly created voltage keyword (voltage.Validate All Channels Voltage) functions correctly when executed outside of a THREAD context.

Please let us know if you require any further details or specific test environments to aid in the troubleshooting process. Thank you for your support.

test-fullautomation commented 1 week ago

Hi Holger, please look into this with high priority. Thank you, Thomas

HolQue commented 1 week ago

Status: Error reproduced within own test setup at my computer. Continuing now with investigation.

HolQue commented 1 week ago

Hi Datta,

within your own keyword Python library you access two further keyword libraries, also implemented in Python: the bits_platform.py belonging to the BITS-Platform, and the framework.py belonging to the TA-Framework.

The bits_platform.py you import with BuiltIn().get_library_instance() but the framework.py you import immediately with

from generic.framework.framework import framework

I am not sure about the differences but I tried to handle the framework library in the same way as the bits_platform library, because this line

framework.set_test_status_to_unknown(info_text)

causes the error message you mention in this issue.

My proposal is to import also the framework library with BuiltIn().get_library_instance(). On my computer, with own test files, it works.

This is my code (the import paths may differ from your paths because of another file system structure in my test setup):

Import of TA-Framework library within my robot test file

Library ../libs/framework.py

In my own keyword library (mysystem.py) I define a test keyword that is simply a mapping between an own keyword and a TA-Framework keyword

@keyword
def mysystem_set_test_status_to_fail_and_continue(self):
    tafw_lib = BuiltIn().get_library_instance('framework')
    tafw_lib.set_test_status_to_fail_and_continue(error_type="REANIMATION", info_text="REANIMATION error info")

In my robot test file I call this keyword

mysystem_set_test_status_to_fail_and_continue

Debug log file looks good

INFO - MainThread> +--- START KEYWORD: mysystem.Mysystem Set Test Status To Fail And Continue [ ]
ERROR - An 'PERFORMANCE' error has occured!
INFO - PERFORMANCE error info
INFO - Set tag 'robot:recursive-continue-on-failure'.
FAIL - The test result is set to 'FAIL' but the test case will be continued.
INFO - MainThread> +--- END KEYWORD: mysystem.Mysystem Set Test Status To Fail And Continue (3)