English 中文(简体)
通过对JUSP测试的校正当地变量
原标题:Passing a thread local variable to JUnit test

我有一线透镜,它使当地人阶级变异,并开始进行单位测试:

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) {
        // ...
    }    
}

现在,我想在登峰造影的地方标码/code>旁听(或参考)。 这是可能的吗? 我试图把它简单地保留下来,但复杂的事情似乎并不明确(因此我增加了一些代码): F物体需要目前的<条码>FooThread<>>> 代码。

问题回答

no idea why do you need threadLocal. if you need run same tests with different parameters then just create a list of those parameters and use parameterized tests (junit s native or of many libraries like zohhak or junit-dataprovider).

如果出于任何原因,你需要在检测中接近当地人,那么你还需要在检测中添加数据,因为在进行测试之前,你没有知道将使用什么来进行测试。 但是,似乎仍然好像你能够写一个检验标准,以检查贵国的法典是否正确使用校对地方的测试,然后是参数的测试,以检查贵国的法典是否正确处理从校对取得的数值。 地方





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...