Is it possible to use TestActivityExtension with activities that do not implement DynamicActivity? samples-java/HelloDynamicActivityJUnit5Test.java at main · temporalio/samples-java · GitHub
I recently added Activity.getExecutionContext() to my activity, so looks like I now need to use Temporal testing facilities for calling my activity. Otherwise, I get the following error when running the unit test: ActivityExecutionContext can be used only inside of activity implementation methods and in the same thread that invoked an activity.
ref: Testing an activity implementation when using ActivityExecutionContext to asynchronously execute activities
You should be able to test your activities with TestActivityExtension, having your activity code invocations to Activity.getExecutionContext().
Which SDK version are you using?
Are you trying to do something like samples-java/HelloDynamicActivityJUnit5Test.java at main · temporalio/samples-java · GitHub but with an activity that does not implement DynamicActivity?
If you want to share your code, I can try to reproduce the issue.
We’re using 1.12.0.
Yes, I’m trying to do something similar to samples-java/HelloDynamicActivityJUnit5Test.java at main · temporalio/samples-java · GitHub but with activity that does not implement DynamicActivity.
I have written a small test using sdk-java v1.12.0 and worked for me temporal-examples/HelloActivityJUnit5Test.java at TestActivityExtension-sdkv-1.12 · antmendoza/temporal-examples · GitHub
I would recommend you to upgrade to the latest SDK version if you can.
let me know if this is what you are looking for.