Передача локальной переменной потока в тест JUnit ⇐ JAVA
-
Anonymous
Передача локальной переменной потока в тест JUnit
I have a thread which inits a thread local class variable and starts with running unit tests:
public class FooThread extends Thread { TestRunner runner; Foo foo; public void run() { initSomeThreadLocalStuff(); // inits foo and runner runner.runJUnitTests(); // JUnitCore.runTest(TestClass) } private void initSomeThreadLocalStuff() { foo = new Foo(this); // ... } } public class Foo() { public Foo(FooThread t) { // ... } } Now I want to run the JUnit tests with access (or a reference) to the thread local object foo. Is this possible? I tried to keep it simple but the complicated thing seemed not to be clear (so I added some code): the Foo object needs the current FooThread to be initialized.
Источник: https://stackoverflow.com/questions/279 ... junit-test
I have a thread which inits a thread local class variable and starts with running unit tests:
public class FooThread extends Thread { TestRunner runner; Foo foo; public void run() { initSomeThreadLocalStuff(); // inits foo and runner runner.runJUnitTests(); // JUnitCore.runTest(TestClass) } private void initSomeThreadLocalStuff() { foo = new Foo(this); // ... } } public class Foo() { public Foo(FooThread t) { // ... } } Now I want to run the JUnit tests with access (or a reference) to the thread local object foo. Is this possible? I tried to keep it simple but the complicated thing seemed not to be clear (so I added some code): the Foo object needs the current FooThread to be initialized.
Источник: https://stackoverflow.com/questions/279 ... junit-test