Skip to content

Conversation

GreyTeardrop
Copy link
Contributor

@GreyTeardrop GreyTeardrop commented Jul 8, 2021

What was changed

  • The TestWorkflowExtension is changed to support per-test overrides for the virtual time used by the TestWorkflowEnvironment.
  • Somewhat unrelated, the extension code is polished a bit: the whole WorkflowOptions is stored in the extension context instead of just the task queue name, to reduce some code duplication.
  • Extend TestWorkflowExtension and TestActivityExtension to support dynamic workflow/activity scenarios.

Why?

One of our workflows has time-sensitive logic and we'd like to test it in multiple scenarios that differ in the initial workflow time. Right now we either have to fall back to manually managing TestWorkflowEnvironment or to split those scenarios into multiple test classes.

Checklist

  1. Closes
  2. How was this tested: extended existing unit test
  3. Any docs updates needed? Longer-term, both JUnit 4 and JUnit 5 extensions could be documented on the Java SDK testing and debugging page.

Override per-test initial workflow time via the @WorkflowInitialTime
annotation.
@GreyTeardrop GreyTeardrop force-pushed the junit5-initial-time-override branch from 539e89b to 174692f Compare July 8, 2021 18:23
Extend TestActivityExtension and TestWorkflowExtension to support
dynamic activity and workflow implementations.

If a dynamic implementation is registered with the extension, it would
support injecting any typed stub into a test.
@GreyTeardrop GreyTeardrop force-pushed the junit5-initial-time-override branch from 31ada12 to a198283 Compare July 10, 2021 10:20
@GreyTeardrop GreyTeardrop changed the title Per-test overrides for the initial workflow time Polish JUnit5 extension: per-test initial time, dynamic workflows and activities Jul 10, 2021
Only inject proper workflow/activity interfaces.
@Spikhalskiy Spikhalskiy merged commit 99e7103 into temporalio:master Jul 27, 2021
@GreyTeardrop GreyTeardrop deleted the junit5-initial-time-override branch July 27, 2021 22:17
@Spikhalskiy
Copy link
Contributor

Spikhalskiy commented Jul 27, 2021

Thank you for your contribution!

@vkoby vkoby mentioned this pull request Aug 5, 2021
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

Successfully merging this pull request may close these issues.

3 participants