-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added allure-robotframework adapter #214
Conversation
def __init__(self, logger_path=DEFAULT_OUTPUT_PATH): | ||
self.reporter = AllureReporter() | ||
self.logger = AllureFileLogger(logger_path) | ||
self.stack = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stack basically duplicates OrderedDict inside AllureReporter.
I think we can simply make the 'item_type' argument of AllureReporter.get_last_item optional, so it would return the last element inserted in the default case, this way you will get rid of this stack of uuids and use only AllureReporter methods. @sseliverstov what do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ehborisov yes, i think I thought about it when I wrote this code, but I tried not to affect the code of commons. I think, now it can already be rewritten
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added use get_last_item where possible. I can't refuse use self.stack because step results does not have the uuid attribute now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, yeah, I apparently thought steps have uuids. Lets keep it.
uuid = uuid4() | ||
self.reporter.get_item(self.stack[-1]).children.append(uuid) | ||
self.stack.append(uuid) | ||
test_case = TestResult(uuid=uuid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a right place to generate a historyId from attributes['longname']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
def test_passed_with_step(self): | ||
assert_that(self.allure_report, has_test_case('Passed Case With Step', | ||
with_status('passed'), | ||
has_step('BuiltIn.No Operation', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if 'BuiltIn.No Operation' is a robot framework constant, I would suggest to move it into some file with test constants for all tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
allure-robotframework/src/utils.py
Outdated
|
||
|
||
def get_allure_tags(tags): | ||
return [Label('tag', tag) for tag in tags] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LabelType.TAG from allure_commons.types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
allure-robotframework/src/utils.py
Outdated
|
||
|
||
def get_allure_thread(pool_id): | ||
return Label('thread', 'Thread #{number}'.format(number=pool_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use LabelType.THREAD from allure_commons.types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also you can add "host" label as well
(see https://github.com/allure-framework/allure-python/blob/master/allure-pytest/src/listener.py#L107)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
self.append_message_to_last_item_log(message, level) | ||
|
||
# listener event ends | ||
def start_new_group(self, name, attributes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can probably use attributes['metadata'] to add links to the suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I wanted to, but the metadata on different projects is different. Is it possible to parameterize this? For example, we use Task_url to specify the task number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skhomuti, @ehborisov is it ready for merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skhomuti maybe just add a link to the suite if if was specified at Metadata section as "Metadata Link some_url"
(it would look something like this, I believe:
link = attributes['metadata'].get('Link', None)
if link:
...
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sseliverstov almost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, @skhomuti do you fix it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will fix it. Later I'll think about a more universal solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
tnx @skhomuti ! |
//: # (
. Thank you so much for sending us a pull request!
.
. Make sure you have a clear name for your pull request.
. The name should start with a capital letter and no dot is required in the end of the sentence.
. To link the request with isses use the following notation: (fixes #123, fixes #321)
.
. An example of good pull request names:
. - Add Russian translation (fixes #123)
. - Add an ability to disable default plugins
. - Support emoji in test descriptions
)
Context
Added allure-robotframework adapter.
Its a listener using allure-python-commons and allure-python-commons-test.
Checklist