Workflow instance should be accessible in test environment for simple assertion

オープン
#2,521 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java

調査の方向性

ファイルやテストは指定されていません。まず、issue に記載されているテスト環境と testWorkflowClient API を確認し、その後、production の QueryMethods を使わずに、最新の状態を持つ workflow instance をどのように公開できるかを判断してください。完了条件は、テストから workflow ID と run ID によって workflow を取得し、その現在の状態をアサートできることです。

索引モデルが issue の本文から書いたものです。

説明

enhancement

Is your feature request related to a problem? Please describe.
I would like to write unit tests on workflow code, and would like to access workflow for assertions in test env.

eg.

class WorkflowImpl implements Workflow {
    public String value = "something";

//// more workflow code
}

and the value is updated in the workflow code. I would like to add access the values.

Currently there is no easy way to access the workflow object, as we simply register workflow class as type

Describe the solution you'd like
I would like to access the workflow object at any point in time for test env, and it should provide me an object of workflow with latest state of workflow.

Like

var workflowImpl = (WorkflowImpl) testWorkflowClient.getWorkflowObject("workflowId", "workflowRunId");
assertThat(workflowImpl.value, is("some-assertion-value"));

Describe alternatives you've considered
The other method we have considered is to add a QueryMethod in the workflow but we don't want to add QueryMethod in production code at all.

We can surely do it for tests as well as mentioned at https://temporalio.slack.com/archives/CTT84KXK9/p1747167261307199?thread_ts=1747086843.705119&cid=CTT84KXK9, but it can cause issues when you have multiple variables, and adding QueryMethod for each a lot, and managing QueryMethod for testing can be cumbersome.

Additional context
Discussed this previously at Github - https://temporalio.slack.com/archives/CTT84KXK9/p1747086843705119

主要言語
Java
スター
447
フォーク
278
平均マージ
3日 22時間
マージ済み PR(30日)
28

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

temporalio/sdk-java のほかの issue

temporalio/sdk-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。