Open primetoxinz opened 7 years ago
Sounds about right. I managed to reproduce the issue with a smaller test case:
@Test
public void issue111() {
Command timedCommand = Command.pause(100, TimeUnit.MILLISECONDS);
Command commandGroup = CommandGroup.runSequentially(timedCommand);
WatchedCommand watched = WatchedCommand.watch(commandGroup);
CommandTester tester = new CommandTester(watched);
tester.step(1);
assertIncomplete(watched);
tester.step(101);
assertComplete(watched); // fails; command still running
}
I dug around and came to the same conclusion as you. CommandTester directly uses CommandRunner, but CommandRunner alone doesn't support CommandGroups (so it calls CommandGroup#execute
, which returns false so the command never finishes). Scheduler#buildRunner
is the needed glue.
The Scheduler does seem tightly coupled to the main framework, so I'm hesitant to try to retrofit it into CommandTester―perhaps we could instead look into extracting Scheduler#buildRunner
into CommandRunner? The static factory method pattern looks like it might help here. :smile:
It appears that due to the lack of a Scheduler the CommandTester cannot support CommandGroups in any form. This can be seen in this test which fails on the selected line since the command does not actually get executed.
Not entirely sure how this can be achieved, but it would be very helpful