Ask a Question

How can I test for a Connection refused error


How can I test for a Connection refused error

I have a test case where the expected action is that the server should not be accessable and therefore a Connection refused return is expected.

The Java system reports an error as below:

Thu Jan 28 09:57:47 NZDT 2010:ERROR:Exception in request: Connection refused

Is there any thing I can do to trap this error or to allow the error to occur and still have the tests validate that nothing was returned, in response to the call.


SmartBear Alumni (Retired)

You need to write a script which will look at the MessageExchange object to check if the connection exists.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️


I have finally had a chance to get back to this. The problem with the suggestion is that because the connection is refused, an exception is thrown and no MessageExchange object is available to be queried.

I have looked at trying a groovy script following the failing step, but because of the exception, there again is no MessageExchange object to be used.

A second issue is that because of the exception, the script is shown to have failed, even though this is the correct expected result.

Cheers Kevin
Occasional Contributor

I'm currently facing the same problem and was not able to find a solution so far... after all these years have you figure out a way to solve this issue?

Showing results for 
Search instead for 
Did you mean: