[英]How to initialize bundle in test class in Dropwizard
I'm using dropwizard and now i'm stuck. 我正在使用dropwizard,现在被卡住了。 When i added new bundle, which give's me data from other source, my resource test cases are failing, because i dont know how to test my resource now.
当我添加新的包(从其他来源获得我的数据)时,我的资源测试用例失败了,因为我现在不知道如何测试我的资源。 I've tried using mockito, but it didn't work anyway.
我已经尝试过使用Mockito,但是无论如何它还是没有用。
So here's my question - how to initialize bundle in my test class so my test objects would be able to get data from bundle correctly? 所以这是我的问题-如何在测试类中初始化包,以便我的测试对象能够正确地从包中获取数据? Or maybe you would have other solutions to this problem?
也许您会对此问题有其他解决方案?
For testing dropwizard resource use dropwizard-testing package. 要测试dropwizard资源,请使用dropwizard-testing软件包。 With this you can define class rule and start up your context for tests:
这样,您可以定义类规则并启动测试上下文:
@ClassRule
public static final DropwizardAppRule<TestConfiguration> RULE =
new DropwizardAppRule<TestConfiguration>(MyApp.class, "my-app-config.yaml");
Also you can test resources without up context with ResourceTestRule class. 您也可以使用ResourceTestRule类在没有上下文的情况下测试资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.