Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommandTester unable to support CommandGroup #111

Open
primetoxinz opened this issue Mar 22, 2017 · 1 comment
Open

CommandTester unable to support CommandGroup #111

primetoxinz opened this issue Mar 22, 2017 · 1 comment

Comments

@primetoxinz
Copy link
Contributor

primetoxinz commented Mar 22, 2017

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

@rothso
Copy link
Contributor

rothso commented Jun 14, 2017

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. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants