Workflow instance should be accessible in test environment for simple assertion

Aperta
#2,521 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
java

Direzione di ricerca

Non vengono indicati file o test. Inizia esaminando l’ambiente di test e l’API testWorkflowClient descritti nell’issue, quindi determina come potrebbe essere esposta un’istanza del workflow con il suo stato più recente senza QueryMethods di produzione. Il lavoro è completato quando un test può recuperare il workflow tramite l’ID del workflow e l’ID dell’esecuzione e verificare il suo stato corrente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Java
Stelle
447
Fork
278
Merge medio
3g 22h
PR unite (30g)
28

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di temporalio/sdk-java

Tutte le issue di temporalio/sdk-java

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.