citrus
citrus copied to clipboard
Ability to mock subprocess calls
Some software to test integrates with other software on the same machine by just calling it as a subprocess. A Citrus test might want to mock this subprocess call, as it goes out to another module and is not part of its the test scope.
Currently Citrus does not have the ability to mock such a call.
If the software to test is a Java process there might be a way to actually mock subprocess calls via a Java agent: For example:
- Extend Citrus with a new Endpoint type "remote call" or similar
- The endpoint listens on a specific port for remote call communication
- Start the SUT with a Java agent that knows host/port of the running citrus test + port of the remote call endpoint
- When the SUT tries to run a OS process let the agent catch that call and, instead of performing it, communicate with the "remote call" endpoint, telling it about the call
- If possible the agent should simulate that the "started process" is actually running for the time being
- The remote endpoint could then feed an "endpoint(remoteCall).receive()" functionality, which could validate the call and perform any other action that are necessary at that time
- A subsequent endpoint(remoteCall).send() could then communicate back to the remote call client, so it simulates that the subprocess has ended with an exit code determined by the Citrus test. The SUT might want to continue with its processing.
It should be taken into account that the tested software and the subprocess might want to communicate with each other via placing files on the file system, which serve as input/output for the subprocess.