-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
allure step doesn't work if is used in global before :all hook #421
Comments
This is by design. |
@andrcuns for other languages like JAVA, JS allure provides this possibility. Could you suggest workaround for this case? |
I'm not sure how other frameworks could support it because the problem is in the core concept of how report works.
|
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days |
@andrcuns containers have |
Oh, You are correct, for some reason I was completely sure that |
I had to refresh my memory on rspec implementation and while this It's very tricky to detect that actual hook is running because rspec doesn't really mark it in the existing events and specific event also doesn't exist for that. |
I'm playing around a bit with it; maybe, this could be a path forward? Such methods for lifecycle: def start_before_test_case(test_result)
unless current_test_result_container
return logger.error { 'Could not start before test case, no container is running.' }
end
clear_step_context
logger.debug { "Starting before test case: #{test_result.name}" }
test_result.start = Allure::ResultUtils.timestamp
test_result.stage = Allure::Stage::RUNNING
current_test_result_container.befores.push(test_result)
current_test_result_container.children.push(test_result.uuid)
@current_test_case = test_result
end
def update_before_test_case
unless @current_test_case
return logger.error { 'Could not update before test case, no before test case is running' }
end
yield(@current_test_case)
end
def stop_before_test_case
unless @current_test_case
return logger.error { 'Could not update before test case, no before test case is running' }
end
logger.debug { "Stopping before test case: #{@current_test_case.name}" }
@current_test_case.stop = Allure::ResultUtils.timestamp
@current_test_case.stage = Allure::Stage::FINISHED
clear_current_test_case
clear_step_context
# not saving @current_test_case is intended
end Those still need updates b/c of the multiple containers, and from what I see, I need to bring a copy of all befores and afters to the last container from previous ones. And such to the formatter: def example_group_started(example_group_notification)
description = example_group_notification.group.description.then { |desc| desc.empty? ? 'Anonymous' : desc }
lifecycle.stop_before_test_case
lifecycle.start_test_container(Allure::TestResultContainer.new(name: description))
lifecycle.start_before_test_case(Allure::TestResult.new(name: description))
end
def example_finished(example_notification)
lifecycle.update_test_case(&update_test_proc(example_notification))
lifecycle.stop_test_case
end |
There might be some complications, because Though I'm not sure if it's the same for the ones in test container, a json schema would be nice. |
In this flow, the biggest pain in the ass is the after-steps. There's no easy way within the current codebase to differentiate between after-steps in different contexts and put them in appropriate containers. |
If You want to take a stab at this, feel free to propose a PR. I'm afraid I won't have time to try and dig deeper in how to better solve this issue. |
I use
allure-rspec 2.17.0
rspec 3.11.0
STR
Result:
There is no "do something" step in Allure report
Also see errors in console
The text was updated successfully, but these errors were encountered: