Fail On No Stubs
-
在
@AutoConfigureStubRunner
注解中将failOnNoStubs
属性设置为false
。 -
在
StubRunnerRule
或StubRunnerExtension
中调用withFailOnNoStubs(false)
方法。
默认情况下,如果未找到任何存根,Stub Runner 将失败。要更改此行为,请将注释中的“failOnNoStubs”属性设置为“false”,或在 JUnit 规则或扩展中调用“withFailOnNoStubs(false)”方法。以下示例展示了如何执行此操作:
Annotation
@AutoConfigureStubRunner(
stubsMode = StubRunnerProperties.StubsMode.REMOTE,
repositoryRoot = "stubs://file://location/to/the/contracts",
ids = "com.example:some-producer",
failOnNoStubs = false)
JUnit 4 Rule
@Rule
public StubRunnerRule rule = new StubRunnerRule()
.downloadStub("com.example:some-producer")
.repoRoot("stubs://file://location/to/the/contracts")
.stubsMode(StubRunnerProperties.StubsMode.REMOTE)
.withFailOnNoStubs(false);
JUnit 5 Extension
@RegisterExtension
public StubRunnerExtension stubRunnerExtension = new StubRunnerExtension()
.downloadStub("com.example:some-producer")
.repoRoot("stubs://file://location/to/the/contracts")
.stubsMode(StubRunnerProperties.StubsMode.REMOTE)
.withFailOnNoStubs(false);