Search code examples
testingproxyintegration-testingcitrus-framework

Writing tests with http request without response


I need to prepare a Java test (citrus framework) which initial step is sending a http request. Unfortunately my app under tests does not reply to this http request with anything while my testing framework expects to have a response and generates an error otherwise. The best way to deal with such a situation which came to my mind is to use some kind of a proxy between my testing framework and actual application which will forward the test request to the actual application and reply back to the testing framework with OK status not waiting for the response from app. Does it make a sense? How could I prepare such a proxy assuming that my tests are to be running with maven invocation?


Solution

  • I see following options:

    • Fire and forget: send the Http request (using the fork mode on the send operation in Citrus) and do not care for the response at all. Just leave out the receive message action to ignore the response in Citrus.
    • Expect the timeout: Send the Http request and use the receive timeout action to verify that the client does not receive a response in the given time
    • Assert/catch the timeout exception: Use the assert or catch action in Citrus to handle the timeout exception when sending the http request

    Personally I would go for the option #2 where you send the Http request and verify that there is no response for a given amount of time. This makes sure that the actual behavior of your application to not send any response does not change over time.