Here is a simple method to check if a server is listening on a certain port. I used it to ignore certain non-critical SFTP related integration tests in a project when I hadn’t bothered starting the SFTP server.
To ignore a test (assuming JUnit) you can then do the following:
@Test
public void some_test()
{
assumeTrue(serverListening("localhost", 22));
// Rest of test...
}
public void some_test()
{
assumeTrue(serverListening("localhost", 22));
// Rest of test...
}