如何使用ResourceTestRule打开单元测试中的跟踪?

Mar*_*ack 9 dropwizard

我正在使用带有球衣的dropwizard.我在资源中的路径有问题,并想调试它.你如何为此配置泽西环境变量?以下不起作用.

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .addProperty("jersey.config.server.tracing.type", "ON")
    .build();
Run Code Online (Sandbox Code Playgroud)

and*_*kis 8

以下调用ResourceTestRule设置了具有WARN级别的默认日志记录:

static {
    BootstrapLogging.bootstrap();
}
Run Code Online (Sandbox Code Playgroud)

要覆盖,我BootstrapLogging再次调用并在ResourceTestRule创建后在我的测试类中指示所需的日志记录级别,例如:

import ch.qos.logback.classic.Level;
import io.dropwizard.logging.BootstrapLogging;
...

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .build();

static {
    BootstrapLogging.bootstrap(Level.DEBUG);
}
Run Code Online (Sandbox Code Playgroud)

然后我可以在控制台中看到我的日志输出.