Is it possible to configure the jUnit test to run only if it is online?

Some tests do not make sense to run when I'm offline, having access to shared resources. Running these tests offline will result in a failed test and an exception.

Is it possible for a given test to be configured in such a way that it only works when a condition is satisfied, for example, when there is a network connection?

+4
source share
1 answer

It sounds like a job for speculation .

@Test public void someTestThatNeedsNetworkConnectivity() { assumeTrue(thereIsNetworkConnectivity()); // ... } 
+4
source

All Articles