You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Information about the exception with which the test fail #3054
Im working on Allure-robotframework listener, and i want to get information about the exception with which the autotest fell to give the test the status of a fail or broken depending on whether the exception is caused - an AssertionError or an unhandled exception. How can I do that?
Yes, I can parse the error message or the traceback that goes next message, but it doesn't look reliable.
Maybe there is some option to add such information to api for support Allure Framework? I have some more wishes on api, we can discuss it separately if possible.
Could you clarify what you actually want to do? If you want to separate AssertionErrors from other failures, that's not currently possible. Robot in general doesn't separate different exceptions. Very early versions had separate FAIL and ERROR statuses but that didn't bring any real benefits and such separation was removed.
The above said, having some API that can get the actual exception instances might be useful. We could, for example, add a dedicated method to the listener API v3.
The allure framework has integration with multiple frameworks for testing, and for most of them separation of exceptions into assertion and non-assert is used to denote different statuses for the test. Assert - test fell and found a mistake. Non-assert - the test is broken and needs to be fixed, since we did not handle this exception.
I understand the semantical difference between a failure and an error but, as I wrote above, it didn't provide any benefits with Robot. Such distinction won't be added in the future either, but APIs that support getting more info about the exceptions that occurred can be considered. Based on that info external tools can report failures and errors differently if they consider it useful.
Yes, adding an exception instance to API v3 is a good option.
I see it like this: new field exception in robot.result.model.TestCase
Perhaps, I could help to add this functionality in api through the pool request, but I need to know how you think it should look like.
Sorry for long delay with replies. After reading this issue again, my thinking is this:
I don't like the idea to add the exception instance to model object that much. Exceptions can contain lot of references to other objects and can thus consume huge amount of memory. Having it in the model wouldn't help much on its own either. We also needed to save it to output.xml and at that point it wouldn't be the real exception instance anymore.
As I wrote earlier, adding a new listener method that gets the real exception instance could be considered. It could be have a signature like def exception(type, value, traceback) similarly as context manager exit. We could also think should such a method be able to silence the exception by returning True similarly as context managers can.
Would a listener method alone be enough your you @skhomuti? For error reporting purposes you probably needed to store the exception info in the listener until end_test is called but that shouldn't be a big problem.
Having access to the exception type would be very helpful in the RPA context, even if it's only at the API level. The proposed solution sounds very useful for this purpose. Are there any plans to implement the new listener interface method?
Sorry for long delay with replies. After reading this issue again, my thinking is this:
I don't like the idea to add the exception instance to model object that much. Exceptions can contain lot of references to other objects and can thus consume huge amount of memory. Having it in the model wouldn't help much on its own either. We also needed to save it to output.xml and at that point it wouldn't be the real exception instance anymore.
As I wrote earlier, adding a new listener method that gets the real exception instance could be considered. It could be have a signature like def exception(type, value, traceback) similarly as context manager exit. We could also think should such a method be able to silence the exception by returning True similarly as context managers can.
Would a listener method alone be enough your you @skhomuti? For error reporting purposes you probably needed to store the exception info in the listener until end_test is called but that shouldn't be a big problem.
any updates on this topic?
an exception listener that contains the whole traceback stack would be great!
Activity
pekkaklarck commentedon Jan 22, 2019
Could you clarify what you actually want to do? If you want to separate AssertionErrors from other failures, that's not currently possible. Robot in general doesn't separate different exceptions. Very early versions had separate FAIL and ERROR statuses but that didn't bring any real benefits and such separation was removed.
The above said, having some API that can get the actual exception instances might be useful. We could, for example, add a dedicated method to the listener API v3.
skhomuti commentedon Jan 22, 2019
The allure framework has integration with multiple frameworks for testing, and for most of them separation of exceptions into assertion and non-assert is used to denote different statuses for the test. Assert - test fell and found a mistake. Non-assert - the test is broken and needs to be fixed, since we did not handle this exception.
https://github.com/allure-framework/allure-python/tree/master/allure-robotframework
pekkaklarck commentedon Jan 22, 2019
I understand the semantical difference between a failure and an error but, as I wrote above, it didn't provide any benefits with Robot. Such distinction won't be added in the future either, but APIs that support getting more info about the exceptions that occurred can be considered. Based on that info external tools can report failures and errors differently if they consider it useful.
skhomuti commentedon Jan 22, 2019
Yes, adding an exception instance to API v3 is a good option.
I see it like this: new field
exceptioninrobot.result.model.TestCasePerhaps, I could help to add this functionality in api through the pool request, but I need to know how you think it should look like.
pekkaklarck commentedon Aug 19, 2019
Sorry for long delay with replies. After reading this issue again, my thinking is this:
I don't like the idea to add the exception instance to model object that much. Exceptions can contain lot of references to other objects and can thus consume huge amount of memory. Having it in the model wouldn't help much on its own either. We also needed to save it to output.xml and at that point it wouldn't be the real exception instance anymore.
As I wrote earlier, adding a new listener method that gets the real exception instance could be considered. It could be have a signature like
def exception(type, value, traceback)similarly as context manager exit. We could also think should such a method be able to silence the exception by returningTruesimilarly as context managers can.Would a listener method alone be enough your you @skhomuti? For error reporting purposes you probably needed to store the exception info in the listener until
end_testis called but that shouldn't be a big problem.skhomuti commentedon Aug 20, 2019
Sounds good!
ottonautti commentedon Jun 26, 2020
Having access to the exception type would be very helpful in the RPA context, even if it's only at the API level. The proposed solution sounds very useful for this purpose. Are there any plans to implement the new listener interface method?
suiluj commentedon May 28, 2025
any updates on this topic?
an exception listener that contains the whole traceback stack would be great!