弹簧状态机使用statemachinetestplan来测试一个选择过渡
如果我设置了如下:
transitionConfigurer
.withExternal()
.source(FIRST)
.event(EVENT_1)
.target(SECOND)
.and()
.withChoice()
.source(SECOND)
.first(THIRD, new Guard(someService))
.last(FIRST)
.and()
.withExternal()
.source(THIRD)
.event(EVENT_2)
.target(FIRST);
如何使用statemachinetestplan测试使用。
我有一个如下所示的statemachinetestplan设置,这会创建一台具有初始状态的状态计算机,然后我希望能够测试选择。但是,当我在测试计划中执行.Step()时,什么也不会发生:
createStateMachineAndSetInitialState(SECOND, workflowCreator);
StateMachineTestPlan<State, Event> plan = StateMachineTestPlanBuilder.<State, Event> builder()
.defaultAwaitTime(1)
.stateMachine(machine)
.step()
.expectState(THIRD)
.and()
.build();
plan.test();
If I have a StateMachine set up as below:
transitionConfigurer
.withExternal()
.source(FIRST)
.event(EVENT_1)
.target(SECOND)
.and()
.withChoice()
.source(SECOND)
.first(THIRD, new Guard(someService))
.last(FIRST)
.and()
.withExternal()
.source(THIRD)
.event(EVENT_2)
.target(FIRST);
How can I test the withChoice using a StateMachineTestPlan.
I have a StateMachineTestPlan set up as below, this creates a State Machine with an initial state of SECOND, I want to then be able to test the choice. However, when I perform the .step() in the test plan nothing happens:
createStateMachineAndSetInitialState(SECOND, workflowCreator);
StateMachineTestPlan<State, Event> plan = StateMachineTestPlanBuilder.<State, Event> builder()
.defaultAwaitTime(1)
.stateMachine(machine)
.step()
.expectState(THIRD)
.and()
.build();
plan.test();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您可以为下面的方法分享您的自定义覆盖吗?
您需要确保已经配置了这样的选择状态:
似乎您已达到状态(第二),但没有进入Pseeudo-State。您的测试停止了哪个状态?
First of all, can you please share your custom override for the method below?
You need to make sure you have configured choice states like this:
It seems like you reached state (SECOND) but did not enter in the CHOICE pseudo-state. In which state have your test stopped at?