I am writing unit tests for a workflow using the annotation @RegisterExtension that injects the desired workflow implementation.
My workflow invokes multiple activity methods of a certain MyActivityImpl.class
I have added the following @InjectMocks
MyActivityImpl activity
However the following
when(activity.someMethod).thenReturn(someResult)
instead of returning someResult always tries to execute the implementation of someMethod
The links to java testing samples is broken. And upon visiting the working link, I found the test cases to be too trivial.
Are there better practical testing samples? Are there samples that use junit5?
Like testing a workflow with few activities in it and how to mock those activities as the above straightforward approach doesn’t seem to be working
Thank you maxim. The link helped.
The example that helped me is
as I planned to use junit5
It would be great if this was linked under junit5 testing in the documentation, as the documentation missed out the important part of the code // withoutAnnotations() is required to stop Mockito from copying
** // method-level annotations from the GreetingActivities interface**
GreetingActivities activities =
mock(GreetingActivities.class, withSettings().withoutAnnotations());