How to enable client side mock factory objects with Java tests?


By examining the webMethods Unit Test Framework Help documentation, I have discovered the following setting.
This seems to be quite a useful feature of WmTestSuite tests.
Is it possible to enable this setting with Java-based webMethods testing?

My JUnit tests would greatly benefit from having the factories defined on the client instead of the server,
because server side factories, when pushed to the server by mockService, seem to always initialize with the default constructor instead of the parametrized constructor I chose in my test.
This makes it so that they always do the default behavior when mocking a service, however I would like to customize the behavior given the specific parameters of the constructor (second constructor in the image below).

Mocking is done at server end only. MockDataFactory implementation types must be loaded by ServerClassLoader irrespective of where they are defined i.e. in a Client side java project or within a Server package. By design, instantiation of these types is done at runtime and using basic constructor only.
You may need to step back and review, why exactly the implementation depends on values/arguments that are set via constructor. Why not using the pipeline itself to pass data/flag/value etc. using predefined key. Once value is retrieved, the same can be removed as well (optionally) from pipeline before any further processing that might happen down the stream.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.