Is context property shared a cross test cases ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is context property shared a cross test cases ?
I am creating "context.variableName = new foo()" for every test case in EVENTS under testrunner.beforerun
Here are the steps for every test case:
1. Create a context variable in beforerun
2. Test Steps (access the context variable in the test steps)
3. kill context variable in afterrun
I have 5 test cases in a test suite, so when I execute from Test suite level in parallel. Every time one or the other test case fail because it could not find context variable.
My guess:
Context variable are shared across the test cases, as I am killing the context variable afterrun its creating problem.
What I need to Understand:
Is context property shared a cross test cases ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@Community, your thoughts?
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am sorry but I don't know the answer to the question. Instead I would ask why use this approach? What is your use case here? If you need a global variable, why not just use a project property instead?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use case: Initialize the java class once and use the class object in all the test cases.
I should be able to run single test case.
I should be able to run test suit.
We can't set objects as project properties.
I don't think this is a new or unique use case.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not sure if I understand the use case, but I believe I encountered 'something' similar when I used a filter request event handler for authorization header injection. Each request needed it's particular (openid) authorization header. Based upon a parameter from the request it went and find the corresponding authorization header that was available as a project property. These authorization headers (tokens) were created at the first test suite of my project.
This all worked fine when running in sequence, but for a test suite that ran its testcases in parallel I noticed this went wrong. Problem was that the filterRequest was not thread safe, so the parallel runs interfered with eachother and wrong authentication headers were submitted. I could not find away to get around this, so in my case, I solved this by 'manualy' adding the authentication headers for these requests in parallel and used a test suite setup script to detect the run type. When this run type equaled "parallel" I disabled the event handler. Teardown made sure to enable it again for my next (sequence) test suites.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Community, thanks for your help!
@Marramreddy, have you found the answer to your question? Please share the solution with us.
Tanya Yatskovskaya
SmartBear Community and Education Manager
