[
https://issues.jboss.org/browse/ARQ-127?page=com.atlassian.jira.plugin.sy...
]
Sarah Faller commented on ARQ-127:
----------------------------------
have been taking a look at the issue and it seems like the testRunnerAdaptor
(deployableTest) is not getting initialized correctly when a new thread is spawned. It is
able to see the correct object but the content is null and not initialized properly. Below
is the output of the code with some print statements I added. The number (#) refers to
lines of code
++++++++---------------+++++++++BeforeSuite+++++++++++--------------+++++++++++++++++++
Current thread: main (1)
i am in setting the adaptor
++++++++--BEFORE SUITE DEPLOYABLE ADDRESSS++
java.lang.ThreadLocal@38022758
++++++++---------------++++++++++BeforeClass++++++++++--------------+++++++++++++++++++
Current thread: testNG-tests-1 (2)
++++++++--before class DEPLOYABLE ADDRESSS++
java.lang.ThreadLocal@38022758
this is the adaptor in before class = null (3)
in verify test runner adaptor
++++++++--verify test runner DEPLOAYBALETEST ADDRESSS++
java.lang.ThreadLocal@38022758
NULLCHECK IS TRUE++++++++++++++++
Here you can see that the main thread (1) in Before suite sets the adaptor. And the
address of that is java.lang.ThreadLocal@38022758.
Then TestNG spawns a new thread for before class method called testNG-tests-1 (2). The
object of the adaptor has the same address: java.lang.ThreadLocal@38022758. When we try to
do
{code:java}
System.err.println("++++++++++---------thisistheadaptorinbeforeclass"+deployableTest.get());
(3)
{code}
It prints null. The content does not exist. Then in BeforeClass, once
{code:java}verifyTestRunnerAdaptorHasbeenSet() {code}
method is executed the null check is true, and the illegalStateException is thrown causing
the program to crash.
I did some research on local thread which is the type of TestRunnerAdaptor:
{code:java}ThreadLocal<TestRunnerAdaptor>deployableTest=new
ThreadLocal<TestRunnerAdaptor>(); {code}
https://stackoverflow.com/questions/6327913/how-to-continue-object-from-t...
http://tutorials.jenkov.com/java-concurrency/threadlocal.html
It seems like what is needed is InheritableThreadLocal.
"The InheritableThreadLocal class is a subclass of ThreadLocal. Instead of each
thread having its own value inside a ThreadLocal, the InheritableThreadLocal grants access
to values to a thread and all child threads created by that thread."
So I changed it to
{code:java}privatestaticInheritableThreadLocal<TestRunnerAdaptor>deployableTest=newInheritableThreadLocal<TestRunnerAdaptor>();{code}
And now I am actually able to run the tests in parallel on my end.
Please let me know you thoughts on this.
Verify TestNG Parallel test exeuction
-------------------------------------
Key: ARQ-127
URL:
https://issues.jboss.org/browse/ARQ-127
Project: Arquillian
Issue Type: Feature Request
Components: Extension - Performance, Test Harness Integration
Reporter: Aslak Knutsen
Assignee: Stale Pedersen
Priority: Critical
Fix For: 2.0.0.Beta1
Attachments: testng-parallel.zip
Verify that Arquillian behaves correctly when ran in TestNG Parallel modes.
--
This message was sent by Atlassian Jira
(v7.12.1#712002)