Spring boot 如何在Springboot应用程序中测试@HystrixCommand回退方法
我在我的方法中使用@HystrixCommand,如下所示Spring boot 如何在Springboot应用程序中测试@HystrixCommand回退方法,spring-boot,hystrix,spring-boot-test,Spring Boot,Hystrix,Spring Boot Test,我在我的方法中使用@HystrixCommand,如下所示 @HystrixCommand(fallbackMethod = "fallbackCircuit", groupKey = "group-key", commandProperties = { @HystrixProperty(name = "requestCache.enabled", value = "true"), @HystrixProperty(name = "executio
@HystrixCommand(fallbackMethod = "fallbackCircuit", groupKey = "group-key", commandProperties = {
@HystrixProperty(name = "requestCache.enabled", value = "true"),
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")})
public void someMethod(String input){
...
}
public void fallbackCircuit(String input, Throwable e){
...
}
但我无法测试回退方法?在我的测试中没有调用回退方法。我想我没有正确设置测试。测试回退方法的更好方法是什么?虽然没有直接测试回退方法,但我回答的另一个问题有一个解决方案,表明断路器已触发。 看见
如果您感兴趣。没有必要测试@HystrixCommand(),如果您想在UT中测试回退方法,您可以在单元测试中直接调用回退方法,并在其响应/结果上断言