Is it possible to set a workflow version while unit testing the workflow? In my debugging, it seems that the static Workflow.getVersion calls will always return the max supported version.
Not until this enhancement is implemented.
One way to test this is by using execution history replay. Record a workflow history using an old version, then replay it from a JSON file using the updated code.
1 Like
Should’ve checked the github issue tab, thanks Maxim!
Just to add since this thread was linked recently in other questions. You can register a test worker interceptor with TestWorkflowEnvironment and use workflow outbound interceptor to intercept
getVersion calls:
public class MyWorkflowOutboundCallsInterceptor
extends WorkflowOutboundCallsInterceptorBase {
// ...
@Override
public int getVersion(String changeId, int minSupported, int maxSupported) {
// ...
return super.getVersion(changeId, minSupported, maxSupported);
}
}
if that helps