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

A single checkpoint should not supersede a succeedingThenComplete #90

Open
doctorpangloss opened this issue Dec 1, 2020 · 3 comments
Open

Comments

@doctorpangloss
Copy link

doctorpangloss commented Dec 1, 2020

Describe the feature

Given code like this:

@Test
void testProc(VertxTestContext testContext) {
  var checkpoint = testContext.checkpoint();
  returnsFuture()
    .onSuccess(v -> checkpoint.flag())
    .compose(v -> anotherReturnsFuture())
    .onComplete(testContext.succeedingThenComplete());
}

the user's intent is almost always to flag the checkpoint but to keep running until testContext.succeedingThenComplete() is called with a succeeded future.

Currently, creating a checkpoint like in the above statement will actually end the test as soon as the test thread notices checkpoint.flag() (i.e. the injected testContext.awaitCompletion will be satisfied). This is very clunky.

Use cases

A common use case is to run some side-by-side check independent the test code and use checkpoints to flag that your assertions were actually run. For example you might mock a class and checkpoint.flag() inside a mocked method that runs assertions on its arguments.

Contribution

I can implement this feature.

@jponge
Copy link
Member

jponge commented Dec 1, 2020

When there are checkpoints TestContext completes when they have all completed, so onComplete shall also flag a checkpoint.

@jponge
Copy link
Member

jponge commented Dec 1, 2020

Also how would you spot that the test context succeedingThenComplete method could eventually be called?

succeedingThenComplete is really a shortcut for completing immediately when one asynchronous operation completes.

@doctorpangloss
Copy link
Author

doctorpangloss commented Dec 1, 2020

Yes, but what happens is the test completes before succeedingThenComplete 's returned handler is called, because of something with checkpoint.flag().

In my opinion, behavior should be, essentially:

Handler<AsyncResult<T>> succeedingThenComplete() {
  return (ar) -> {/*if ar succeeded, wait until timeout for all remaining checkpoints to be passed.
  otherwise fail.*/}
}

right now it's

inject a testContext
beginning of user's test code {
  since the user called .checkpoint(),
    the injected awaitCompletion will only wait for that one checkpoint to be flagged,
    instead of the .completeNow() from .succeedingThenComplete()'s handler
} end of user's test code
inject awaitCompletion

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

No branches or pull requests

2 participants