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

Add "VirtualTimeScheduler#getScheduledTaskCount()" #1746

Merged
merged 1 commit into from
Jun 24, 2019

Conversation

ttddyy
Copy link
Contributor

@ttddyy ttddyy commented Jun 12, 2019

Expose "counter" as scheduled task count in VirtualTimeScheduler.

While testing publisher logic that have publishOn/subscribeOn, I'd like to have a way to check provided scheduler has performed the execution.
Since VirtualTimeScheduler already have counter that keeps track of the number of the scheduled tasks, it can be used to check whether tasks have executed on the scheduler.

For example,

mono....
  .publishOn(vts)
  .subscribe();
  
assertThat(vts.getScheduledTaskCount()).isGreaterThanOrEqualTo(1);

assertThat(vts.getScheduledTaskCount()).as("a task scheduled").isEqualTo(1);

// schedule with delay
vts = VirtualTimeScheduler.create();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest splitting it into a few different tests

@bsideup bsideup added the area/reactor-test This belongs to the reactor-test module label Jun 21, 2019
Copy link
Contributor

@bsideup bsideup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok in general, requested a test change for better maintainability

Expose "counter" as scheduled task count in VirtualTimeScheduler.
@ttddyy
Copy link
Contributor Author

ttddyy commented Jun 21, 2019

updated the PR.
Split the test to multiple test methods as suggested.

@bsideup bsideup added this to the 3.3.0.M3 milestone Jun 24, 2019
@bsideup bsideup merged commit e532799 into reactor:master Jun 24, 2019
@bsideup
Copy link
Contributor

bsideup commented Jun 24, 2019

@ttddyy thanks for your contribution! 🎉

simonbasle pushed a commit that referenced this pull request Nov 22, 2019
Since VirtualTimeScheduler already has "counter" that keeps track of the
number of the scheduled tasks, it can be used to check whether tasks
have executed on the scheduler.

This change exposes that counter as "scheduled task count".

(cherry picked from commit e532799)
(backported for the benefit of #1916 backport)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/reactor-test This belongs to the reactor-test module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants