0

Actually i need to capture run time values and pass it over for the further execution. In sequentially execution its working perfectly but when i do remote executions (in sauce labs) , at that juncture run time values are interchanged between the browser , which leads to failure. (Because each browser will have to get separate value)

Can you please throw me the light in this ?

Thanks, Kris.

3
  • What have your tried so far? Commented Oct 24, 2017 at 7:05
  • I think u can go with setting priorities to test methods which returns values synchronously. guru99.com/test-case-priority-testng.html Commented Oct 24, 2017 at 7:05
  • Thanks for your responses Pradeep & Loki .. got the solution , actually in our scenario same test cases runs in 10 browsers , at run time we capture an id and pass to further execution , as quoted sequential working fine but at parallel execution id's variable getting overlapped with another one which is failing , but now with thread local variable this is fixed Commented Oct 24, 2017 at 8:49

1 Answer 1

0

Thanks ..! Got the solutions went with the ThreadLocal variables concept

Most of the environment specific values in my framework are defined as STATIC.

In Java, Static variables are used to share the data between the threads which means these variable are same across the threads. In that case, when second thread assigns a value to the static variable it overrides the value set by first thread. This causes the problem.

To overcome the above problem, there are two approaches we can consider.

1) All the local variables in java are stored in Stack memory And each thread has it's own stack. So if you change the variables to local variables, it will solves the problem.

2) with the above approach in the existing framework lot of dependencies will break. And it's always not easy to make variables to local. So we have to look for better solution. For this type of situations, we have ThreadLocal variables in java.

http://learn-testing-urself.blogspot.in/2015/05/importance-of-threadlocal-in-parallel.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.