-
Notifications
You must be signed in to change notification settings - Fork 2.4k
setup/teardown for every test run in a templated test #2668
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
Comments
Did you try using the http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown Here is a sample test suite
with the output being
You can even override the default Test Teardown for a single iteration. Here's a sample
Is this what you are looking for? |
Hi @bkhouri, thanks for this very interesting reply. This indeed works and does what I want, so it helps :) However, what I was trying, and where the Test Teardown lacked, was
In this case, the templated test cases run, but there's only one setup/teardown:
I wasn't clear to me from the docs that this would make a difference. The reason for why I chose a non-global template definition was for flexibility: For templating diffierent test cases I won't need a file for each. |
When you use templates and want run multiple iterations per test, then the keyword used as a template needs to take care of possible iteration specific setup/teardown activities. With keywords implemented in Python you'd use something like *** Keywords ***
Test Iteration KW
[Arguments] ${var}
Iteration Setup KW
Log To Console In Test case: ${var}
[Teardown] Iteration Teardown KW |
I would also be interested to have the global setup and teardown routines, defined in the *** Settings *** section, run after each iteration of the template. Is this place the good place to ask for an update or request a feature? 🤔 |
Could you clarify why that would be beneficial compared to what's already possible by using keyword teardown? |
I prefer test setup/teardown being executed once per test. Even if you were able to convince me that they should be run for each templated iteration, changing the behavior would so badly backwards compatibility that it couldn't realistically be done. The only possible solution would be adding some new setting to control this but I seriously doubt that's worth the effort. |
Not sure why I reopened this in 2022, probably by mistake. Anyway, now that user keywords can even have an explicit setup (#4747) I see no reason to add any new functionality to specify setup/teardown for iterations. |
Something that I've missd many times now for using robot test in a templated and more of a TDD manner is a teardown keyword that allows me to define which keyword to run whenever one "iteration" of a templated test is run, setup respectively.
I'm dealing with services and networking mocks that need a clear state whenever a test starts. If one test iteration fails, the state will not be "fresh" without a teardown followed by a setup.
The text was updated successfully, but these errors were encountered: