我有一个前提条件步骤,测试流程和后置条件步骤。如果前提条件步骤失败,我想跳过测试流程。在文档Configuring a step无法正常工作之后,无论执行什么测试流程都将被执行。我想念什么? 使用Spring Boot 2.0.5.RELEASE和Spring Batch 4.0.1.RELEASE。
val testingFlow = FlowBuilder<SimpleFlow>("TESTING_FLOW")
.start(testExecutorDecider)
.on(TestExecutor.JUNIT.name).to(junitExecutionStep())
.from(testExecutorDecider).on(TestExecutor.GRADLE.name).to(gradleExecutionStep())
.end()
return jobs.get(touchstoneProperties.jobName)
.start(preConditionsStep())
.on("*").to(testingFlow)
.from(preConditionsStep()).on("FAILED").to(postConditionsStep())
.from(testingFlow).on("*").to(postConditionsStep())
.end()
.build()
答案 0 :(得分:0)
我自己弄清楚了。
val testingFlow = FlowBuilder<SimpleFlow>("TESTING_FLOW")
.start(testExecutorDecider)
.on(TestExecutor.JUNIT.name).to(junitExecutionStep())
.from(testExecutorDecider).on(TestExecutor.GRADLE.name).to(gradleExecutionStep())
.from(testExecutorDecider).on("*").end()
.build()
return jobs.get(touchstoneProperties.jobName)
.start(preConditionsStep())
.on("*").to(testingFlow)
.from(testingFlow).on("*").to(postConditionsStep()).end()
.build()
TestExecutorDecider
class TestExecutorDecider(private val touchstoneProperties: TouchstoneProperties) : JobExecutionDecider {
companion object {
private val LOGGER = LoggerFactory.getLogger(TestExecutorDecider::class.java)
}
override fun decide(jobExecution: JobExecution, stepExecution: StepExecution): FlowExecutionStatus {
return when (stepExecution.exitStatus.compareTo(ExitStatus.FAILED)) {
0 -> FlowExecutionStatus("SKIPPED")
else -> {
LOGGER.info("Test executor: {}", touchstoneProperties.testExecutor)
return FlowExecutionStatus(touchstoneProperties.testExecutor.name)
}
}
}
}